|
8 | 8 | class Organizations extends BaseClient |
9 | 9 | { |
10 | 10 | protected $ENDPOINT = 'organizations'; |
11 | | - protected $API_VERSION = 'v1'; |
12 | 11 |
|
13 | 12 |
|
14 | 13 | /** |
@@ -211,20 +210,66 @@ public function uploadCertificate($id, $params) |
211 | 210 | } |
212 | 211 |
|
213 | 212 | /** |
214 | | - * Get the Api Keys for an Organization |
| 213 | + * Get the Test Api Key for an Organization |
215 | 214 | * |
216 | 215 | * @param id : Unique ID for Organization |
217 | 216 | * |
218 | | - * @return JSON object for requested Organization |
| 217 | + * @return String Test Api Key |
| 218 | + * |
| 219 | + * @throws Facturapi_Exception |
| 220 | + **/ |
| 221 | + public function getTestApiKey($id) |
| 222 | + { |
| 223 | + try { |
| 224 | + return json_decode($this->execute_get_request($this->get_request_url($id) . "/apikeys/test")); |
| 225 | + } catch (Facturapi_Exception $e) { |
| 226 | + throw new Facturapi_Exception('Unable to get organization\'s test key: ' . $e); |
| 227 | + } |
| 228 | + } |
| 229 | + |
| 230 | + /** |
| 231 | + * Renews the Test Api Key for an Organization and makes the previous one inactive |
| 232 | + * |
| 233 | + * @param id : Unique ID for Organization |
| 234 | + * |
| 235 | + * @return String Test Api Key |
219 | 236 | * |
220 | 237 | * @throws Facturapi_Exception |
221 | 238 | **/ |
222 | | - public function getApiKeys($id) |
| 239 | + public function renewTestApiKey($id) |
223 | 240 | { |
224 | 241 | try { |
225 | | - return json_decode($this->execute_get_request($this->get_request_url($id) . "/apikeys")); |
| 242 | + return json_decode( |
| 243 | + $this->execute_JSON_put_request( |
| 244 | + $this->get_request_url($id) . "/apikeys/test", |
| 245 | + [] |
| 246 | + ) |
| 247 | + ); |
| 248 | + } catch (Facturapi_Exception $e) { |
| 249 | + throw new Facturapi_Exception('Unable to renew organization\'s test key: ' . $e); |
| 250 | + } |
| 251 | + } |
| 252 | + |
| 253 | + /** |
| 254 | + * Renews the Test Api Key for an Organization and makes the previous one inactive |
| 255 | + * |
| 256 | + * @param id : Unique ID for Organization |
| 257 | + * |
| 258 | + * @return String Live Api Key |
| 259 | + * |
| 260 | + * @throws Facturapi_Exception |
| 261 | + **/ |
| 262 | + public function renewLiveApiKey($id) |
| 263 | + { |
| 264 | + try { |
| 265 | + return json_decode( |
| 266 | + $this->execute_JSON_put_request( |
| 267 | + $this->get_request_url($id) . "/apikeys/live", |
| 268 | + [] |
| 269 | + ) |
| 270 | + ); |
226 | 271 | } catch (Facturapi_Exception $e) { |
227 | | - throw new Facturapi_Exception('Unable to get organization\'s api keys: ' . $e); |
| 272 | + throw new Facturapi_Exception('Unable to renew organization\'s live key: ' . $e); |
228 | 273 | } |
229 | 274 | } |
230 | 275 |
|
|
0 commit comments