Skip to content

Commit

Permalink
Merge pull request #1 from goldspecdigital/develop
Browse files Browse the repository at this point in the history
fixed get delivery status method
  • Loading branch information
matthew-inamdar committed Dec 28, 2017
2 parents 8a72577 + 13140b9 commit af78eec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Client
{
protected const URI = 'https://www.voodooSMS.com/vapi/server/';
protected const MESSAGE_LIMIT = 160;
protected const EXTERNAL_REFERENCE_LIMIT = 160;
protected const EXTERNAL_REFERENCE_LIMIT = 30;
protected const COUNTRY_CODE = 44;
protected const RESPONSE_FORMAT = 'JSON';

Expand Down Expand Up @@ -115,9 +115,13 @@ public function send(string $message, string $to, ?string $from = null, ?string
public function getDeliveryStatus(string $referenceID): object
{
$uri = 'getDlrStatus';
$parameters = ['reference_id' => $referenceID];
$parameters = [
'uid' => $this->username,
'pass' => $this->password,
'reference_id' => $referenceID,
];

$request = $this->httpClient->get($uri, $this->headers, $parameters);
$request = $this->httpClient->post($uri, $this->headers, $parameters);
$response = $this->httpClient->send($request);

return json_decode((string)$response->getBody());
Expand Down
14 changes: 14 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ public function testSendWorksWithFromSetInConstructor(): void
$this->assertEquals(200, $response->result);
}

/**
* @throws \Exception
*/
public function testGetDeliveryStatusWorks(): void
{
$client = $this->createClient('PHPUnitTest');
$response = $client->send('This is a test message', getenv('VOODOO_TO'));
$deliveryStatus = $client->getDeliveryStatus($response->reference_id[0]);

$this->assertEquals('200 OK', $deliveryStatus->result);
$this->assertEquals($response->reference_id[0], $deliveryStatus->reference_id);
$this->assertEquals('This is a test message', $deliveryStatus->message);
}

/**
* @param null|string $from
* @return \GoldSpecDigital\VoodooSmsSdk\Client
Expand Down

0 comments on commit af78eec

Please sign in to comment.