diff --git a/src/Traits/Sms/HandlesSms.php b/src/Traits/Sms/HandlesSms.php index d7823bc..8d54f07 100644 --- a/src/Traits/Sms/HandlesSms.php +++ b/src/Traits/Sms/HandlesSms.php @@ -173,4 +173,25 @@ public function deleteSmsTemplate(string $templateId): Response 'DELETE' ); } + + /** + * 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 + * + * @return Response + * + * @throws ConfigurationUnavailableException + */ + 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", + 'GET', + $body + ); + } } \ No newline at end of file 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')); + } }