Skip to content

Commit 4deddf7

Browse files
authored
added missing optional client ref to delivery webhook (#342)
* added missing optional client ref to delivery webhook * Add test for delivery receipt webhook test
1 parent 72f77a6 commit 4deddf7

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/SMS/Webhook/DeliveryReceipt.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ class DeliveryReceipt
206206
*/
207207
protected $apiKey;
208208

209+
/**
210+
* @var mixed|string
211+
*/
212+
protected $clientRef;
213+
209214
/**
210215
* @param array<string, string> $data
211216
*
@@ -229,6 +234,10 @@ public function __construct(array $data)
229234
$this->status = $data['status'];
230235
$this->to = $data['to'];
231236
$this->apiKey = $data['api-key'];
237+
238+
if (isset($data['client-ref'])) {
239+
$this->clientRef = $data['client-ref'];
240+
}
232241
}
233242

234243
public function getErrCode(): int
@@ -280,4 +289,9 @@ public function getApiKey(): string
280289
{
281290
return $this->apiKey;
282291
}
292+
293+
public function getClientRef(): ?string
294+
{
295+
return $this->clientRef ?? null;
296+
}
283297
}

test/SMS/Webhook/DeliveryReceiptTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public function testCanCreateFromRawArray(): void
9696
$this->assertSame($expected['status'], $dlr->getStatus());
9797
$this->assertSame($expected['to'], $dlr->getTo());
9898
$this->assertSame($expected['api-key'], $dlr->getApiKey());
99+
$this->assertSame($expected['client-ref'], $dlr->getClientRef());
99100
$this->assertSame($expected['message-timestamp'], $dlr->getMessageTimestamp()->format('Y-m-d H:i:s'));
100101
}
101102

test/SMS/requests/dlr-get.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
GET /webhooks/dlr?msisdn=14845552121&to=16105553939&network-code=310004&messageId=14000000F9DBBBBB&price=0.00845000&status=delivered&scts=1234567890&err-code=0&api-key=a1234567&message-timestamp=2020-07-17+02%3A34%3A35 HTTP/1.1
1+
GET /webhooks/dlr?msisdn=14845552121&to=16105553939&network-code=310004&messageId=14000000F9DBBBBB&price=0.00845000&status=delivered&scts=1234567890&err-code=0&api-key=a1234567&client-ref=my-ref&message-timestamp=2020-07-17+02%3A34%3A35 HTTP/1.1
22
Accept: */*
33
User-Agent: Vonage/MessagingHUB/v1.0
44
Host: dragonmantank.ngrok.io

0 commit comments

Comments
 (0)