-
Notifications
You must be signed in to change notification settings - Fork 94
Add client implementation for Numbers API, support 7.0 #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
286dd32
Broaden support for php back to 7.0, downgrade phpunit
paolobueno dd06d0c
Add Number object
paolobueno b829358
Added Resources for Available and (Purchased) phone numbers.
bb5fbdb
Add PhoneNumbers initial Resources/Base-based implementation
paolobueno fd6cae5
Add PhoneNumbersTest for purchased phone numbers
paolobueno 69557c6
Make new examples use env var
paolobueno 5541dc4
Add tests for AvailablePhoneNumbers
paolobueno 6013353
Remove alignment to avoid threshing on resource additions
paolobueno 0e8f398
Add return type information
paolobueno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
vendor/ | ||
composer.lock | ||
composer*.lock | ||
composer.phar | ||
.DS_Store | ||
.idea/ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
language: php | ||
dist: xenial | ||
php: | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
- 7.4 | ||
|
||
before_script: | ||
- if [[ ${TRAVIS_PHP_VERSION} == 7.0 ]]; then export COMPOSER=composer-7-0.json; fi | ||
- composer install | ||
|
||
script: phpunit --verbose | ||
script: php ./vendor/bin/phpunit --verbose |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "messagebird/php-rest-api", | ||
"description": "MessageBird REST API client for PHP", | ||
"type": "library", | ||
"homepage": "https://github.com/messagebird/php-rest-api", | ||
"license": "BSD-2-Clause", | ||
"authors": [ | ||
{ | ||
"name": "MessageBird", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.0", | ||
"ext-curl": "*" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^6" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"MessageBird\\": "src/MessageBird/" | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); | ||
|
||
try { | ||
$phoneNumbers = $MessageBird->availablePhoneNumbers->getList("nl", array()); | ||
var_dump($phoneNumbers); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
var_dump($e->getMessage()); | ||
// That means that your accessKey is unknown | ||
print("wrong login\n"); | ||
|
||
} catch (\Exception $e) { | ||
var_dump($e->getMessage()); | ||
|
||
} | ||
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); // Set your own API access key here. | ||
$NumberPurchaseRequest = new \MessageBird\Objects\NumberPurchaseRequest(); | ||
$NumberPurchaseRequest->number = '31612345678'; | ||
$NumberPurchaseRequest->countryCode = 'NL'; | ||
$NumberPurchaseRequest->billingIntervalMonths = 1; | ||
|
||
try { | ||
$NumberPurchaseRequestResult = $MessageBird->phoneNumbers->create($NumberPurchaseRequest); | ||
var_dump($NumberPurchaseRequestResult); | ||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
print("wrong login\n"); | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); // Set your own API access key here. | ||
|
||
try { | ||
$deleted = $MessageBird->phoneNumbers->delete('31612345678'); | ||
var_dump('Deleted: ' . $deleted); | ||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
print("wrong login\n"); | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); // Set your own API access key here. | ||
$Number = new \MessageBird\Objects\Number(); | ||
$Number->tags = array('tag1'); | ||
|
||
try { | ||
$NumberResult = $MessageBird->phoneNumbers->update($Number, '31612345678'); | ||
var_dump($NumberResult); | ||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
print("wrong login\n"); | ||
|
||
} catch (\Exception $e) { | ||
echo $e->getMessage(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
require_once(__DIR__ . '/../autoload.php'); | ||
|
||
$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); // Set your own API access key here. | ||
|
||
try { | ||
$phoneNumbers = $MessageBird->phoneNumbers->getList(); | ||
var_dump($phoneNumbers); | ||
|
||
} catch (\MessageBird\Exceptions\AuthenticateException $e) { | ||
// That means that your accessKey is unknown | ||
print("wrong login\n"); | ||
|
||
} catch (\Exception $e) { | ||
var_dump($e->getMessage()); | ||
|
||
} | ||
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
|
||
namespace MessageBird\Objects; | ||
|
||
/** | ||
* Class Number | ||
* | ||
* Represents a specific phone number | ||
* | ||
* @package MessageBird\Objects | ||
*/ | ||
class Number extends Base | ||
{ | ||
/** | ||
* The phone number in E.164 format without the prefixed plus-sign. | ||
* @var string | ||
*/ | ||
public $number; | ||
|
||
/** | ||
* The Number's country | ||
* @var string | ||
*/ | ||
public $country; | ||
|
||
/** | ||
* The country code for this number in ISO 3166-1 alpha-2 format. | ||
* @var string | ||
*/ | ||
public $region; | ||
|
||
/** | ||
* Finer-grained locality for this Number | ||
* @var string | ||
*/ | ||
public $locality; | ||
|
||
/** | ||
* The available features for this Number | ||
* @var array | ||
*/ | ||
public $features; | ||
|
||
/** | ||
* Additional user-provided tags for this Number | ||
* @var array | ||
*/ | ||
public $tags = []; | ||
|
||
/** | ||
* Number type (example: landline, mobile). | ||
* @var string | ||
*/ | ||
public $type; | ||
|
||
/** | ||
* Number availability and current activated status | ||
* @var string | ||
*/ | ||
public $status; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
|
||
namespace MessageBird\Objects; | ||
|
||
/** | ||
* Class NumberPurchaseRequest | ||
* | ||
* Represents a specific phone number | ||
* | ||
* @package MessageBird\Objects | ||
*/ | ||
class NumberPurchaseRequest extends Base | ||
{ | ||
/** | ||
* The phone number in E.164 format without the prefixed plus-sign. | ||
* @var string | ||
*/ | ||
public $number; | ||
|
||
/** | ||
* The country code for this number in ISO 3166-1 alpha-2 format. | ||
* | ||
* @var string | ||
*/ | ||
public $countryCode; | ||
|
||
/** | ||
* The interval in months that this number will be billed by | ||
*/ | ||
public $billingIntervalMonths; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.