Skip to content

Commit 2601a5c

Browse files
Dennis van der VlietdennisvdvlietAlexandru Bucur
authored
Add additional properties to Recipient object (#186)
* 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. Co-authored-by: Dennis van der Vliet <[email protected]> Co-authored-by: Alexandru Bucur <[email protected]>
1 parent 12882fc commit 2601a5c

File tree

2 files changed

+102
-2
lines changed

2 files changed

+102
-2
lines changed

src/MessageBird/Objects/Recipient.php

+77-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,85 @@ class Recipient extends Base
2929
public $status;
3030

3131
/**
32-
* The datum time of the last status in RFC3339 format (Y-m-d\TH:i:sP)
32+
* The date and time of the last status in RFC3339 format (Y-m-d\TH:i:sP)
3333
*
3434
* @var string
3535
*/
3636
public $statusDatetime;
37+
38+
39+
/**
40+
* The details about the status message. More details can be found here:
41+
* https://developers.messagebird.com/api/sms-messaging/#sms-statuses
42+
*
43+
* @var string
44+
*/
45+
public $statusReason;
46+
47+
/**
48+
* Extra error code that describes the failure in more detail (optional,
49+
* null if not available)
50+
*
51+
* @var string
52+
*/
53+
public $statusErrorCode;
54+
55+
/**
56+
* The name of the recipient’s original country, based on MSISDN.
57+
*
58+
* @var string
59+
*/
60+
public $recipientCountry;
61+
62+
/**
63+
* The prefix code for the recipient’s original country, based on MSISDN.
64+
*
65+
* @var int
66+
*/
67+
public $recipientCountryPrefix;
68+
69+
/**
70+
* The name of the operator of the recipient. Identified by MCCMNC
71+
* of the message.
72+
*
73+
* @var string
74+
*/
75+
public $recipientOperator;
76+
77+
/**
78+
* The code of the operator of the message sender.
79+
* It could have null value if the message isn’t delivered yet.
80+
*
81+
* @var string
82+
*/
83+
public $mccmnc;
84+
85+
/**
86+
* The MCC (Mobile Country Code) part of MCCMNC.
87+
*
88+
* @var string
89+
*/
90+
public $mcc;
91+
92+
/**
93+
* The MNC (Mobile Network Code) part of MCCMNC.
94+
*
95+
* @var string
96+
*/
97+
public $mnc;
98+
99+
/**
100+
* The length of the message in characters. Depends on the
101+
* message datacoding.
102+
*
103+
* @var int
104+
*/
105+
public $messageLength;
106+
107+
/**
108+
* The count of total messages send. Personalisation not taken in account.
109+
*
110+
* @var int
111+
*/
112+
public $messagePartCount;
37113
}

tests/Integration/Messages/MessagesTest.php

+25-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,21 @@ public function testCreateMessageResponse(): void
170170
{
171171
"recipient":31612345678,
172172
"status":"sent",
173-
"statusDatetime":"2015-07-03T07:55:31+00:00"
173+
"statusDatetime":"2015-07-03T07:55:31+00:00",
174+
"statusReason":"successfully delivered",
175+
"statusErrorCode":null,
176+
"recipientCountry":"Netherlands",
177+
"recipientCountryPrefix":31,
178+
"recipientOperator":"KPN",
179+
"mccmnc":"20408",
180+
"mcc":"204",
181+
"mnc":"08",
182+
"messageLength":22,
183+
"messagePartCount":1,
184+
"price":{
185+
"amount":0.075,
186+
"currency":"EUR"
187+
}
174188
}
175189
]
176190
},
@@ -206,5 +220,15 @@ public function testCreateMessageResponse(): void
206220
self::assertSame(31612345678, $messageResponse->recipients->items[0]->recipient);
207221
self::assertSame('sent', $messageResponse->recipients->items[0]->status);
208222
self::assertSame('2015-07-03T07:55:31+00:00', $messageResponse->recipients->items[0]->statusDatetime);
223+
self::assertSame('successfully delivered', $messageResponse->recipients->items[0]->statusReason);
224+
self::assertSame(null, $messageResponse->recipients->items[0]->statusErrorCode);
225+
self::assertSame('Netherlands', $messageResponse->recipients->items[0]->recipientCountry);
226+
self::assertSame(31, $messageResponse->recipients->items[0]->recipientCountryPrefix);
227+
self::assertSame('KPN', $messageResponse->recipients->items[0]->recipientOperator);
228+
self::assertSame('20408', $messageResponse->recipients->items[0]->mccmnc);
229+
self::assertSame('204', $messageResponse->recipients->items[0]->mcc);
230+
self::assertSame('08', $messageResponse->recipients->items[0]->mnc);
231+
self::assertSame(22, $messageResponse->recipients->items[0]->messageLength);
232+
self::assertSame(1, $messageResponse->recipients->items[0]->messagePartCount);
209233
}
210234
}

0 commit comments

Comments
 (0)