diff --git a/README.md b/README.md index 776cd170..0db03743 100644 --- a/README.md +++ b/README.md @@ -921,7 +921,7 @@ $filter ->setPattern(234) ->setSearchPattern(\Vonage\Numbers\Filter\OwnedNumbers::SEARCH_PATTERN_CONTAINS) ; -$response = $client->numbers()->searchOwned($filter); +$response = $client->numbers()->searchOwned(null, $filter); ``` `has_application`: diff --git a/src/Numbers/Filter/OwnedNumbers.php b/src/Numbers/Filter/OwnedNumbers.php index 433344f0..132493c2 100644 --- a/src/Numbers/Filter/OwnedNumbers.php +++ b/src/Numbers/Filter/OwnedNumbers.php @@ -38,7 +38,7 @@ class OwnedNumbers implements FilterInterface protected int $pageIndex = 1; - protected string $pattern; + protected ?string $pattern = null; protected int $searchPattern = 0; diff --git a/test/Numbers/ClientTest.php b/test/Numbers/ClientTest.php index 83fc36fd..a0d202af 100644 --- a/test/Numbers/ClientTest.php +++ b/test/Numbers/ClientTest.php @@ -361,6 +361,27 @@ public function testPurchaseNumberWithNumberObject(): void // If there's no exception thrown, everything is fine! } + public function testSearchOwnedNumbersWithFilter(): void + { + $this->vonageClient->send(Argument::that(function (RequestInterface $request) { + $uri = $request->getUri(); + $uriString = $uri->__toString(); + $this->assertEquals( + 'https://rest.nexmo.com/account/numbers?size=10&index=1&application_id=66c04cea-68b2-45e4-9061-3fd847d627b8&page_index=1', + $uriString + ); + + $this->assertEquals('GET', $request->getMethod()); + + return true; + }))->willReturn($this->getResponse('owned-numbers')); + + $filter = new \Vonage\Numbers\Filter\OwnedNumbers(); + $filter->setApplicationId("66c04cea-68b2-45e4-9061-3fd847d627b8"); + + $response = $this->numberClient->searchOwned(null, $filter); + } + public function testPurchaseNumberWithNumberAndCountry(): void { // When providing a number string, the first thing that happens is a GET request to fetch number details diff --git a/test/Numbers/responses/owned-numbers.json b/test/Numbers/responses/owned-numbers.json new file mode 100644 index 00000000..bed20c82 --- /dev/null +++ b/test/Numbers/responses/owned-numbers.json @@ -0,0 +1,16 @@ +{ + "count": 1234, + "numbers": [ + { + "country": "GB", + "msisdn": "447700900000", + "type": "mobile-lvn", + "cost": "1.25", + "features": [ + "VOICE", + "SMS", + "MMS" + ] + } + ] +} \ No newline at end of file