From 286dd32446a1255611ea17b10f3b91caed925b98 Mon Sep 17 00:00:00 2001 From: Paolo Bueno Date: Fri, 10 Jan 2020 13:01:51 +0100 Subject: [PATCH 1/9] Broaden support for php back to 7.0, downgrade phpunit --- .gitignore | 2 +- .travis.yml | 6 +++++- README.md | 2 +- composer-7-0.json | 25 +++++++++++++++++++++++++ composer.json | 4 ++-- test-bash.sh | 5 +++++ 6 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 composer-7-0.json create mode 100755 test-bash.sh diff --git a/.gitignore b/.gitignore index c3d69fbb..b8cad2b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ vendor/ -composer.lock +composer*.lock composer.phar .DS_Store .idea/ diff --git a/.travis.yml b/.travis.yml index de597358..938b50c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/README.md b/README.md index 57fbf0f4..770df09c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Requirements - [Sign up](https://www.messagebird.com/en/signup) for a free MessageBird account - Create a new access_key in the developers sections -- MessageBird API client for PHP requires PHP >= 5.4. +- MessageBird API client for PHP requires PHP >= 7.0. Installation ----- diff --git a/composer-7-0.json b/composer-7-0.json new file mode 100644 index 00000000..c5883c74 --- /dev/null +++ b/composer-7-0.json @@ -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": "info@messagebird.com" + } + ], + "require": { + "php": ">=7.0", + "ext-curl": "*" + }, + "require-dev": { + "phpunit/phpunit": "^6" + }, + "autoload": { + "psr-4": { + "MessageBird\\": "src/MessageBird/" + } + } +} diff --git a/composer.json b/composer.json index 40a17863..399ce791 100644 --- a/composer.json +++ b/composer.json @@ -11,11 +11,11 @@ } ], "require": { - "php": ">=7.2.0", + "php": ">=7.0", "ext-curl": "*" }, "require-dev": { - "phpunit/phpunit": "^8" + "phpunit/phpunit": "^7.5" }, "autoload": { "psr-4": { diff --git a/test-bash.sh b/test-bash.sh new file mode 100755 index 00000000..cf95c944 --- /dev/null +++ b/test-bash.sh @@ -0,0 +1,5 @@ +#!/bin/bash +TRAVIS_PHP_VERSION=7.5 +V=`echo -e "$TRAVIS_PHP_VERSION\n7.0" | sort -Vr | head -n1` +echo $V +if [ `echo -e "$TRAVIS_PHP_VERSION\n7.0" | sort -Vr | head -n1` == 7.0 ]; then echo "yo"; fi From dd06d0cb73fcbe5498e0e0211a10fa1e01e2755b Mon Sep 17 00:00:00 2001 From: Paolo Bueno Date: Mon, 6 Jan 2020 17:43:36 +0100 Subject: [PATCH 2/9] Add Number object --- src/MessageBird/Objects/Number.php | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/MessageBird/Objects/Number.php diff --git a/src/MessageBird/Objects/Number.php b/src/MessageBird/Objects/Number.php new file mode 100644 index 00000000..eee7de71 --- /dev/null +++ b/src/MessageBird/Objects/Number.php @@ -0,0 +1,62 @@ + Date: Tue, 7 Jan 2020 10:20:35 +0100 Subject: [PATCH 3/9] Added Resources for Available and (Purchased) phone numbers. --- examples/available-phone-numbers-view.php | 20 +++++ examples/phone-numbers-view.php | 19 ++++ src/MessageBird/Client.php | 68 +++++++++----- .../Resources/AvailablePhoneNumbers.php | 89 +++++++++++++++++++ src/MessageBird/Resources/PhoneNumbers.php | 89 +++++++++++++++++++ 5 files changed, 261 insertions(+), 24 deletions(-) create mode 100644 examples/available-phone-numbers-view.php create mode 100644 examples/phone-numbers-view.php create mode 100644 src/MessageBird/Resources/AvailablePhoneNumbers.php create mode 100644 src/MessageBird/Resources/PhoneNumbers.php diff --git a/examples/available-phone-numbers-view.php b/examples/available-phone-numbers-view.php new file mode 100644 index 00000000..803ebc04 --- /dev/null +++ b/examples/available-phone-numbers-view.php @@ -0,0 +1,20 @@ +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()); + +} +?> diff --git a/examples/phone-numbers-view.php b/examples/phone-numbers-view.php new file mode 100644 index 00000000..cff33c19 --- /dev/null +++ b/examples/phone-numbers-view.php @@ -0,0 +1,19 @@ +phoneNumbers->getList("nl", array()); + 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()); + +} +?> diff --git a/src/MessageBird/Client.php b/src/MessageBird/Client.php index ff6287e8..cb4fdc43 100644 --- a/src/MessageBird/Client.php +++ b/src/MessageBird/Client.php @@ -14,6 +14,7 @@ class Client const CONVERSATIONSAPI_ENDPOINT = 'https://conversations.messagebird.com/v1'; const VOICEAPI_ENDPOINT = 'https://voice.messagebird.com'; const PARTNER_ACCOUNT_ENDPOINT = 'https://partner-accounts.messagebird.com'; + const NUMBERSAPI_ENDPOINT = 'https://numbers.messagebird.com/v1'; const ENABLE_CONVERSATIONSAPI_WHATSAPP_SANDBOX = 'ENABLE_CONVERSATIONSAPI_WHATSAPP_SANDBOX'; const CONVERSATIONSAPI_WHATSAPP_SANDBOX_ENDPOINT = 'https://whatsapp-sandbox.messagebird.com/v1'; @@ -120,6 +121,16 @@ class Client */ public $voiceTranscriptions; + /** + * @var Resources\PhoneNumbers + */ + public $phoneNumbers; + + /** + * @var Resources\AvailablePhoneNumbers + */ + public $availablePhoneNumbers; + /** * @var Resources\Voice\Webhooks */ @@ -170,6 +181,7 @@ class Client */ protected $partnerAccountClient; + /** * @param string $accessKey * @param Common\HttpClient $httpClient @@ -184,12 +196,14 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n 'X-MessageBird-Version' => '20170314', )); $this->partnerAccountClient = new Common\HttpClient(self::PARTNER_ACCOUNT_ENDPOINT); + $this->numbersAPIClient = new Common\HttpClient(self::NUMBERSAPI_ENDPOINT); } else { $this->ChatAPIHttpClient = $httpClient; $this->ConversationsAPIHttpClient = $httpClient; $this->HttpClient = $httpClient; $this->VoiceAPIHttpClient = $httpClient; $this->partnerAccountClient = $httpClient; + $this->numbersAPIClient = $httpClient; } $this->HttpClient->addUserAgentString('MessageBird/ApiClient/' . self::CLIENT_VERSION); @@ -207,34 +221,39 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n $this->partnerAccountClient->addUserAgentString('MessageBird/ApiClient/' . self::CLIENT_VERSION); $this->partnerAccountClient->addUserAgentString($this->getPhpVersion()); + $this->numbersAPIClient->addUserAgentString('MessageBird/ApiClient/' . self::CLIENT_VERSION); + $this->numbersAPIClient->addUserAgentString($this->getPhpVersion()); + if ($accessKey !== null) { $this->setAccessKey($accessKey); } - $this->messages = new Resources\Messages($this->HttpClient); - $this->hlr = new Resources\Hlr($this->HttpClient); - $this->verify = new Resources\Verify($this->HttpClient); - $this->balance = new Resources\Balance($this->HttpClient); - $this->voicemessages = new Resources\VoiceMessage($this->HttpClient); - $this->lookup = new Resources\Lookup($this->HttpClient); - $this->lookupHlr = new Resources\LookupHlr($this->HttpClient); - $this->chatMessages = new Resources\Chat\Message($this->ChatAPIHttpClient); - $this->chatChannels = new Resources\Chat\Channel($this->ChatAPIHttpClient); - $this->chatPlatforms = new Resources\Chat\Platform($this->ChatAPIHttpClient); - $this->chatContacts = new Resources\Chat\Contact($this->ChatAPIHttpClient); - $this->voiceCallFlows = new Resources\Voice\CallFlows($this->VoiceAPIHttpClient); - $this->voiceCalls = new Resources\Voice\Calls($this->VoiceAPIHttpClient); - $this->voiceLegs = new Resources\Voice\Legs($this->VoiceAPIHttpClient); - $this->voiceRecordings = new Resources\Voice\Recordings($this->VoiceAPIHttpClient); - $this->voiceTranscriptions = new Resources\Voice\Transcriptions($this->VoiceAPIHttpClient); - $this->voiceWebhooks = new Resources\Voice\Webhooks($this->VoiceAPIHttpClient); - $this->mmsMessages = new Resources\MmsMessages($this->HttpClient); - $this->contacts = new Resources\Contacts($this->HttpClient); - $this->groups = new Resources\Groups($this->HttpClient); - $this->conversations = new Resources\Conversation\Conversations($this->ConversationsAPIHttpClient); - $this->conversationMessages = new Resources\Conversation\Messages($this->ConversationsAPIHttpClient); - $this->conversationWebhooks = new Resources\Conversation\Webhooks($this->ConversationsAPIHttpClient); - $this->partnerAccounts = new Resources\PartnerAccount\Accounts($this->partnerAccountClient); + $this->messages = new Resources\Messages($this->HttpClient); + $this->hlr = new Resources\Hlr($this->HttpClient); + $this->verify = new Resources\Verify($this->HttpClient); + $this->balance = new Resources\Balance($this->HttpClient); + $this->voicemessages = new Resources\VoiceMessage($this->HttpClient); + $this->lookup = new Resources\Lookup($this->HttpClient); + $this->lookupHlr = new Resources\LookupHlr($this->HttpClient); + $this->chatMessages = new Resources\Chat\Message($this->ChatAPIHttpClient); + $this->chatChannels = new Resources\Chat\Channel($this->ChatAPIHttpClient); + $this->chatPlatforms = new Resources\Chat\Platform($this->ChatAPIHttpClient); + $this->chatContacts = new Resources\Chat\Contact($this->ChatAPIHttpClient); + $this->voiceCallFlows = new Resources\Voice\CallFlows($this->VoiceAPIHttpClient); + $this->voiceCalls = new Resources\Voice\Calls($this->VoiceAPIHttpClient); + $this->voiceLegs = new Resources\Voice\Legs($this->VoiceAPIHttpClient); + $this->voiceRecordings = new Resources\Voice\Recordings($this->VoiceAPIHttpClient); + $this->voiceTranscriptions = new Resources\Voice\Transcriptions($this->VoiceAPIHttpClient); + $this->voiceWebhooks = new Resources\Voice\Webhooks($this->VoiceAPIHttpClient); + $this->mmsMessages = new Resources\MmsMessages($this->HttpClient); + $this->contacts = new Resources\Contacts($this->HttpClient); + $this->groups = new Resources\Groups($this->HttpClient); + $this->conversations = new Resources\Conversation\Conversations($this->ConversationsAPIHttpClient); + $this->conversationMessages = new Resources\Conversation\Messages($this->ConversationsAPIHttpClient); + $this->conversationWebhooks = new Resources\Conversation\Webhooks($this->ConversationsAPIHttpClient); + $this->partnerAccounts = new Resources\PartnerAccount\Accounts($this->partnerAccountClient); + $this->phoneNumbers = new Resources\PhoneNumbers($this->numbersAPIClient); + $this->availablePhoneNumbers = new Resources\AvailablePhoneNumbers($this->numbersAPIClient); } /** @@ -249,6 +268,7 @@ public function setAccessKey ($accessKey) $this->HttpClient->setAuthentication($Authentication); $this->VoiceAPIHttpClient->setAuthentication($Authentication); $this->partnerAccountClient->setAuthentication($Authentication); + $this->numbersAPIClient->setAuthentication($Authentication); } /** diff --git a/src/MessageBird/Resources/AvailablePhoneNumbers.php b/src/MessageBird/Resources/AvailablePhoneNumbers.php new file mode 100644 index 00000000..bde7556e --- /dev/null +++ b/src/MessageBird/Resources/AvailablePhoneNumbers.php @@ -0,0 +1,89 @@ +HttpClient = $HttpClient; + } + + /** + * @param string $countryCode + * @param array $parameters + * + * @return Objects\BaseList + * @throws \MessageBird\Exceptions\RequestException + * @throws \MessageBird\Exceptions\ServerException + */ + public function getList($countryCode, $parameters = array()) + { + list($status, , $body) = $this->HttpClient->performHttpRequest( + Common\HttpClient::REQUEST_GET, + "available-phone-numbers/$countryCode", + $parameters + ); + + if ($status === 200) { + $body = json_decode($body); + + $items = $body->data; + unset($body->data); + + $baseList = new Objects\BaseList(); + $baseList->loadFromArray($body); + + foreach ($items as $item) { + $object = new Objects\Number($this->HttpClient); + + $itemObject = $object->loadFromArray($item); + $baseList->items[] = $itemObject; + } + return $baseList; + } + + return $this->processRequest($body); + } + + /** + * @param string $body + * + * @return Objects\Number + * @throws \MessageBird\Exceptions\RequestException + * @throws \MessageBird\Exceptions\ServerException + */ + private function processRequest($body) + { + $body = @json_decode($body); + + if ($body === null or $body === false) { + throw new Exceptions\ServerException('Got an invalid JSON response from the server.'); + } + + if (empty($body->errors)) { + return Objects\Number.loadFromArray($body->data[0]); + } + + $ResponseError = new Common\ResponseError($body); + throw new Exceptions\RequestException($ResponseError->getErrorString()); + } +} +?> diff --git a/src/MessageBird/Resources/PhoneNumbers.php b/src/MessageBird/Resources/PhoneNumbers.php new file mode 100644 index 00000000..edb83459 --- /dev/null +++ b/src/MessageBird/Resources/PhoneNumbers.php @@ -0,0 +1,89 @@ +HttpClient = $HttpClient; + } + + /** + * @param string $countryCode + * @param array $parameters + * + * @return Objects\BaseList + * @throws \MessageBird\Exceptions\RequestException + * @throws \MessageBird\Exceptions\ServerException + */ + public function getList($countryCode, $parameters = array()) + { + list($status, , $body) = $this->HttpClient->performHttpRequest( + Common\HttpClient::REQUEST_GET, + "phone-numbers/$countryCode", + $parameters + ); + + if ($status === 200) { + $body = json_decode($body); + + $items = $body->data; + unset($body->data); + + $baseList = new Objects\BaseList(); + $baseList->loadFromArray($body); + + foreach ($items as $item) { + $object = new Objects\Number($this->HttpClient); + + $itemObject = $object->loadFromArray($item); + $baseList->items[] = $itemObject; + } + return $baseList; + } + + return $this->processRequest($body); + } + + /** + * @param string $body + * + * @return Objects\Number + * @throws \MessageBird\Exceptions\RequestException + * @throws \MessageBird\Exceptions\ServerException + */ + private function processRequest($body) + { + $body = @json_decode($body); + + if ($body === null or $body === false) { + throw new Exceptions\ServerException('Got an invalid JSON response from the server.'); + } + + if (empty($body->errors)) { + return Objects\Number.loadFromArray($body->data[0]); + } + + $ResponseError = new Common\ResponseError($body); + throw new Exceptions\RequestException($ResponseError->getErrorString()); + } +} +?> From bb5fbdb96a994b5040d67a038384e31e3af48c3b Mon Sep 17 00:00:00 2001 From: Paolo Bueno Date: Tue, 7 Jan 2020 14:59:50 +0100 Subject: [PATCH 4/9] Add PhoneNumbers initial Resources/Base-based implementation --- examples/available-phone-numbers-view.php | 2 +- examples/balance-view.php | 2 +- examples/phone-numbers-create.php | 20 ++++++ examples/phone-numbers-delete.php | 16 +++++ examples/phone-numbers-update.php | 18 +++++ examples/phone-numbers-view.php | 4 +- src/MessageBird/Client.php | 6 +- src/MessageBird/Objects/Number.php | 16 ++--- .../Objects/NumberPurchaseRequest.php | 31 +++++++++ src/MessageBird/Resources/PhoneNumbers.php | 69 +++++-------------- .../integration/numbers/PhoneNumbersTest.php | 32 +++++++++ 11 files changed, 152 insertions(+), 64 deletions(-) create mode 100644 examples/phone-numbers-create.php create mode 100644 examples/phone-numbers-delete.php create mode 100644 examples/phone-numbers-update.php create mode 100644 src/MessageBird/Objects/NumberPurchaseRequest.php create mode 100644 tests/integration/numbers/PhoneNumbersTest.php diff --git a/examples/available-phone-numbers-view.php b/examples/available-phone-numbers-view.php index 803ebc04..52562ed8 100644 --- a/examples/available-phone-numbers-view.php +++ b/examples/available-phone-numbers-view.php @@ -2,7 +2,7 @@ require_once(__DIR__ . '/../autoload.php'); -$MessageBird = new \MessageBird\Client(getenv("MESSAGEBIRD_API")); // Set your own API access key here. +$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); // Set your own API access key here. try { $phoneNumbers = $MessageBird->availablePhoneNumbers->getList("nl", array()); diff --git a/examples/balance-view.php b/examples/balance-view.php index 83c7685b..d69d9e95 100644 --- a/examples/balance-view.php +++ b/examples/balance-view.php @@ -2,7 +2,7 @@ require_once(__DIR__ . '/../autoload.php'); -$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); // Set your own API access key here. +$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); try { $Balance = $MessageBird->balance->read(); diff --git a/examples/phone-numbers-create.php b/examples/phone-numbers-create.php new file mode 100644 index 00000000..179b54d0 --- /dev/null +++ b/examples/phone-numbers-create.php @@ -0,0 +1,20 @@ +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(); +} diff --git a/examples/phone-numbers-delete.php b/examples/phone-numbers-delete.php new file mode 100644 index 00000000..b29b2750 --- /dev/null +++ b/examples/phone-numbers-delete.php @@ -0,0 +1,16 @@ +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(); +} diff --git a/examples/phone-numbers-update.php b/examples/phone-numbers-update.php new file mode 100644 index 00000000..3635e828 --- /dev/null +++ b/examples/phone-numbers-update.php @@ -0,0 +1,18 @@ +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(); +} diff --git a/examples/phone-numbers-view.php b/examples/phone-numbers-view.php index cff33c19..187bb771 100644 --- a/examples/phone-numbers-view.php +++ b/examples/phone-numbers-view.php @@ -2,10 +2,10 @@ require_once(__DIR__ . '/../autoload.php'); -$MessageBird = new \MessageBird\Client(getenv("MESSAGEBIRD_API")); // Set your own API access key here. +$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $phoneNumbers = $MessageBird->phoneNumbers->getList("nl", array()); + $phoneNumbers = $MessageBird->phoneNumbers->getList(); var_dump($phoneNumbers); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/src/MessageBird/Client.php b/src/MessageBird/Client.php index cb4fdc43..0ab19ab7 100644 --- a/src/MessageBird/Client.php +++ b/src/MessageBird/Client.php @@ -66,6 +66,11 @@ class Client */ public $lookup; + /** + * @var Resources\AvailableNumbers + */ + public $availableNumbers; + /** * @var Resources\LookupHlr */ @@ -181,7 +186,6 @@ class Client */ protected $partnerAccountClient; - /** * @param string $accessKey * @param Common\HttpClient $httpClient diff --git a/src/MessageBird/Objects/Number.php b/src/MessageBird/Objects/Number.php index eee7de71..b2e560cd 100644 --- a/src/MessageBird/Objects/Number.php +++ b/src/MessageBird/Objects/Number.php @@ -16,47 +16,47 @@ class Number extends Base * The phone number in E.164 format without the prefixed plus-sign. * @var string */ - protected $number; + public $number; /** * The Number's country * @var string */ - protected $country; + public $country; /** * The country code for this number in ISO 3166-1 alpha-2 format. * @var string */ - protected $region; + public $region; /** * Finer-grained locality for this Number * @var string */ - protected $locality; + public $locality; /** * The available features for this Number * @var array */ - protected $features = array(); + public $features = array(); /** * Additional user-provided tags for this Number * @var array */ - protected $tags = array(); + public $tags = array(); /** * Number type (example: landline, mobile). * @var string */ - protected $type; + public $type; /** * Number availability and current activated status * @var string */ - protected $status; + public $status; } diff --git a/src/MessageBird/Objects/NumberPurchaseRequest.php b/src/MessageBird/Objects/NumberPurchaseRequest.php new file mode 100644 index 00000000..e93f091f --- /dev/null +++ b/src/MessageBird/Objects/NumberPurchaseRequest.php @@ -0,0 +1,31 @@ +HttpClient = $HttpClient; + $this->setResourceName('phone-numbers'); } /** - * @param string $countryCode - * @param array $parameters + * @param $object + * @param $id * - * @return Objects\BaseList - * @throws \MessageBird\Exceptions\RequestException - * @throws \MessageBird\Exceptions\ServerException - */ - public function getList($countryCode, $parameters = array()) - { - list($status, , $body) = $this->HttpClient->performHttpRequest( - Common\HttpClient::REQUEST_GET, - "phone-numbers/$countryCode", - $parameters - ); - - if ($status === 200) { - $body = json_decode($body); - - $items = $body->data; - unset($body->data); - - $baseList = new Objects\BaseList(); - $baseList->loadFromArray($body); - - foreach ($items as $item) { - $object = new Objects\Number($this->HttpClient); - - $itemObject = $object->loadFromArray($item); - $baseList->items[] = $itemObject; - } - return $baseList; - } - - return $this->processRequest($body); - } - - /** - * @param string $body + * @return $this ->Object * - * @return Objects\Number - * @throws \MessageBird\Exceptions\RequestException - * @throws \MessageBird\Exceptions\ServerException + * @internal param array $parameters */ - private function processRequest($body) + public function update($object, $id) { - $body = @json_decode($body); - - if ($body === null or $body === false) { - throw new Exceptions\ServerException('Got an invalid JSON response from the server.'); + $objVars = get_object_vars($object); + $body = array(); + foreach ($objVars as $key => $value) { + if (null !== $value) { + $body[$key] = $value; + } } - if (empty($body->errors)) { - return Objects\Number.loadFromArray($body->data[0]); - } + $ResourceName = $this->resourceName . ($id ? '/' . $id : null); + $body = json_encode($body); - $ResponseError = new Common\ResponseError($body); - throw new Exceptions\RequestException($ResponseError->getErrorString()); + // This override is only needed to use the PATCH http method + list(, , $body) = $this->HttpClient->performHttpRequest(Common\HttpClient::REQUEST_PATCH, $ResourceName, false, $body); + return $this->processRequest($body); } } ?> diff --git a/tests/integration/numbers/PhoneNumbersTest.php b/tests/integration/numbers/PhoneNumbersTest.php new file mode 100644 index 00000000..09a7b272 --- /dev/null +++ b/tests/integration/numbers/PhoneNumbersTest.php @@ -0,0 +1,32 @@ +client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); + } + + /** + * @expectedException MessageBird\Exceptions\ServerException + */ + public function testCreateHlr() + { + $Hlr = new \MessageBird\Objects\Hlr(); + $Hlr->msisdn = 'MessageBird'; + $Hlr->reference = "yoloswag3000"; + + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'hlr', null, '{"msisdn":"MessageBird","network":null,"details":[],"reference":"yoloswag3000","status":null}'); + $this->client->hlr->create($Hlr); + } + + + /** + * @expectedException MessageBird\Exceptions\ServerException + */ + public function testReadHlr() + { + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'hlr/message_id', null, null); + $this->client->hlr->read("message_id"); + } +} From fd6cae5d8fa63f7edb26d56e5de29ed3d19a1fcd Mon Sep 17 00:00:00 2001 From: Paolo Bueno Date: Wed, 8 Jan 2020 16:25:06 +0100 Subject: [PATCH 5/9] Add PhoneNumbersTest for purchased phone numbers --- src/MessageBird/Objects/Number.php | 2 +- .../Objects/NumberPurchaseRequest.php | 5 +- src/MessageBird/Resources/PhoneNumbers.php | 1 + .../integration/numbers/PhoneNumbersTest.php | 52 +++++++++++++------ 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/MessageBird/Objects/Number.php b/src/MessageBird/Objects/Number.php index b2e560cd..392bd978 100644 --- a/src/MessageBird/Objects/Number.php +++ b/src/MessageBird/Objects/Number.php @@ -40,7 +40,7 @@ class Number extends Base * The available features for this Number * @var array */ - public $features = array(); + public $features; /** * Additional user-provided tags for this Number diff --git a/src/MessageBird/Objects/NumberPurchaseRequest.php b/src/MessageBird/Objects/NumberPurchaseRequest.php index e93f091f..641b3eb0 100644 --- a/src/MessageBird/Objects/NumberPurchaseRequest.php +++ b/src/MessageBird/Objects/NumberPurchaseRequest.php @@ -19,10 +19,11 @@ class NumberPurchaseRequest extends Base public $number; /** - * The Number's country + * The country code for this number in ISO 3166-1 alpha-2 format. + * * @var string */ - public $country; + public $countryCode; /** * The interval in months that this number will be billed by diff --git a/src/MessageBird/Resources/PhoneNumbers.php b/src/MessageBird/Resources/PhoneNumbers.php index d4d9e6e5..fea97728 100644 --- a/src/MessageBird/Resources/PhoneNumbers.php +++ b/src/MessageBird/Resources/PhoneNumbers.php @@ -24,6 +24,7 @@ class PhoneNumbers extends Base public function __construct(Common\HttpClient $HttpClient) { $this->HttpClient = $HttpClient; + $this->setObject(new Objects\Number()); $this->setResourceName('phone-numbers'); } diff --git a/tests/integration/numbers/PhoneNumbersTest.php b/tests/integration/numbers/PhoneNumbersTest.php index 09a7b272..e55b0a11 100644 --- a/tests/integration/numbers/PhoneNumbersTest.php +++ b/tests/integration/numbers/PhoneNumbersTest.php @@ -7,26 +7,48 @@ protected function setUp(): void $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ - public function testCreateHlr() + public function testReadPhoneNumber() { - $Hlr = new \MessageBird\Objects\Hlr(); - $Hlr->msisdn = 'MessageBird'; - $Hlr->reference = "yoloswag3000"; + $this->expectException(\MessageBird\Exceptions\ServerException::class); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with('GET', 'phone-numbers/31612345678', null, null); + $this->client->phoneNumbers->read(31612345678); + } + + public function testListPhoneNumbers() + { + $this->expectException(\MessageBird\Exceptions\ServerException::class); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with('GET', 'phone-numbers', array (), null); + $this->client->phoneNumbers->getList(); + } + + public function testUpdatePhoneNumber() + { + $Number = new \MessageBird\Objects\Number(); + $Number->tags = array('tag1'); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'hlr', null, '{"msisdn":"MessageBird","network":null,"details":[],"reference":"yoloswag3000","status":null}'); - $this->client->hlr->create($Hlr); + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(200, '', '{"tags":["tag1"]}')); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with('PATCH', 'phone-numbers/31612345678', null, '{"tags":["tag1"]}'); + $this->client->phoneNumbers->update($Number, '31612345678'); } + public function testPurchasePhoneNumber() + { + $NumberPurchaseRequest = new \MessageBird\Objects\NumberPurchaseRequest(); + $NumberPurchaseRequest->number = '31612345678'; + $NumberPurchaseRequest->countryCode = 'NL'; + $NumberPurchaseRequest->billingIntervalMonths = 1; + + $NumberJSON = '{"number":"31612345678","countryCode":"NL","billingIntervalMonths":1}'; + + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(201, '', "[$NumberJSON]")); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with('POST', 'phone-numbers', null, $NumberJSON); + $this->client->phoneNumbers->create($NumberPurchaseRequest); + } - /** - * @expectedException MessageBird\Exceptions\ServerException - */ - public function testReadHlr() + public function testCancelPhoneNumber() { - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'hlr/message_id', null, null); - $this->client->hlr->read("message_id"); + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(204, '', '')); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with('DELETE', 'phone-numbers/31612345678', null, null); + $this->client->phoneNumbers->delete('31612345678'); } } From 69557c61ee99241fc5627933221f44188a95ea15 Mon Sep 17 00:00:00 2001 From: Paolo Bueno Date: Thu, 9 Jan 2020 09:55:53 +0100 Subject: [PATCH 6/9] Make new examples use env var --- examples/available-phone-numbers-view.php | 2 +- examples/balance-view.php | 2 +- examples/phone-numbers-create.php | 2 +- examples/phone-numbers-delete.php | 2 +- examples/phone-numbers-update.php | 2 +- examples/phone-numbers-view.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/available-phone-numbers-view.php b/examples/available-phone-numbers-view.php index 52562ed8..40861d14 100644 --- a/examples/available-phone-numbers-view.php +++ b/examples/available-phone-numbers-view.php @@ -2,7 +2,7 @@ require_once(__DIR__ . '/../autoload.php'); -$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); // Set your own API access key here. +$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); try { $phoneNumbers = $MessageBird->availablePhoneNumbers->getList("nl", array()); diff --git a/examples/balance-view.php b/examples/balance-view.php index d69d9e95..83c7685b 100644 --- a/examples/balance-view.php +++ b/examples/balance-view.php @@ -2,7 +2,7 @@ require_once(__DIR__ . '/../autoload.php'); -$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); +$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); // Set your own API access key here. try { $Balance = $MessageBird->balance->read(); diff --git a/examples/phone-numbers-create.php b/examples/phone-numbers-create.php index 179b54d0..db43c3f4 100644 --- a/examples/phone-numbers-create.php +++ b/examples/phone-numbers-create.php @@ -2,7 +2,7 @@ require_once(__DIR__ . '/../autoload.php'); -$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. +$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'; diff --git a/examples/phone-numbers-delete.php b/examples/phone-numbers-delete.php index b29b2750..77bde1c3 100644 --- a/examples/phone-numbers-delete.php +++ b/examples/phone-numbers-delete.php @@ -2,7 +2,7 @@ require_once(__DIR__ . '/../autoload.php'); -$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. +$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); // Set your own API access key here. try { $deleted = $MessageBird->phoneNumbers->delete('31612345678'); diff --git a/examples/phone-numbers-update.php b/examples/phone-numbers-update.php index 3635e828..f0af638f 100644 --- a/examples/phone-numbers-update.php +++ b/examples/phone-numbers-update.php @@ -2,7 +2,7 @@ require_once(__DIR__ . '/../autoload.php'); -$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. +$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); // Set your own API access key here. $Number = new \MessageBird\Objects\Number(); $Number->tags = array('tag1'); diff --git a/examples/phone-numbers-view.php b/examples/phone-numbers-view.php index 187bb771..a4b4bd8d 100644 --- a/examples/phone-numbers-view.php +++ b/examples/phone-numbers-view.php @@ -2,7 +2,7 @@ require_once(__DIR__ . '/../autoload.php'); -$MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. +$MessageBird = new \MessageBird\Client(getenv('MESSAGEBIRD_API_KEY')); // Set your own API access key here. try { $phoneNumbers = $MessageBird->phoneNumbers->getList(); From 5541dc4400f7df74ae1368f453b092c19839a05e Mon Sep 17 00:00:00 2001 From: Paolo Bueno Date: Thu, 9 Jan 2020 10:49:11 +0100 Subject: [PATCH 7/9] Add tests for AvailablePhoneNumbers --- .../Resources/AvailablePhoneNumbers.php | 4 ++-- .../numbers/AvailablePhoneNumbersTest.php | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 tests/integration/numbers/AvailablePhoneNumbersTest.php diff --git a/src/MessageBird/Resources/AvailablePhoneNumbers.php b/src/MessageBird/Resources/AvailablePhoneNumbers.php index bde7556e..38a20af6 100644 --- a/src/MessageBird/Resources/AvailablePhoneNumbers.php +++ b/src/MessageBird/Resources/AvailablePhoneNumbers.php @@ -75,7 +75,7 @@ private function processRequest($body) $body = @json_decode($body); if ($body === null or $body === false) { - throw new Exceptions\ServerException('Got an invalid JSON response from the server.'); + throw new \MessageBird\Exceptions\ServerException('Got an invalid JSON response from the server.'); } if (empty($body->errors)) { @@ -83,7 +83,7 @@ private function processRequest($body) } $ResponseError = new Common\ResponseError($body); - throw new Exceptions\RequestException($ResponseError->getErrorString()); + throw new \MessageBird\Exceptions\RequestException($ResponseError->getErrorString()); } } ?> diff --git a/tests/integration/numbers/AvailablePhoneNumbersTest.php b/tests/integration/numbers/AvailablePhoneNumbersTest.php new file mode 100644 index 00000000..07cbb710 --- /dev/null +++ b/tests/integration/numbers/AvailablePhoneNumbersTest.php @@ -0,0 +1,16 @@ +client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); + } + + public function testListAvailablePhoneNumbers() + { + $this->expectException(\MessageBird\Exceptions\ServerException::class); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with('GET', 'available-phone-numbers/nl', array (), null); + $this->client->availablePhoneNumbers->getList("nl", array()); + } +} From 601335363c9746affa0093f3db83639a3f8b9a7e Mon Sep 17 00:00:00 2001 From: Paolo Bueno Date: Mon, 13 Jan 2020 11:26:02 +0100 Subject: [PATCH 8/9] Remove alignment to avoid threshing on resource additions --- src/MessageBird/Client.php | 50 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/MessageBird/Client.php b/src/MessageBird/Client.php index 0ab19ab7..9d06dda2 100644 --- a/src/MessageBird/Client.php +++ b/src/MessageBird/Client.php @@ -232,31 +232,31 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n $this->setAccessKey($accessKey); } - $this->messages = new Resources\Messages($this->HttpClient); - $this->hlr = new Resources\Hlr($this->HttpClient); - $this->verify = new Resources\Verify($this->HttpClient); - $this->balance = new Resources\Balance($this->HttpClient); - $this->voicemessages = new Resources\VoiceMessage($this->HttpClient); - $this->lookup = new Resources\Lookup($this->HttpClient); - $this->lookupHlr = new Resources\LookupHlr($this->HttpClient); - $this->chatMessages = new Resources\Chat\Message($this->ChatAPIHttpClient); - $this->chatChannels = new Resources\Chat\Channel($this->ChatAPIHttpClient); - $this->chatPlatforms = new Resources\Chat\Platform($this->ChatAPIHttpClient); - $this->chatContacts = new Resources\Chat\Contact($this->ChatAPIHttpClient); - $this->voiceCallFlows = new Resources\Voice\CallFlows($this->VoiceAPIHttpClient); - $this->voiceCalls = new Resources\Voice\Calls($this->VoiceAPIHttpClient); - $this->voiceLegs = new Resources\Voice\Legs($this->VoiceAPIHttpClient); - $this->voiceRecordings = new Resources\Voice\Recordings($this->VoiceAPIHttpClient); - $this->voiceTranscriptions = new Resources\Voice\Transcriptions($this->VoiceAPIHttpClient); - $this->voiceWebhooks = new Resources\Voice\Webhooks($this->VoiceAPIHttpClient); - $this->mmsMessages = new Resources\MmsMessages($this->HttpClient); - $this->contacts = new Resources\Contacts($this->HttpClient); - $this->groups = new Resources\Groups($this->HttpClient); - $this->conversations = new Resources\Conversation\Conversations($this->ConversationsAPIHttpClient); - $this->conversationMessages = new Resources\Conversation\Messages($this->ConversationsAPIHttpClient); - $this->conversationWebhooks = new Resources\Conversation\Webhooks($this->ConversationsAPIHttpClient); - $this->partnerAccounts = new Resources\PartnerAccount\Accounts($this->partnerAccountClient); - $this->phoneNumbers = new Resources\PhoneNumbers($this->numbersAPIClient); + $this->messages = new Resources\Messages($this->HttpClient); + $this->hlr = new Resources\Hlr($this->HttpClient); + $this->verify = new Resources\Verify($this->HttpClient); + $this->balance = new Resources\Balance($this->HttpClient); + $this->voicemessages = new Resources\VoiceMessage($this->HttpClient); + $this->lookup = new Resources\Lookup($this->HttpClient); + $this->lookupHlr = new Resources\LookupHlr($this->HttpClient); + $this->chatMessages = new Resources\Chat\Message($this->ChatAPIHttpClient); + $this->chatChannels = new Resources\Chat\Channel($this->ChatAPIHttpClient); + $this->chatPlatforms = new Resources\Chat\Platform($this->ChatAPIHttpClient); + $this->chatContacts = new Resources\Chat\Contact($this->ChatAPIHttpClient); + $this->voiceCallFlows = new Resources\Voice\CallFlows($this->VoiceAPIHttpClient); + $this->voiceCalls = new Resources\Voice\Calls($this->VoiceAPIHttpClient); + $this->voiceLegs = new Resources\Voice\Legs($this->VoiceAPIHttpClient); + $this->voiceRecordings = new Resources\Voice\Recordings($this->VoiceAPIHttpClient); + $this->voiceTranscriptions = new Resources\Voice\Transcriptions($this->VoiceAPIHttpClient); + $this->voiceWebhooks = new Resources\Voice\Webhooks($this->VoiceAPIHttpClient); + $this->mmsMessages = new Resources\MmsMessages($this->HttpClient); + $this->contacts = new Resources\Contacts($this->HttpClient); + $this->groups = new Resources\Groups($this->HttpClient); + $this->conversations = new Resources\Conversation\Conversations($this->ConversationsAPIHttpClient); + $this->conversationMessages = new Resources\Conversation\Messages($this->ConversationsAPIHttpClient); + $this->conversationWebhooks = new Resources\Conversation\Webhooks($this->ConversationsAPIHttpClient); + $this->partnerAccounts = new Resources\PartnerAccount\Accounts($this->partnerAccountClient); + $this->phoneNumbers = new Resources\PhoneNumbers($this->numbersAPIClient); $this->availablePhoneNumbers = new Resources\AvailablePhoneNumbers($this->numbersAPIClient); } From 0e8f398844765431da68bbaff77e15d4661fe5f1 Mon Sep 17 00:00:00 2001 From: Paolo Bueno Date: Mon, 13 Jan 2020 11:26:24 +0100 Subject: [PATCH 9/9] Add return type information --- src/MessageBird/Objects/Number.php | 2 +- .../Resources/AvailablePhoneNumbers.php | 43 +++++++++---------- src/MessageBird/Resources/PhoneNumbers.php | 6 +-- tests/integration/BaseTest.php | 2 +- tests/integration/balance/BalanceTest.php | 2 +- tests/integration/chat/ChatTest.php | 2 +- tests/integration/contacts/ContactTest.php | 2 +- .../conversation/ConversationMessageTest.php | 2 +- .../conversation/ConversationTest.php | 2 +- .../conversation/ConversationWebhookTest.php | 2 +- tests/integration/groups/GroupTest.php | 2 +- tests/integration/hlr/HlrTest.php | 2 +- tests/integration/lookup/LookupTest.php | 2 +- tests/integration/messages/MessagesTest.php | 2 +- .../numbers/AvailablePhoneNumbersTest.php | 2 +- .../integration/numbers/PhoneNumbersTest.php | 2 +- .../partneraccount/AccountTest.php | 2 +- tests/integration/verify/VerifyTest.php | 2 +- tests/integration/voice/VoiceTest.php | 2 +- .../voicemessages/VoiceMessagesTest.php | 2 +- 20 files changed, 42 insertions(+), 43 deletions(-) diff --git a/src/MessageBird/Objects/Number.php b/src/MessageBird/Objects/Number.php index 392bd978..2156d497 100644 --- a/src/MessageBird/Objects/Number.php +++ b/src/MessageBird/Objects/Number.php @@ -46,7 +46,7 @@ class Number extends Base * Additional user-provided tags for this Number * @var array */ - public $tags = array(); + public $tags = []; /** * Number type (example: landline, mobile). diff --git a/src/MessageBird/Resources/AvailablePhoneNumbers.php b/src/MessageBird/Resources/AvailablePhoneNumbers.php index 38a20af6..e23d06b2 100644 --- a/src/MessageBird/Resources/AvailablePhoneNumbers.php +++ b/src/MessageBird/Resources/AvailablePhoneNumbers.php @@ -34,7 +34,7 @@ public function __construct(Common\HttpClient $HttpClient) * @throws \MessageBird\Exceptions\RequestException * @throws \MessageBird\Exceptions\ServerException */ - public function getList($countryCode, $parameters = array()) + public function getList($countryCode, $parameters = []): Objects\BaseList { list($status, , $body) = $this->HttpClient->performHttpRequest( Common\HttpClient::REQUEST_GET, @@ -42,25 +42,24 @@ public function getList($countryCode, $parameters = array()) $parameters ); - if ($status === 200) { - $body = json_decode($body); + if ($status !== 200) { + return $this->processRequest($body); + } + $body = json_decode($body); - $items = $body->data; - unset($body->data); + $items = $body->data; + unset($body->data); - $baseList = new Objects\BaseList(); - $baseList->loadFromArray($body); + $baseList = new Objects\BaseList(); + $baseList->loadFromArray($body); - foreach ($items as $item) { - $object = new Objects\Number($this->HttpClient); + foreach ($items as $item) { + $object = new Objects\Number($this->HttpClient); - $itemObject = $object->loadFromArray($item); - $baseList->items[] = $itemObject; - } - return $baseList; + $itemObject = $object->loadFromArray($item); + $baseList->items[] = $itemObject; } - - return $this->processRequest($body); + return $baseList; } /** @@ -70,20 +69,20 @@ public function getList($countryCode, $parameters = array()) * @throws \MessageBird\Exceptions\RequestException * @throws \MessageBird\Exceptions\ServerException */ - private function processRequest($body) + private function processRequest($body): Objects\Number { - $body = @json_decode($body); + $body = json_decode($body); - if ($body === null or $body === false) { + if (json_last_error()) { throw new \MessageBird\Exceptions\ServerException('Got an invalid JSON response from the server.'); } - if (empty($body->errors)) { - return Objects\Number.loadFromArray($body->data[0]); + if (!empty($body->errors)) { + $ResponseError = new Common\ResponseError($body); + throw new \MessageBird\Exceptions\RequestException($ResponseError->getErrorString()); } - $ResponseError = new Common\ResponseError($body); - throw new \MessageBird\Exceptions\RequestException($ResponseError->getErrorString()); + return Objects\Number.loadFromArray($body->data[0]); } } ?> diff --git a/src/MessageBird/Resources/PhoneNumbers.php b/src/MessageBird/Resources/PhoneNumbers.php index fea97728..3ae2d60c 100644 --- a/src/MessageBird/Resources/PhoneNumbers.php +++ b/src/MessageBird/Resources/PhoneNumbers.php @@ -32,14 +32,14 @@ public function __construct(Common\HttpClient $HttpClient) * @param $object * @param $id * - * @return $this ->Object + * @return Objects\Number * * @internal param array $parameters */ - public function update($object, $id) + public function update($object, $id): Objects\Number { $objVars = get_object_vars($object); - $body = array(); + $body = []; foreach ($objVars as $key => $value) { if (null !== $value) { $body[$key] = $value; diff --git a/tests/integration/BaseTest.php b/tests/integration/BaseTest.php index 4ea04a8b..4e51cfce 100644 --- a/tests/integration/BaseTest.php +++ b/tests/integration/BaseTest.php @@ -10,7 +10,7 @@ class BaseTest extends TestCase /** @var PHPUnit_Framework_MockObject_MockObject */ protected $mockClient; - protected function setUp(): void + protected function setUp() { $this->mockClient = $this->getMockBuilder("\MessageBird\Common\HttpClient")->setConstructorArgs(array("fake.messagebird.dev"))->getMock(); $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/balance/BalanceTest.php b/tests/integration/balance/BalanceTest.php index bde69ed8..7ab836a2 100644 --- a/tests/integration/balance/BalanceTest.php +++ b/tests/integration/balance/BalanceTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/chat/ChatTest.php b/tests/integration/chat/ChatTest.php index bc9c79e3..219350e5 100644 --- a/tests/integration/chat/ChatTest.php +++ b/tests/integration/chat/ChatTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/contacts/ContactTest.php b/tests/integration/contacts/ContactTest.php index ae511e51..f3adde86 100644 --- a/tests/integration/contacts/ContactTest.php +++ b/tests/integration/contacts/ContactTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/conversation/ConversationMessageTest.php b/tests/integration/conversation/ConversationMessageTest.php index c6d9e468..87111a53 100644 --- a/tests/integration/conversation/ConversationMessageTest.php +++ b/tests/integration/conversation/ConversationMessageTest.php @@ -46,7 +46,7 @@ class ConversationMessageTest extends BaseTest "type": "video" }'; - protected function setUp(): void + protected function setUp() { parent::setUp(); diff --git a/tests/integration/conversation/ConversationTest.php b/tests/integration/conversation/ConversationTest.php index 15a6daee..94938dd8 100644 --- a/tests/integration/conversation/ConversationTest.php +++ b/tests/integration/conversation/ConversationTest.php @@ -94,7 +94,7 @@ class ConversationTest extends BaseTest "lastUsedChannelId": "channel-id" }'; - protected function setUp(): void + protected function setUp() { parent::setUp(); diff --git a/tests/integration/conversation/ConversationWebhookTest.php b/tests/integration/conversation/ConversationWebhookTest.php index acf236fe..3cae2ec5 100644 --- a/tests/integration/conversation/ConversationWebhookTest.php +++ b/tests/integration/conversation/ConversationWebhookTest.php @@ -37,7 +37,7 @@ class ConversationWebhookTest extends BaseTest "updatedDatetime": "2018-07-20T12:13:51+00:00" }'; - protected function setUp(): void + protected function setUp() { parent::setUp(); diff --git a/tests/integration/groups/GroupTest.php b/tests/integration/groups/GroupTest.php index 4ab0e8d5..42a28beb 100644 --- a/tests/integration/groups/GroupTest.php +++ b/tests/integration/groups/GroupTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/hlr/HlrTest.php b/tests/integration/hlr/HlrTest.php index 34f9d9bd..1eebad69 100644 --- a/tests/integration/hlr/HlrTest.php +++ b/tests/integration/hlr/HlrTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/lookup/LookupTest.php b/tests/integration/lookup/LookupTest.php index a8906d93..0533d1ee 100644 --- a/tests/integration/lookup/LookupTest.php +++ b/tests/integration/lookup/LookupTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/messages/MessagesTest.php b/tests/integration/messages/MessagesTest.php index c558b521..9e246bf1 100644 --- a/tests/integration/messages/MessagesTest.php +++ b/tests/integration/messages/MessagesTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/numbers/AvailablePhoneNumbersTest.php b/tests/integration/numbers/AvailablePhoneNumbersTest.php index 07cbb710..9f64dc0d 100644 --- a/tests/integration/numbers/AvailablePhoneNumbersTest.php +++ b/tests/integration/numbers/AvailablePhoneNumbersTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/numbers/PhoneNumbersTest.php b/tests/integration/numbers/PhoneNumbersTest.php index e55b0a11..da95cdd1 100644 --- a/tests/integration/numbers/PhoneNumbersTest.php +++ b/tests/integration/numbers/PhoneNumbersTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/partneraccount/AccountTest.php b/tests/integration/partneraccount/AccountTest.php index 68206f9d..25391217 100644 --- a/tests/integration/partneraccount/AccountTest.php +++ b/tests/integration/partneraccount/AccountTest.php @@ -2,7 +2,7 @@ class AccountTest extends BaseTest { - protected function setUp(): void + protected function setUp() { parent::setUp(); $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/verify/VerifyTest.php b/tests/integration/verify/VerifyTest.php index 589e864d..c796a968 100644 --- a/tests/integration/verify/VerifyTest.php +++ b/tests/integration/verify/VerifyTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/voice/VoiceTest.php b/tests/integration/voice/VoiceTest.php index 0d7cd7c2..fd51031f 100644 --- a/tests/integration/voice/VoiceTest.php +++ b/tests/integration/voice/VoiceTest.php @@ -5,7 +5,7 @@ class VoiceTest extends BaseTest /** @var \MessageBird\Client client */ public $client; - protected function setUp(): void + protected function setUp() { parent::setUp(); $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); diff --git a/tests/integration/voicemessages/VoiceMessagesTest.php b/tests/integration/voicemessages/VoiceMessagesTest.php index 6ea883a2..726e336a 100644 --- a/tests/integration/voicemessages/VoiceMessagesTest.php +++ b/tests/integration/voicemessages/VoiceMessagesTest.php @@ -1,7 +1,7 @@ client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient);