From 536fb7468a9c97394f4303dde8137c41a9d3c830 Mon Sep 17 00:00:00 2001 From: McGwery Date: Thu, 22 Aug 2024 12:22:19 +0300 Subject: [PATCH 1/3] Check delivery report of the sms --- src/Traits/Sms/HandlesSms.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Traits/Sms/HandlesSms.php b/src/Traits/Sms/HandlesSms.php index d7823bc..401208a 100644 --- a/src/Traits/Sms/HandlesSms.php +++ b/src/Traits/Sms/HandlesSms.php @@ -173,4 +173,21 @@ public function deleteSmsTemplate(string $templateId): Response 'DELETE' ); } + + /** + * @param string $destAddr + * + * @param string $requestId + * + * @return Response + * + * @throws ConfigurationUnavailableException + */ + public function smsDeliveryReport(string $destAddr, string $requestId): Response + { + return $this->call( + "https://dlrapi.beem.africa/public/v1/delivery-reports?dest_addr=$destAddr&request_id=$requestId", + 'GET' + ); + } } \ No newline at end of file From 9d4a486f023f903fb07bbe5b48d444b8a84f3431 Mon Sep 17 00:00:00 2001 From: McGwery Date: Thu, 22 Aug 2024 12:31:44 +0300 Subject: [PATCH 2/3] Testing delivery report of sms and add description to smsDeliveryReport method --- src/Traits/Sms/HandlesSms.php | 1 + tests/Feature/SmsTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Traits/Sms/HandlesSms.php b/src/Traits/Sms/HandlesSms.php index 401208a..a1c0aeb 100644 --- a/src/Traits/Sms/HandlesSms.php +++ b/src/Traits/Sms/HandlesSms.php @@ -175,6 +175,7 @@ public function deleteSmsTemplate(string $templateId): Response } /** + * Delivery reports for sms can be accessed by requesting the status of each message using the below request. Delivery status should be checked 5mins or later after an sms has been submitted to the platform to allow for any delivery delays experienced with mobile network operators. * @param string $destAddr * * @param string $requestId diff --git a/tests/Feature/SmsTest.php b/tests/Feature/SmsTest.php index 25847b2..9747021 100644 --- a/tests/Feature/SmsTest.php +++ b/tests/Feature/SmsTest.php @@ -53,4 +53,16 @@ public function it_can_request_sender_names() $this->assertTrue($request->successful()); } + + /** @test */ + public function it_can_check_delivery_report() + { + $request = Beem::sms( + 'Your verification code: 34990', + [['recipient_id' => (string) now()->timestamp, 'dest_addr' => '255753820520']] + ); + sleep(60 * 10); + $request2 = Beem::smsDeliveryReport('255753820520', json_decode($request,true)['request_id']); + $this->assertTrue((json_decode($request2,true)['dest_addr']=='255753820520')); + } } From c6dd5cf8bf936915347293ddcd01d49fa9090a1f Mon Sep 17 00:00:00 2001 From: McGwery Date: Thu, 22 Aug 2024 18:38:51 +0300 Subject: [PATCH 3/3] Working with Fixing payload --- src/Traits/Sms/HandlesSms.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Traits/Sms/HandlesSms.php b/src/Traits/Sms/HandlesSms.php index a1c0aeb..8d54f07 100644 --- a/src/Traits/Sms/HandlesSms.php +++ b/src/Traits/Sms/HandlesSms.php @@ -186,9 +186,12 @@ public function deleteSmsTemplate(string $templateId): Response */ public function smsDeliveryReport(string $destAddr, string $requestId): Response { + $body = array('request_id' => $requestId,'dest_addr' => $destAddr); + //?dest_addr={$destAddr}&request_id={$requestId} return $this->call( - "https://dlrapi.beem.africa/public/v1/delivery-reports?dest_addr=$destAddr&request_id=$requestId", - 'GET' + "https://dlrapi.beem.africa/public/v1/delivery-reports", + 'GET', + $body ); } } \ No newline at end of file