diff --git a/src/Service/Account/Numbers.php b/src/Service/Account/Numbers.php index 8a86bc9..93acfe1 100644 --- a/src/Service/Account/Numbers.php +++ b/src/Service/Account/Numbers.php @@ -51,6 +51,10 @@ protected function validateResponse(array $json) if (!isset($json['count'])) { throw new Exception('count property expected'); } + if (0 == $json['count']) { + // If there are no numbers on the account, stop validating. + return; + } if (!isset($json['numbers']) || !is_array($json['numbers'])) { throw new Exception('numbers array property expected'); } @@ -67,9 +71,6 @@ protected function validateResponse(array $json) if (!isset($number['features']) || !is_array($number['features'])) { throw new Exception('number.features array property expected'); } - if (!isset($number['moHttpUrl'])) { - throw new Exception('number.moHttpUrl property expected'); - } } } } diff --git a/src/Service/Account/Pricing/Country.php b/src/Service/Account/Pricing/Country.php index d88ebb1..1fa60df 100644 --- a/src/Service/Account/Pricing/Country.php +++ b/src/Service/Account/Pricing/Country.php @@ -34,7 +34,8 @@ public function invoke($country = null) } return new Entity\Pricing($this->exec([ - 'country' => $country, + // Nexmo API requires $country value to be uppercase. + 'country' => strtoupper($country), ])); } @@ -43,6 +44,10 @@ public function invoke($country = null) */ protected function validateResponse(array $json) { + if (!isset($json['mt'])) { + // Some countries don't have any values, e.g., BV. + return; + } if (!isset($json['country'])) { throw new Exception('country property expected'); }