From bdaf9147708e71548246e708806bc6884141e257 Mon Sep 17 00:00:00 2001 From: Dennis van der Vliet Date: Mon, 17 Jan 2022 20:32:45 +0100 Subject: [PATCH 1/5] Add additional properties to Recipient object The REST API returns attributes not included in the `Recipient` object. This PR adds additional attributes with one exception; pricing information. --- src/MessageBird/Objects/Recipient.php | 78 ++++++++++++++++++++- tests/Integration/Messages/MessagesTest.php | 26 ++++++- 2 files changed, 102 insertions(+), 2 deletions(-) diff --git a/src/MessageBird/Objects/Recipient.php b/src/MessageBird/Objects/Recipient.php index 0e5de5d1..400aac63 100644 --- a/src/MessageBird/Objects/Recipient.php +++ b/src/MessageBird/Objects/Recipient.php @@ -29,9 +29,85 @@ class Recipient extends Base public $status; /** - * The datum time of the last status in RFC3339 format (Y-m-d\TH:i:sP) + * The date and time of the last status in RFC3339 format (Y-m-d\TH:i:sP) * * @var string */ public $statusDatetime; + + + /** + * The details about the status message. More details can be found here: + * https://developers.messagebird.com/api/sms-messaging/#sms-statuses + * + * @var string + */ + public $statusReason; + + /** + * Extra error code that describes the failure in more detail (optional, + * null if not available) + * + * @var string + */ + public $statusErrorCode; + + /** + * The name of the recipient’s original country, based on MSISDN. + * + * @var string + */ + public $recipientCountry; + + /** + * The prefix code for the recipient’s original country, based on MSISDN. + * + * @var int + */ + public $recipientCountryPrefix; + + /** + * The name of the operator of the recipient. Identified by MCCMNC + * of the message. + * + * @var string + */ + public $recipientOperator; + + /** + * The code of the operator of the message sender. + * It could have null value if the message isn’t delivered yet. + * + * @var string + */ + public $mccmnc; + + /** + * The MCC (Mobile Country Code) part of MCCMNC. + * + * @var string + */ + public $mcc; + + /** + * The MNC (Mobile Network Code) part of MCCMNC. + * + * @var string + */ + public $mnc; + + /** + * The length of the message in characters. Depends on the + * message datacoding. + * + * @var int + */ + public $messageLength; + + /** + * The count of total messages send. Personalisation not taken in account. + * + * @var int + */ + public $messagePartCount; } diff --git a/tests/Integration/Messages/MessagesTest.php b/tests/Integration/Messages/MessagesTest.php index 8ca749f2..b84bbc07 100644 --- a/tests/Integration/Messages/MessagesTest.php +++ b/tests/Integration/Messages/MessagesTest.php @@ -170,7 +170,21 @@ public function testCreateMessageResponse(): void { "recipient":31612345678, "status":"sent", - "statusDatetime":"2015-07-03T07:55:31+00:00" + "statusDatetime":"2015-07-03T07:55:31+00:00", + "statusReason":"successfully delivered", + "statusErrorCode":null, + "recipientCountry":"Netherlands", + "recipientCountryPrefix":31, + "recipientOperator":"KPN", + "mccmnc":"20408", + "mcc":"204", + "mnc":"08", + "messageLength":22, + "messagePartCount":1, + "price":{ + "amount":0.075, + "currency":"EUR" + } } ] }, @@ -206,5 +220,15 @@ public function testCreateMessageResponse(): void self::assertSame(31612345678, $messageResponse->recipients->items[0]->recipient); self::assertSame('sent', $messageResponse->recipients->items[0]->status); self::assertSame('2015-07-03T07:55:31+00:00', $messageResponse->recipients->items[0]->statusDatetime); + self::assertSame('successfully delivered', $messageResponse->recipients->items[0]->statusReason); + self::assertSame(null, $messageResponse->recipients->items[0]->statusErrorCode); + self::assertSame('Netherlands', $messageResponse->recipients->items[0]->recipientCountry); + self::assertSame(31, $messageResponse->recipients->items[0]->recipientCountryPrefix); + self::assertSame('KPN', $messageResponse->recipients->items[0]->recipientOperator); + self::assertSame('20408', $messageResponse->recipients->items[0]->mccmnc); + self::assertSame('204', $messageResponse->recipients->items[0]->mcc); + self::assertSame('08', $messageResponse->recipients->items[0]->mnc); + self::assertSame(22, $messageResponse->recipients->items[0]->messageLength); + self::assertSame(1, $messageResponse->recipients->items[0]->messagePartCount); } } From 0cf46127a8a678b854019e10421ce4142ef9d5cf Mon Sep 17 00:00:00 2001 From: Dennis van der Vliet Date: Mon, 17 Jan 2022 21:42:45 +0100 Subject: [PATCH 2/5] Fix psalm version to 4.18.1 when running on GitHub --- .github/workflows/psalm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index a64cb3eb..60915c4c 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -16,4 +16,4 @@ jobs: - uses: actions/checkout@v2 - name: Psalm – Static Analysis for PHP - uses: docker://vimeo/psalm-github-actions + uses: docker://vimeo/psalm-github-actions:4.18.1 From eb754701eeefec852682a907fda0b1476c4a7753 Mon Sep 17 00:00:00 2001 From: Dennis van der Vliet Date: Mon, 17 Jan 2022 22:12:08 +0100 Subject: [PATCH 3/5] Update psalm.yml --- .github/workflows/psalm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 60915c4c..0c9d3ade 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -16,4 +16,4 @@ jobs: - uses: actions/checkout@v2 - name: Psalm – Static Analysis for PHP - uses: docker://vimeo/psalm-github-actions:4.18.1 + uses: docker://vimeo/psalm-github-actions:^4.6 From 2e47c939fe3f578ad4ef925154d587fc674d993c Mon Sep 17 00:00:00 2001 From: Dennis van der Vliet Date: Tue, 18 Jan 2022 08:50:18 +0100 Subject: [PATCH 4/5] Pin psalm to stable --- .github/workflows/psalm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 0c9d3ade..2c54dab2 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -16,4 +16,4 @@ jobs: - uses: actions/checkout@v2 - name: Psalm – Static Analysis for PHP - uses: docker://vimeo/psalm-github-actions:^4.6 + uses: docker://vimeo/psalm-github-actions:stable From 1fcd6245e8b53278f64bc9a7991bcbf1594b8f34 Mon Sep 17 00:00:00 2001 From: Dennis van der Vliet Date: Tue, 18 Jan 2022 16:14:51 +0100 Subject: [PATCH 5/5] Pin psalm version --- .github/workflows/psalm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 2c54dab2..729e3dc0 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -16,4 +16,4 @@ jobs: - uses: actions/checkout@v2 - name: Psalm – Static Analysis for PHP - uses: docker://vimeo/psalm-github-actions:stable + uses: docker://vimeo/psalm-github-actions:v4