From 13140b94d70ea53cec4f268609f8ba83d6035709 Mon Sep 17 00:00:00 2001 From: Matthew Inamdar Date: Thu, 28 Dec 2017 01:20:38 +0000 Subject: [PATCH] fixed get delivery status method --- src/Client.php | 10 +++++++--- tests/ClientTest.php | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Client.php b/src/Client.php index 9066490..48683db 100644 --- a/src/Client.php +++ b/src/Client.php @@ -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'; @@ -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()); diff --git a/tests/ClientTest.php b/tests/ClientTest.php index db93ecf..6c83e43 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -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