Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Traits/Sms/HandlesSms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
12 changes: 12 additions & 0 deletions tests/Feature/SmsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}