|
9 | 9 | class OSTSdk |
10 | 10 | { |
11 | 11 |
|
12 | | - /** @var object object to access methods */ |
13 | | - public $services; |
| 12 | + /** @var object object to access methods */ |
| 13 | + public $services; |
14 | 14 |
|
15 | | - /** |
16 | | - * Class constructor. |
17 | | - * |
18 | | - * @param array $params Array containing the necessary params { |
19 | | - * @type string $apiKey API Key. |
20 | | - * @type string $apiSecret API Secret. |
21 | | - * @type string $baseUrl Base API URL. |
22 | | - * } |
23 | | - * |
24 | | - * @throws \Exception |
25 | | - */ |
26 | | - public function __construct(array $params) |
27 | | - { |
28 | | - // Extract API major version |
29 | | - $apiEndpointVersion = explode('/', $params['apiBaseUrl'])[3]; |
30 | | - if (empty($apiEndpointVersion)) { |
31 | | - $this->services = new \OST\V0\Manifest($params); |
32 | | - } elseif (!empty($apiEndpointVersion) && strtolower($apiEndpointVersion) === 'v1') { |
33 | | - $this->services = new \OST\V1\Manifest($params); |
34 | | - } else { |
35 | | - throw new \Exception('Api endpoint is invalid'); |
36 | | - } |
| 15 | + /** |
| 16 | + * Class constructor. |
| 17 | + * |
| 18 | + * @param array $params Array containing the necessary params { |
| 19 | + * @type string $apiKey API Key. |
| 20 | + * @type string $apiSecret API Secret. |
| 21 | + * @type string $baseUrl Base API URL. |
| 22 | + * } |
| 23 | + * |
| 24 | + * @throws \Exception |
| 25 | + */ |
| 26 | + public function __construct(array $params) |
| 27 | + { |
| 28 | + // Extract API version |
| 29 | + $apiEndpointVersion = explode('/', $params['apiBaseUrl'])[3]; |
| 30 | + |
| 31 | + # Provide access to version specific API endpoints |
| 32 | + if (is_null($apiEndpointVersion) || $apiEndpointVersion == '') { |
| 33 | + $this->services = new \OST\V0\Manifest($params); |
| 34 | + } elseif (strtolower($apiEndpointVersion) == 'v1') { |
| 35 | + $this->services = new \OST\V1\Manifest($params); |
| 36 | + } elseif (strtolower($apiEndpointVersion) == 'v1.1') { |
| 37 | + $this->services = new \OST\V1Dot1\Manifest($params); |
| 38 | + } else { |
| 39 | + throw new \Exception('Api endpoint is invalid'); |
37 | 40 | } |
| 41 | + |
| 42 | + } |
| 43 | + |
| 44 | + |
38 | 45 | } |
0 commit comments