Completed
Push — master ( 94ee56...6e6d73 )
by Cesar
20s queued 10s
created

ApiConfiguration::addHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PagaMasTarde\OrdersApiClient\Model;
4
5
use PagaMasTarde\OrdersApiClient\Exception\ClientException;
6
use PagaMasTarde\OrdersApiClient\Model\Order\Configuration\Urls;
7
8
/**
9
 * Class ApiConfiguration
10
 * @package PagaMasTarde\OrdersApiClient\Model
11
 */
12
class ApiConfiguration extends AbstractModel
13
{
14
    /**
15
     * Base Production URL for API calls
16
     */
17
    const BASE_URI = 'https://api.pagamastarde.com/v2';
18
19
    /**
20
     * Base Sandbox URL for API calls
21
     */
22
    const SANDBOX_BASE_URI = 'https://api-stg.pagamastarde.com/v2';
23
24
    /**
25
     * Private key for API calls
26
     *
27
     * @var string $privateKey
28
     */
29
    protected $privateKey;
30
31
    /**
32
     * Public key for API calls
33
     *
34
     * @var string $publicKey
35
     */
36
    protected $publicKey;
37
38
    /**
39
     * SandBox url should be specified here
40
     *
41
     * @var string $baseUri
42
     */
43
    protected $baseUri;
44
45
    /**
46
     * Headers send to the API
47
     *
48
     * @var array
49
     */
50
    protected $headers = array();
51
52
    /**
53
     * @return string
54
     */
55
    public function getPrivateKey()
56
    {
57
        return $this->privateKey;
58
    }
59
60
    /**
61
     * @param string $privateKey
62
     *
63
     * @return ApiConfiguration
64
     */
65
    public function setPrivateKey($privateKey)
66
    {
67
        $this->privateKey = $privateKey;
68
69
        return $this;
70
    }
71
72
    /**
73
     * @return string
74
     */
75
    public function getPublicKey()
76
    {
77
        return $this->publicKey;
78
    }
79
80
    /**
81
     * @param string $publicKey
82
     *
83
     * @return ApiConfiguration
84
     */
85
    public function setPublicKey($publicKey)
86
    {
87
        $this->publicKey = $publicKey;
88
89
        return $this;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function getBaseUri()
96
    {
97
        return $this->baseUri;
98
    }
99
100
    /**
101
     * @param $baseUri
102
     *
103
     * @return $this
104
     * @throws ClientException
105
     */
106
    public function setBaseUri($baseUri)
107
    {
108
        if (Urls::urlValidate($baseUri)) {
109
            $this->baseUri = $baseUri;
110
            return $this;
111
        }
112
113
        throw new ClientException('Invalid base URL on the ApiConfiguration setter');
114
    }
115
116
    /**
117
     * @return array
118
     */
119
    public function getHeaders()
120
    {
121
        return $this->headers;
122
    }
123
124
    /**
125
     * @param array $headers
126
     * @return ApiConfiguration
127
     */
128
    public function setHeaders($headers)
129
    {
130
        $this->headers = $headers;
131
132
        return $this;
133
    }
134
135
    /**
136
     * @param $header
137
     * @return ApiConfiguration
138
     */
139
    public function addHeader($header)
140
    {
141
        $this->headers[] = $header;
142
143
        return $this;
144
    }
145
}
146