1414use Psr \Http \Client \ClientExceptionInterface ;
1515use Vonage \Client \APIClient ;
1616use Vonage \Client \APIResource ;
17- use Vonage \Client \ClientAwareInterface ;
18- use Vonage \Client \ClientAwareTrait ;
1917use Vonage \Client \Exception as ClientException ;
18+ use Vonage \Client \Exception \Exception ;
19+ use Vonage \Client \Exception \Request ;
20+ use Vonage \Client \Exception \Server ;
2021use Vonage \Entity \Filter \KeyValueFilter ;
22+ use Vonage \Entity \IterableAPICollection ;
2123use Vonage \Numbers \Number ;
2224
23- use function is_null ;
24-
2525/**
2626 * Class Client
2727 */
2828class Client implements APIClient
2929{
30+ protected array $ chargeableCodes = [0 , 43 , 44 , 45 ];
31+
3032 public function __construct (protected ?APIResource $ api = null )
3133 {
3234 }
@@ -39,10 +41,11 @@ public function getApiResource(): APIResource
3941 /**
4042 * @param $number
4143 *
44+ * @return Basic
4245 * @throws ClientExceptionInterface
43- * @throws ClientException\ Exception
44- * @throws ClientException\ Request
45- * @throws ClientException\ Server
46+ * @throws Exception
47+ * @throws Request
48+ * @throws Server
4649 */
4750 public function basic ($ number ): Basic
4851 {
@@ -56,10 +59,11 @@ public function basic($number): Basic
5659 /**
5760 * @param $number
5861 *
62+ * @return StandardCnam
5963 * @throws ClientExceptionInterface
60- * @throws ClientException\ Exception
61- * @throws ClientException\ Request
62- * @throws ClientException\ Server
64+ * @throws Exception
65+ * @throws Request
66+ * @throws Server
6367 */
6468 public function standardCNam ($ number ): StandardCnam
6569 {
@@ -72,10 +76,11 @@ public function standardCNam($number): StandardCnam
7276 /**
7377 * @param $number
7478 *
79+ * @return AdvancedCnam
7580 * @throws ClientExceptionInterface
76- * @throws ClientException\ Exception
77- * @throws ClientException\ Request
78- * @throws ClientException\ Server
81+ * @throws Exception
82+ * @throws Request
83+ * @throws Server
7984 */
8085 public function advancedCnam ($ number ): AdvancedCnam
8186 {
@@ -146,6 +151,9 @@ public function makeRequest(string $path, $number, array $additionalParams = [])
146151 {
147152 $ api = $ this ->getApiResource ();
148153 $ api ->setBaseUri ($ path );
154+ $ collectionPrototype = new IterableAPICollection ();
155+ $ collectionPrototype ->setHasPagination (false );
156+ $ api ->setCollectionPrototype ($ collectionPrototype );
149157
150158 if ($ number instanceof Number) {
151159 $ number = $ number ->getMsisdn ();
@@ -156,7 +164,7 @@ public function makeRequest(string $path, $number, array $additionalParams = [])
156164 $ data = $ result ->getPageData ();
157165
158166 // check the status field in response (HTTP status is 200 even for errors)
159- if (( int )$ data ['status ' ] !== 0 ) {
167+ if (! in_array (( int )$ data ['status ' ], $ this -> chargeableCodes , true ) ) {
160168 throw $ this ->getNIException ($ data );
161169 }
162170
0 commit comments