diff --git a/CHANGELOG.md b/CHANGELOG.md index 36e9fdde..87754e09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,21 @@ # Change Log -## [4.53.0](https://github.com/plivo/plivo-php/tree/v4.53.0) (2023-08-02) +## [4.55.0](https://github.com/plivo/plivo-php/tree/v4.55.0) (2023-08-10) **Feature - Verify** - Added Create Session API - Added Get Session API - Added List Session API - Added Validate Session API +## [4.54.0](https://github.com/plivo/plivo-php/tree/v7.33.0) (2023-08-07) +**Feature - WhatsApp message support** +- Added new param `template` and new message_type `whatsapp` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message) +- Added new `message_states` (`read`) `message_type`(`whatsapp`),`conversation_id`, `conversation_origin`, `conversation_expiry_timestamp` in [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages) and [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) response + +## [4.53.0](https://github.com/plivo/plivo-php/tree/v4.53.0) (2023-08-03) +**Feature - DLT parameters** +- Added new params `DLTEntityID`, `DLTTemplateID`, `DLTTemplateCategory` to the [send message API](https://www.plivo.com/docs/sms/api/message/send-a-message/) +- Added new params `DLTEntityID`, `DLTTemplateID`, `DLTTemplateCategory` to the response for the [list all messages API](https://www.plivo.com/docs/sms/api/message/list-all-messages/) and the [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message) + ## [4.52.0](https://github.com/plivo/plivo-php/tree/v4.52.0) (2023-07-18) - Removed object_id and object_type in the parameter as well as response in [list all numbers API] diff --git a/Makefile b/Makefile index 3dc93e32..ef7d0038 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,10 @@ build: docker-compose up --build --remove-orphans +start: + docker-compose up --build --remove-orphans --detach + docker attach $(shell docker-compose ps -q phpSDK) + test: @[ "${CONTAINER}" ] && \ docker exec -it $$CONTAINER /bin/bash -c "/usr/src/app/vendor/bin/phpunit --verbose --bootstrap tests/bootstrap.php --testsuite resources-tests tests" || \ diff --git a/src/Plivo/Resources/Message/Message.php b/src/Plivo/Resources/Message/Message.php index f1650b81..6df88dc8 100644 --- a/src/Plivo/Resources/Message/Message.php +++ b/src/Plivo/Resources/Message/Message.php @@ -24,6 +24,9 @@ * @property ?string $errorCode * @property ?string $powerpackID * @property ?string $requesterIP + * @property ?string $conversationID + * @property ?string $conversationOrigin + * @property ?string $conversationExpirationTimestamp * @property ?bool $isDomestic */ class Message extends Resource @@ -38,7 +41,6 @@ public function __construct( MessageClient $client, $response, $authId, $uri) { parent::__construct($client); - $this->properties = [ 'from' => $response['from_number'], 'to' => $response['to_number'], @@ -68,6 +70,15 @@ public function __construct( if (!empty($response['message_expiry'])) { $this->properties['messageExpiry'] = $response['message_expiry']; } + if (!empty($response['dlt_entity_id'])) { + $this->properties['dltEntityID'] = $response['dlt_entity_id']; + } + if (!empty($response['dlt_template_id'])) { + $this->properties['dltTemplateID'] = $response['dlt_template_id']; + } + if (!empty($response['dlt_template_category'])) { + $this->properties['dltTemplateCategory'] = $response['dlt_template_category']; + } if (!empty($response['requester_ip'])) { $this->properties['requesterIP'] = $response['requester_ip']; @@ -81,6 +92,17 @@ public function __construct( $this->properties['tendlc_registration_status'] = $response['tendlc_registration_status']; } + if (!empty($response['conversation_id'])) { + $this->properties['conversationID'] = $response['conversation_id']; + } + + if (!empty($response['conversation_origin'])) { + $this->properties['conversationOrigin'] = $response['conversation_origin']; + } + if (!empty($response['conversation_expiration_timestamp'])) { + $this->properties['conversationExpirationTimestamp'] = $response['conversation_expiration_timestamp']; + } + if (isset($response['is_domestic'])){ $this->properties['isDomestic'] = $response['is_domestic']; } diff --git a/src/Plivo/Resources/Message/MessageInterface.php b/src/Plivo/Resources/Message/MessageInterface.php index 401f5f47..9fb3d341 100644 --- a/src/Plivo/Resources/Message/MessageInterface.php +++ b/src/Plivo/Resources/Message/MessageInterface.php @@ -8,6 +8,8 @@ use Plivo\Exceptions\PlivoRestException; use Plivo\Exceptions\PlivoResponseException; use Plivo\Util\ArrayOperations; +use Plivo\Util\Template; + use Plivo\MessageClient; use Plivo\Resources\ResourceInterface; @@ -74,7 +76,7 @@ public function get($messageUuid) *
message_time\__lt: lt stands for lesser than. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Eg:- To get all messages that were sent/received before 2012-03-21 11:47, use message_time\__lt=2012-03-21 11:47 *
message_time\__lte: lte stands for lesser than or equal. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Eg:- To get all messages that were sent/received before or exactly at 2012-03-21 11:47[:30], use message_time\__lte=2012-03-21 11:47[:30] *
Note: The above filters can be combined to get messages that were sent/received in a particular time range. The timestamps need to be UTC timestamps. - * + [string] :message_state Status value of the message, is one of "queued", "sent", "failed", "delivered", "undelivered" or "rejected" + * + [string] :message_state Status value of the message, is one of "queued", "sent", "failed","read", "deleted", "delivered", "undelivered" or "rejected" * + [int] :limit Used to display the number of results per page. The maximum number of results that can be fetched is 20. * + [int] :offset Denotes the number of value items by which the results should be offset. Eg:- If the result contains a 1000 values and limit is set to 10 and offset is set to 705, then values 706 through 715 are displayed in the results. This parameter is also used for pagination of the results. * + [string] :error_code Delivery Response code returned by the carrier attempting the delivery. See Supported error codes {https://www.plivo.com/docs/api/message/#standard-plivo-error-codes}. @@ -82,6 +84,9 @@ public function get($messageUuid) * + [string]: tendlc_campaign_id - exact tendlc campaign id search * + [string]:destination_country_iso2 - valid 2 character country_iso2 * + [string] : tendlc_registration_status - registered or unregistered enum allowed + * + [string] : conversation_id - Filter the results by conversation_id in case of whatsapp messages. + * + [string] : conversation_origin - Filter the results by conversation_origin in case of whatsapp messages. + * * @return MessageList */ protected function getList($optionalArgs = []) @@ -116,11 +121,11 @@ protected function getList($optionalArgs = []) * @param string $text * @param array $optionalArgs * + Valid arguments - * + [string] :type - The type of message. Should be `sms` or `mms`. Defaults to `sms`. + * + [string] :type - The type of message. Should be `sms`, `whatsapp` or `mms`. Defaults to `sms`. * + [string] :url - The URL to which with the status of the message is sent. The following parameters are sent to the URL: *
To - Phone number of the recipient *
From - Phone number of the sender - *
Status - Status of the message including "queued", "sent", "failed", "delivered", "undelivered" or "rejected" + *
Status - Status of the message including "queued", "sent", "failed", "delivered", "undelivered", "read", "deleted" or "rejected" *
MessageUUID - The unique ID for the message *
ParentMessageUUID - ID of the parent message (see notes about long SMS below) *
PartInfo - Specifies the sequence of the message (useful for long messages split into multiple text messages; see notes about long SMS below) @@ -132,6 +137,8 @@ protected function getList($optionalArgs = []) *
ErrorCode - Delivery Response code returned by the carrier attempting the delivery. See Supported error codes {https://www.plivo.com/docs/api/message/#standard-plivo-error-codes}. * + [string] :method - The method used to call the url. Defaults to POST. * + [string] :log - If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true. + * + [template] :template - For sending templated whatsapp messages. + * * [list] : media_urls - If your sending mms message, you can specify the media urls like ['https://yourmedia_urls/test.jpg','https://test.com/test.gif'] * @return MessageCreateResponse output * @throws PlivoValidationException,PlivoResponseException @@ -146,7 +153,8 @@ public function create($src=null, $dst=null, $text=null,array $optionalArgs = [] $dst = isset($optionalArgs['dst']) ? $optionalArgs['dst'] : null; $text = isset($optionalArgs['text']) ? $optionalArgs['text'] : null; $powerpackUUID = isset($optionalArgs['powerpackUUID']) ? $optionalArgs['powerpackUUID'] : null; - } + } + $template = isset($optionalArgs['template']) ? $optionalArgs['template'] : null; if (is_array($dst)){ $mandatoryArgs = [ 'dst' => implode('<', $dst), @@ -176,7 +184,29 @@ public function create($src=null, $dst=null, $text=null,array $optionalArgs = [] "Both powerpack_uuid and src cannot be specified. Specify either powerpack_uuid or src in request params to send a message." ); } + if(isset($optionalArgs['type']) && $optionalArgs['type'] == 'whatsapp' && is_null($src)) + { + throw new PlivoValidationException( + "src parameter not present" + ); + } + if (isset($optionalArgs['type']) && $optionalArgs['type'] != 'whatsapp' && !is_null($template)){ + throw new PlivoValidationException( + 'Template paramater is only applicable when message_type is whatsapp' + ); + } + if(!is_null($template)){ + $err = Template::validateTemplate($template); + if (!is_null($err)) + { + throw new PlivoValidationException( + $err + ); + } + $optionalArgs['template'] = json_decode($template,True); + } + $response = $this->client->update( $this->uri, array_merge($mandatoryArgs, $optionalArgs, ['src' => $src, 'powerpack_uuid' => $powerpackUUID, 'text' => $text]) diff --git a/src/Plivo/Util/template.php b/src/Plivo/Util/template.php new file mode 100644 index 00000000..9638e81c --- /dev/null +++ b/src/Plivo/Util/template.php @@ -0,0 +1,122 @@ +fallback_value = isset($data['fallback_value']) ? $data['fallback_value'] : null; + $this->currency_code = isset($data['currency_code']) ? $data['currency_code'] : null; + $this->amount_1000 = isset($data['amount_1000']) ? $data['amount_1000'] : null; + + validateNotNullAndDataType($this->fallback_value, 'currency', 'fallback_value', 'string', true); + validateNotNullAndDataType($this->currency_code, 'currency', 'currency_code', 'string', true); + validateNotNullAndDataType($this->amount_1000, 'currency', 'amount_1000', 'integer', true); + } + + +} + +class DateTime { + public $fallback_value; + + public function __construct(array $data) + { + // Validate the data + $this->fallback_value = isset($data['fallback_value'])? $data['fallback_value'] : null; + validateNotNullAndDataType($this->fallback_value, 'date_time', 'fallback_value', 'string', true); + } + +} + +class Parameter { + public $type; + public $text; + public $media; + public $currency; + public $date_time; + + public function __construct(array $data) + { + // Validate the data + $this->type = isset($data['type'])? $data['type'] : null; + $this->text = isset($data['text'])? $data['text'] : null; + $this->media = isset($data['media'])? $data['media'] : null; + $this->currency = isset($data['currency'])? new Currency($data['currency']) : null; + $this->date_time = isset($data['date_time']) ? new DateTime($data['date_time']) : null; + validateNotNullAndDataType($this->type, 'parameter', 'type', 'string', true); + validateNotNullAndDataType($this->text, 'parameter', 'text', 'string'); + validateNotNullAndDataType($this->media, 'parameter', 'media', 'string'); + } + + +} + +class Component { + public $type; + public $sub_type; + public $index; + public $parameters; + + public function __construct(array $data) + { + // Validate the data + $this->type = isset($data['type'])? $data['type'] : null; + $this->sub_type = isset($data['sub_type'])? $data['sub_type'] : null; + $this->index = isset($data['index']) ? $data['index'] : null; + $this->parameters = isset($data['parameters']) ? array_map(function($param) {return new Parameter($param);}, $data['parameters']): []; + validateNotNullAndDataType($this->type, 'component', 'type', 'string', true); + validateNotNullAndDataType($this->sub_type, 'component', 'sub_type', 'string'); + validateNotNullAndDataType($this->index, 'component', 'index', 'string'); + } + +} + +class Template { + public $name; + public $language; + public $components; + + public function __construct(array $data) + { + // Validate the data + $this->name = isset($data['name'])? $data['name'] : null; + $this->language = isset($data['language'])? $data['language'] : null; + $this->components = isset($data['components']) ? array_map(function($component) {return new Component($component);}, $data['components']): []; + validateNotNullAndDataType($this->name, 'template', 'name','string', true); + validateNotNullAndDataType($this->language, 'template', 'language', 'string', true); + } + + + public static function validateTemplate(string $template) + { + try { + if(is_null(json_decode($template, true))) + { + return "Invalid JSON data for template!"; + } + //Validate the JSON data against the Template class + $template = new Template(json_decode($template, true)); + return null; + } catch (PlivoValidationException $e) { + // Handle validation errors here + return $e->getMessage(); + } + } +} diff --git a/src/Plivo/Version.php b/src/Plivo/Version.php index 7bbf0783..be1636d3 100644 --- a/src/Plivo/Version.php +++ b/src/Plivo/Version.php @@ -20,7 +20,7 @@ class Version /** * @const int PHP helper library minor version number */ - const MINOR = 53; + const MINOR = 55; /** * @const int PHP helper library patch number diff --git a/tests/Mocks/messageGetResponse.json b/tests/Mocks/messageGetResponse.json index 26d63d22..616c245d 100644 --- a/tests/Mocks/messageGetResponse.json +++ b/tests/Mocks/messageGetResponse.json @@ -16,5 +16,11 @@ "requester_ip": "192.168.1.1", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "1234", + "dlt_template_id": "5678", + "dlt_template_category": "service_implicit", + "conversation_id": "9876", + "conversation_origin": "utility", + "conversation_expiration_timestamp": "2023-08-03 23:02:00+05:30" } \ No newline at end of file diff --git a/tests/Mocks/messageListResponse.json b/tests/Mocks/messageListResponse.json index b8a9600e..219060f7 100644 --- a/tests/Mocks/messageListResponse.json +++ b/tests/Mocks/messageListResponse.json @@ -23,7 +23,13 @@ "requester_ip": "192.168.1.1", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "9876", + "dlt_template_id": "5432", + "dlt_template_category": "promotional", + "conversation_id": "1234", + "conversation_origin": "service", + "conversation_expiration_timestamp": "2023-08-03 23:02:00+05:30" }, { "error_code": null, @@ -41,7 +47,13 @@ "requester_ip": "192.168.1.2", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -59,7 +71,13 @@ "requester_ip": "192.168.1.3", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -77,7 +95,13 @@ "requester_ip": "192.168.1.4", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -95,7 +119,13 @@ "requester_ip": "192.168.1.5", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -113,7 +143,13 @@ "requester_ip": "192.168.1.6", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -131,7 +167,13 @@ "requester_ip": "192.168.1.7", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -149,7 +191,13 @@ "requester_ip": "192.168.1.8", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -167,7 +215,13 @@ "requester_ip": "192.168.1.9", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -185,7 +239,13 @@ "requester_ip": "192.168.1.10", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -203,7 +263,13 @@ "requester_ip": "192.168.1.11", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -221,7 +287,13 @@ "requester_ip": "192.168.1.12", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -239,7 +311,13 @@ "requester_ip": "192.168.1.13", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -257,7 +335,13 @@ "requester_ip": "192.168.1.14", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -275,7 +359,13 @@ "requester_ip": "192.168.1.15", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": null, @@ -293,7 +383,13 @@ "requester_ip": "192.168.1.16", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -311,7 +407,13 @@ "requester_ip": "192.168.1.17", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -329,7 +431,13 @@ "requester_ip": "192.168.1.18", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -347,7 +455,13 @@ "requester_ip": "192.168.1.19", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" }, { "error_code": "000", @@ -365,7 +479,13 @@ "requester_ip": "192.168.1.20", "is_domestic": false, "destination_country_iso2": "IN", - "replaced_sender": "INSID" + "replaced_sender": "INSID", + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "", + "conversation_id": "", + "conversation_origin": "", + "conversation_expiration_timestamp": "" } ] } \ No newline at end of file diff --git a/tests/Resources/MessageTest.php b/tests/Resources/MessageTest.php index b9fb330b..55dd7e0b 100644 --- a/tests/Resources/MessageTest.php +++ b/tests/Resources/MessageTest.php @@ -76,10 +76,41 @@ public function testnewMessageCreate() self::assertNotNull($actual); } + public function testwhatsappTemplateMessageCreate() + { + $request = new PlivoRequest( + 'POST', + 'Account/MAXXXXXXXXXXXXXXXXXX/Message/', + [ + "dst" => "+919012345678", + "text" => "Test", + "src" => "+919999999999" + ]); + $body = file_get_contents(__DIR__ . '/../Mocks/messageSendResponse.json'); + + $this->mock(new PlivoResponse($request,200, $body)); + + $template = '{ + "name": "hello_world", + "language": "en_US", + "components": null + }'; + + $actual = $this->client->messages->create([ "src" => "+919999999999", "dst" => "+919012345678", "template" =>$template]); + + self::assertNotNull($actual); + } + public function testMessageGet() { $messageUuid = "5b40a428-bfc7-4daf-9d06-726c558bf3b8"; $requesterIP = "192.168.1.1"; + $dltEntityID = "1234"; + $dltTemplateID = "5678"; + $dltTemplateCategory = "service_implicit"; + $conversationID = "9876"; + $conversationOrigin = "utility"; + $conversationExpirationTimestamp = "2023-08-03 23:02:00+05:30"; $request = new PlivoRequest( 'GET', 'Account/MAXXXXXXXXXXXXXXXXXX/Message/'.$messageUuid.'/', @@ -96,6 +127,12 @@ public function testMessageGet() self::assertEquals($actual->messageUuid, $messageUuid); self::assertEquals($actual->requesterIP, $requesterIP); + self::assertEquals($actual->dltEntityID, $dltEntityID); + self::assertEquals($actual->dltTemplateID, $dltTemplateID); + self::assertEquals($actual->dltTemplateCategory, $dltTemplateCategory); + self::assertEquals($actual->conversationID, $conversationID); + self::assertEquals($actual->conversationOrigin, $conversationOrigin); + self::assertEquals($actual->conversationExpirationTimestamp, $conversationExpirationTimestamp); } public function testMessageGetwithPowerpack() @@ -143,6 +180,12 @@ function testMessageList() { $requesterIP1 = "192.168.1.1"; $requesterIP2 = "192.168.1.20"; + $dltEntityID = "9876"; + $dltTemplateID = "5432"; + $dltTemplateCategory = "promotional"; + $conversationID = "1234"; + $conversationOrigin = "service"; + $conversationExpirationTimestamp = "2023-08-03 23:02:00+05:30"; $request = new PlivoRequest( 'Get', 'Account/MAXXXXXXXXXXXXXXXXXX/Message/', @@ -158,6 +201,23 @@ function testMessageList() self::assertNotNull($actual); self::assertEquals($actual->resources[0]->requesterIP, $requesterIP1); self::assertEquals($actual->resources[19]->requesterIP, $requesterIP2); + + self::assertEquals($actual->resources[0]->dltEntityID, $dltEntityID); + self::assertEquals($actual->resources[0]->dltTemplateID, $dltTemplateID); + self::assertEquals($actual->resources[0]->dltTemplateCategory, $dltTemplateCategory); + + self::assertEquals($actual->resources[0]->conversationID, $conversationID); + self::assertEquals($actual->resources[0]->conversationOrigin, $conversationOrigin); + self::assertEquals($actual->resources[0]->conversationExpirationTimestamp, $conversationExpirationTimestamp); + + self::assertObjectNotHasAttribute('dltEntityID', $actual->resources[19]); + self::assertObjectNotHasAttribute('dltTemplateID', $actual->resources[19]); + self::assertObjectNotHasAttribute('dltTemplateCategory', $actual->resources[19]); + + self::assertObjectNotHasAttribute('conversationID', $actual->resources[19]); + self::assertObjectNotHasAttribute('conversationOrigin', $actual->resources[19]); + self::assertObjectNotHasAttribute('conversationExpirationTimestamp', $actual->resources[19]); + } } \ No newline at end of file