Skip to content

Commit

Permalink
Allow toll-free numbers to be searched for
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmantank committed Apr 22, 2021
1 parent 5034d5e commit a839b5c
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2.9.0

### Changed

* Nexmo/nexmo-laravel#62 - Landline Toll Free numbers can be searched for

# 2.8.1

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Client implements LoggerAwareInterface
{
use LoggerTrait;

public const VERSION = '2.8.1';
public const VERSION = '2.9.0';
public const BASE_API = 'https://api.nexmo.com';
public const BASE_REST = 'https://rest.nexmo.com';

Expand Down
8 changes: 7 additions & 1 deletion src/Numbers/Filter/AvailableNumbers.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,13 @@ public function setType(string $type): self
return $this;
}

if ($type !== Number::TYPE_FIXED && $type !== Number::TYPE_MOBILE) {
$valid = [
Number::TYPE_FIXED,
Number::TYPE_MOBILE,
Number::TYPE_TOLLFREE,
];

if (!in_array($type, $valid)) {
throw new InvalidArgumentException('Invalid type of number');
}

Expand Down
1 change: 1 addition & 0 deletions src/Numbers/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Number implements EntityInterface, JsonSerializableInterface, JsonUnserial

public const TYPE_MOBILE = 'mobile-lvn';
public const TYPE_FIXED = 'landline';
public const TYPE_TOLLFREE = 'landline-toll-free';

public const FEATURE_VOICE = 'VOICE';
public const FEATURE_SMS = 'SMS';
Expand Down
45 changes: 45 additions & 0 deletions test/Numbers/Filter/AvailableNumbersTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace VonageTest\Numbers\Filter;

use InvalidArgumentException;
use Vonage\Numbers\Number;
use PHPUnit\Framework\TestCase;
use Vonage\Numbers\Filter\AvailableNumbers;

class AvailableNumbersTest extends TestCase
{
/**
* @dataProvider numberTypes
*/
public function testCanSetValidNumberType(string $type): void
{
$filter = new AvailableNumbers();
$filter->setType($type);

$this->assertSame($type, $filter->getType());
}

/**
* List of valid number types that can be searched on
*
* @return array<array<string>>
*/
public function numberTypes(): array
{
return [
[Number::TYPE_FIXED],
[Number::TYPE_MOBILE],
[Number::TYPE_TOLLFREE]
];
}

public function testInvalidTypeThrowsException()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid type of number');

$filter = new AvailableNumbers();
$filter->setType('foo-bar');
}
}

0 comments on commit a839b5c

Please sign in to comment.