1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Part of the AmazonGiftCode package. |
5
|
|
|
* Author: Kashyap Merai <[email protected]> |
6
|
|
|
* |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace kamerk22\AmazonGiftCode\Config; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
class Config implements ConfigInterface |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* The current Endpoint version. |
18
|
|
|
* |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
private $_endpoint; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The AWS Access Key. |
25
|
|
|
* |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
private $_accessKey; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* The AWS Secret. |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
private $_secretKey; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* The Amazon Gift Card Partner. |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
private $_partnerId; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* The Amazon Gift Card Currency. |
46
|
|
|
* |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
private $_currency; |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
public function __construct($key, $secret, $partner, $endpoint, $currency) |
53
|
|
|
{ |
54
|
|
|
|
55
|
|
|
$this->setAccessKey($key ?: config('amazongiftcode.key')); |
56
|
|
|
$this->setSecret($secret ?: config('amazongiftcode.secret')); |
57
|
|
|
$this->setPartner($partner ?: config('amazongiftcode.partner')); |
58
|
|
|
$this->setEndpoint($endpoint ?: config('amazongiftcode.endpoint')); |
59
|
|
|
$this->setCurrency($currency ?: config('amazongiftcode.currency')); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return String |
64
|
|
|
*/ |
65
|
|
|
public function getEndpoint(): string |
66
|
|
|
{ |
67
|
|
|
return $this->_endpoint; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param $endpoint |
73
|
|
|
* @return ConfigInterface |
74
|
|
|
*/ |
75
|
|
|
public function setEndpoint($endpoint): ConfigInterface |
76
|
|
|
{ |
77
|
|
|
$this->_endpoint = parse_url($endpoint, PHP_URL_HOST); |
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return String |
84
|
|
|
*/ |
85
|
|
|
public function getAccessKey(): string |
86
|
|
|
{ |
87
|
|
|
return $this->_accessKey; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param String $key |
92
|
|
|
* @return ConfigInterface |
93
|
|
|
*/ |
94
|
|
|
public function setAccessKey($key): ConfigInterface |
95
|
|
|
{ |
96
|
|
|
$this->_accessKey = $key; |
97
|
|
|
|
98
|
|
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return String |
103
|
|
|
*/ |
104
|
|
|
public function getSecret(): string |
105
|
|
|
{ |
106
|
|
|
return $this->_secretKey; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param String $secret |
111
|
|
|
* @return ConfigInterface |
112
|
|
|
*/ |
113
|
|
|
public function setSecret($secret): ConfigInterface |
114
|
|
|
{ |
115
|
|
|
$this->_secretKey = $secret; |
116
|
|
|
|
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return String |
122
|
|
|
*/ |
123
|
|
|
public function getCurrency(): string |
124
|
|
|
{ |
125
|
|
|
return $this->_currency; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param String $currency |
130
|
|
|
* @return ConfigInterface |
131
|
|
|
*/ |
132
|
|
|
public function setCurrency($currency): ConfigInterface |
133
|
|
|
{ |
134
|
|
|
$this->_currency = $currency; |
135
|
|
|
|
136
|
|
|
return $this; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @return String |
141
|
|
|
*/ |
142
|
|
|
public function getPartner(): string |
143
|
|
|
{ |
144
|
|
|
return $this->_partnerId; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @param String $partner |
149
|
|
|
* @return ConfigInterface |
150
|
|
|
*/ |
151
|
|
|
public function setPartner($partner): ConfigInterface |
152
|
|
|
{ |
153
|
|
|
$this->_partnerId = $partner; |
154
|
|
|
|
155
|
|
|
return $this; |
156
|
|
|
} |
157
|
|
|
} |