Completed
Pull Request — master (#6)
by
unknown
03:48 queued 10s
created

Client::authorize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 10
ccs 0
cts 6
cp 0
crap 6
rs 10
1
<?php
2
3
namespace Slides\Connector\Auth\Clients\Mandrill;
4
5
use Slides\Connector\Auth\Clients\AbstractClient;
6
use Slides\Connector\Auth\Clients\Mandrill\Requests;
7
8
/**
9
 * Class Client
10
 *
11
 * @package Slides\Connector\Auth\Clients\Mandrill
12
 */
13
class Client extends AbstractClient
14
{
15
    /**
16
     * Base URL of resource
17
     *
18
     * @var string
19
     */
20
    protected $baseUrl = 'https://mandrillapp.com/api/1.0/';
21
22
    /**
23
     * Get client's credentials
24
     *
25
     * @return array
26
     */
27
    protected function credentials(): array
28
    {
29
        return config('connector.credentials.clients.mandrill', []);
30
    }
31
32
    /**
33
     * Authorize the client
34
     *
35
     * @return void
36
     */
37
    protected function authorize()
38
    {
39
        if (!$secret = $this->credential('secretKey')) {
40
            $this->abort();
41
42
            return;
43
        }
44
45
        $this->body([
46
            'key' => $secret
47
        ]);
48
    }
49
50
    /**
51
     * List of supported requests
52
     *
53
     * @return array
54
     */
55
    public function requests(): array
56
    {
57
        return [
58
            Requests\SendTemplate::class
59
        ];
60
    }
61
62
    /**
63
     * Send a new transactional message through Mandrill using a template
64
     *
65
     * @param array $attributes
66
     *
67
     * @return mixed
68
     */
69
    public function sendTemplate(array $attributes)
70
    {
71
        return $this->request(new Requests\SendTemplate($this, $attributes));
72
    }
73
}