Skip to content

Commit a839b5c

Browse files
committed
Allow toll-free numbers to be searched for
1 parent 5034d5e commit a839b5c

File tree

5 files changed

+60
-2
lines changed

5 files changed

+60
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 2.9.0
2+
3+
### Changed
4+
5+
* Nexmo/nexmo-laravel#62 - Landline Toll Free numbers can be searched for
6+
17
# 2.8.1
28

39
### Fixed

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class Client implements LoggerAwareInterface
105105
{
106106
use LoggerTrait;
107107

108-
public const VERSION = '2.8.1';
108+
public const VERSION = '2.9.0';
109109
public const BASE_API = 'https://api.nexmo.com';
110110
public const BASE_REST = 'https://rest.nexmo.com';
111111

src/Numbers/Filter/AvailableNumbers.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,13 @@ public function setType(string $type): self
215215
return $this;
216216
}
217217

218-
if ($type !== Number::TYPE_FIXED && $type !== Number::TYPE_MOBILE) {
218+
$valid = [
219+
Number::TYPE_FIXED,
220+
Number::TYPE_MOBILE,
221+
Number::TYPE_TOLLFREE,
222+
];
223+
224+
if (!in_array($type, $valid)) {
219225
throw new InvalidArgumentException('Invalid type of number');
220226
}
221227

src/Numbers/Number.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Number implements EntityInterface, JsonSerializableInterface, JsonUnserial
4040

4141
public const TYPE_MOBILE = 'mobile-lvn';
4242
public const TYPE_FIXED = 'landline';
43+
public const TYPE_TOLLFREE = 'landline-toll-free';
4344

4445
public const FEATURE_VOICE = 'VOICE';
4546
public const FEATURE_SMS = 'SMS';
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace VonageTest\Numbers\Filter;
4+
5+
use InvalidArgumentException;
6+
use Vonage\Numbers\Number;
7+
use PHPUnit\Framework\TestCase;
8+
use Vonage\Numbers\Filter\AvailableNumbers;
9+
10+
class AvailableNumbersTest extends TestCase
11+
{
12+
/**
13+
* @dataProvider numberTypes
14+
*/
15+
public function testCanSetValidNumberType(string $type): void
16+
{
17+
$filter = new AvailableNumbers();
18+
$filter->setType($type);
19+
20+
$this->assertSame($type, $filter->getType());
21+
}
22+
23+
/**
24+
* List of valid number types that can be searched on
25+
*
26+
* @return array<array<string>>
27+
*/
28+
public function numberTypes(): array
29+
{
30+
return [
31+
[Number::TYPE_FIXED],
32+
[Number::TYPE_MOBILE],
33+
[Number::TYPE_TOLLFREE]
34+
];
35+
}
36+
37+
public function testInvalidTypeThrowsException()
38+
{
39+
$this->expectException(InvalidArgumentException::class);
40+
$this->expectExceptionMessage('Invalid type of number');
41+
42+
$filter = new AvailableNumbers();
43+
$filter->setType('foo-bar');
44+
}
45+
}

0 commit comments

Comments
 (0)