Skip to content

Commit d50be1b

Browse files
authored
TS-167: Option to pass webhook url on authentication and edit base url (#17)
1 parent 7fedea3 commit d50be1b

4 files changed

Lines changed: 28 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [0.15.1] - 2021-11-29
5+
- Support for `Webhook-URL` header on authentication
6+
- New `domain` option to switch between environments easily.
7+
48
## [0.15.0] - 2021-11-28
59
- Added support for Account Information Service (AIS)
610
- Fixes a bug when multiple authentication scopes could not be supplied

src/AuthTrait.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ private function getAuthHeaderAttr($attr = [])
8888
$data[] = 'Redirect-URL: ' . $attr['Redirect-URL'];
8989
}
9090

91+
if ($this->getOption('version') == '0.3') {
92+
if (isset($attr['Webhook-URL'])) {
93+
$data[] = 'Webhook-URL: ' . $attr['Webhook-URL'];
94+
}
95+
}
96+
9197
return $data;
9298
}
9399

src/EndpointInterface.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ interface EndpointInterface
1010
/**
1111
* Base URL used for sending API calls.
1212
*/
13-
const BASE_URL = 'https://api.kevin.eu/platform';
14-
const BASE_URL_V01 = self::BASE_URL . '/v0.1';
15-
const BASE_URL_V02 = self::BASE_URL . '/v0.2';
16-
const BASE_URL_V03 = self::BASE_URL . '/v0.3';
13+
14+
const SERVICE_NAME = '/platform';
15+
const BASE_PATH_V01 = self::SERVICE_NAME . '/v0.1';
16+
const BASE_PATH_V02 = self::SERVICE_NAME . '/v0.2';
17+
const BASE_PATH_V03 = self::SERVICE_NAME . '/v0.3';
1718

1819
/**
1920
* List of Auth related endpoints.

src/UtilityTrait.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ private function processOptionsAttributes(array $options)
329329
{
330330
$data = [
331331
'error' => 'exception',
332-
'version' => '0.3'
332+
'version' => '0.3',
333+
'domain' => 'api.kevin.eu'
333334
];
334335

335336
$optionError = ['exception', 'array'];
@@ -347,6 +348,11 @@ private function processOptionsAttributes(array $options)
347348
$data['lang'] = $options['lang'];
348349
}
349350

351+
$optionDomain = ['api-kevin.eu', 'api-sandbox.kevin.eu', 'api-dev.kevin.eu'];
352+
if (isset($options['domain']) && in_array($options['domain'], $optionDomain)) {
353+
$data['domain'] = $options['domain'];
354+
}
355+
350356
if (isset($options['pluginVersion'])) {
351357
$data['pluginVersion'] = $options['pluginVersion'];
352358
}
@@ -403,19 +409,21 @@ private function getOption($option)
403409
private function getBaseUrl()
404410
{
405411
$version = $this->getOption('version');
412+
$domain = $this->getOption('domain');
413+
$scheme = 'https://';
406414

407415
switch ($version) {
408416
case '0.1':
409-
$base_url = self::BASE_URL_V01;
417+
$base_url = $scheme . $domain . self::BASE_PATH_V01;
410418
break;
411419
case '0.2':
412-
$base_url = self::BASE_URL_V02;
420+
$base_url = $scheme . $domain . self::BASE_PATH_V02;
413421
break;
414422
case '0.3':
415-
$base_url = self::BASE_URL_V03;
423+
$base_url = $scheme . $domain . self::BASE_PATH_V03;
416424
break;
417425
default:
418-
$base_url = self::BASE_URL_V02;
426+
$base_url = $scheme . $domain . self::BASE_PATH_V03;
419427
}
420428

421429
return $base_url;

0 commit comments

Comments
 (0)