Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMS-6010: Add DLT Params to Send and Get Message APIs #323

Merged
merged 3 commits into from
Aug 3, 2023
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [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]

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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" || \
Expand Down
9 changes: 9 additions & 0 deletions src/Plivo/Resources/Message/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,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'];
Expand Down
2 changes: 1 addition & 1 deletion src/Plivo/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Version
/**
* @const int PHP helper library minor version number
*/
const MINOR = 52;
const MINOR = 53;

/**
* @const int PHP helper library patch number
Expand Down
5 changes: 4 additions & 1 deletion tests/Mocks/messageGetResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"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"
}
100 changes: 80 additions & 20 deletions tests/Mocks/messageListResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
"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"
},
{
"error_code": null,
Expand All @@ -41,7 +44,10 @@
"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": ""
},
{
"error_code": null,
Expand All @@ -59,7 +65,10 @@
"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": ""
},
{
"error_code": null,
Expand All @@ -77,7 +86,10 @@
"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": ""
},
{
"error_code": null,
Expand All @@ -95,7 +107,10 @@
"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": ""
},
{
"error_code": null,
Expand All @@ -113,7 +128,10 @@
"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": ""
},
{
"error_code": null,
Expand All @@ -131,7 +149,10 @@
"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": ""
},
{
"error_code": null,
Expand All @@ -149,7 +170,10 @@
"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": ""
},
{
"error_code": "000",
Expand All @@ -167,7 +191,10 @@
"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": ""
},
{
"error_code": null,
Expand All @@ -185,7 +212,10 @@
"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": ""
},
{
"error_code": "000",
Expand All @@ -203,7 +233,10 @@
"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": ""
},
{
"error_code": null,
Expand All @@ -221,7 +254,10 @@
"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": ""
},
{
"error_code": "000",
Expand All @@ -239,7 +275,10 @@
"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": ""
},
{
"error_code": null,
Expand All @@ -257,7 +296,10 @@
"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": ""
},
{
"error_code": "000",
Expand All @@ -275,7 +317,10 @@
"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": ""
},
{
"error_code": null,
Expand All @@ -293,7 +338,10 @@
"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": ""
},
{
"error_code": "000",
Expand All @@ -311,7 +359,10 @@
"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": ""
},
{
"error_code": "000",
Expand All @@ -329,7 +380,10 @@
"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": ""
},
{
"error_code": "000",
Expand All @@ -347,7 +401,10 @@
"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": ""
},
{
"error_code": "000",
Expand All @@ -365,7 +422,10 @@
"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": ""
}
]
}
16 changes: 16 additions & 0 deletions tests/Resources/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public function testMessageGet()
{
$messageUuid = "5b40a428-bfc7-4daf-9d06-726c558bf3b8";
$requesterIP = "192.168.1.1";
$dltEntityID = "1234";
$dltTemplateID = "5678";
$dltTemplateCategory = "service_implicit";
$request = new PlivoRequest(
'GET',
'Account/MAXXXXXXXXXXXXXXXXXX/Message/'.$messageUuid.'/',
Expand All @@ -96,6 +99,9 @@ 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);
}

public function testMessageGetwithPowerpack()
Expand Down Expand Up @@ -143,6 +149,9 @@ function testMessageList()
{
$requesterIP1 = "192.168.1.1";
$requesterIP2 = "192.168.1.20";
$dltEntityID = "9876";
$dltTemplateID = "5432";
$dltTemplateCategory = "promotional";
$request = new PlivoRequest(
'Get',
'Account/MAXXXXXXXXXXXXXXXXXX/Message/',
Expand All @@ -158,6 +167,13 @@ 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::assertObjectNotHasAttribute('dltEntityID', $actual->resources[19]);
self::assertObjectNotHasAttribute('dltTemplateID', $actual->resources[19]);
self::assertObjectNotHasAttribute('dltTemplateCategory', $actual->resources[19]);
}

}
Loading