|
3 | 3 | /** |
4 | 4 | * Vonage Client Library for PHP |
5 | 5 | * |
6 | | - * @copyright Copyright (c) 2016-2020 Vonage, Inc. (http://vonage.com) |
| 6 | + * @copyright Copyright (c) 2016-2022 Vonage, Inc. (http://vonage.com) |
7 | 7 | * @license https://github.com/Vonage/vonage-php-sdk-core/blob/master/LICENSE.txt Apache License 2.0 |
8 | 8 | */ |
9 | 9 |
|
|
14 | 14 | use Psr\Http\Client\ClientExceptionInterface; |
15 | 15 | use Vonage\Client\APIClient; |
16 | 16 | use Vonage\Client\APIResource; |
17 | | -use Vonage\Client\ClientAwareInterface; |
18 | | -use Vonage\Client\ClientAwareTrait; |
19 | 17 | use Vonage\Client\Exception as ClientException; |
20 | 18 | use Vonage\Client\Exception\Request as ClientRequestException; |
21 | | -use Vonage\Client\Exception\Validation as ClientValidationException; |
22 | 19 | use Vonage\Entity\Filter\KeyValueFilter; |
23 | | -use Vonage\InvalidResponseException; |
24 | 20 |
|
25 | | -use function array_key_exists; |
26 | 21 | use function count; |
27 | 22 | use function is_null; |
28 | 23 | use function json_decode; |
29 | 24 |
|
30 | 25 | /** |
31 | 26 | * @todo Unify the exception handling to avoid duplicated code and logic (ie: getPrefixPricing()) |
32 | 27 | */ |
33 | | -class Client implements ClientAwareInterface, APIClient |
| 28 | +class Client implements APIClient |
34 | 29 | { |
35 | | - /** |
36 | | - * @deprecated This object will be dropping support for ClientAwareInterface in the future |
37 | | - */ |
38 | | - use ClientAwareTrait; |
39 | | - |
40 | | - /** |
41 | | - * @var APIResource|null |
42 | | - */ |
43 | | - protected ?APIResource $accountAPI; |
44 | | - |
45 | | - public function __construct(?APIResource $accountAPI = null) |
| 30 | + public function __construct(protected ?APIResource $accountAPI = null) |
46 | 31 | { |
47 | | - $this->accountAPI = $accountAPI; |
48 | 32 | } |
49 | 33 |
|
50 | 34 | public function getAPIResource(): APIResource |
51 | 35 | { |
52 | | - return $this->accountAPI; |
| 36 | + return clone $this->accountAPI; |
53 | 37 | } |
54 | 38 |
|
55 | 39 | /** |
@@ -128,13 +112,13 @@ protected function makePricingRequest($country, $pricingType): array |
128 | 112 | $api = $this->getAPIResource(); |
129 | 113 | $api->setBaseUri('/account/get-pricing/outbound/' . $pricingType); |
130 | 114 | $results = $api->search(new KeyValueFilter(['country' => $country])); |
131 | | - $data = $results->getPageData(); |
| 115 | + $pageData = $results->getPageData(); |
132 | 116 |
|
133 | | - if (is_null($data)) { |
| 117 | + if (is_null($pageData)) { |
134 | 118 | throw new ClientException\Server('No results found'); |
135 | 119 | } |
136 | 120 |
|
137 | | - return $data; |
| 121 | + return $pageData; |
138 | 122 | } |
139 | 123 |
|
140 | 124 | /** |
@@ -164,7 +148,6 @@ public function getBalance(): Balance |
164 | 148 | public function topUp($trx): void |
165 | 149 | { |
166 | 150 | $api = $this->getAPIResource(); |
167 | | - // @TODO why is this re-setting the base URL |
168 | 151 | $api->setBaseUri('/account/top-up'); |
169 | 152 | $api->submit(['trx' => $trx]); |
170 | 153 | } |
|
0 commit comments