From a49d1f0031b8844c92236677ab0603951c29f0df Mon Sep 17 00:00:00 2001 From: Mohsin Mamoon Hafiz <84492744+mohsin-plivo@users.noreply.github.com> Date: Thu, 3 Aug 2023 15:36:39 +0530 Subject: [PATCH] SMS-6010: Add DLT Params to Send and Get Message APIs (#178) * SMS-6010: Add DLT Params to Send and Get Message APIs * Version update --- CHANGELOG.md | 5 ++ Makefile | 4 ++ baseclient.go | 2 +- fixtures/messageGetResponse.json | 5 +- fixtures/messageListResponse.json | 100 ++++++++++++++++++++++++------ messages.go | 10 ++- messages_test.go | 17 ++++- 7 files changed, 118 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 179d63c..a43c59c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## [7.34.0](https://github.com/plivo/plivo-go/tree/v7.34.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) + ## [7.33.0](https://github.com/plivo/plivo-go/tree/v7.33.0) (2023-07-31) **Feature - Number Masking** - Added Get, Update and List Masking Session API and modified the Create and Delete API diff --git a/Makefile b/Makefile index 07342a6..8de2b90 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 goSDK) + test: @[ "${CONTAINER}" ] && \ (docker exec -it $$CONTAINER /bin/bash -c "go test -v -race -cover") || \ diff --git a/baseclient.go b/baseclient.go index ee70238..c2a010e 100644 --- a/baseclient.go +++ b/baseclient.go @@ -13,7 +13,7 @@ import ( "github.com/google/go-querystring/query" ) -const sdkVersion = "7.33.0" +const sdkVersion = "7.34.0" const lookupBaseUrl = "lookup.plivo.com" diff --git a/fixtures/messageGetResponse.json b/fixtures/messageGetResponse.json index 4491d69..3516e91 100644 --- a/fixtures/messageGetResponse.json +++ b/fixtures/messageGetResponse.json @@ -13,5 +13,8 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.1", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "1234", + "dlt_template_id": "5678", + "dlt_template_category": "service_implicit" } diff --git a/fixtures/messageListResponse.json b/fixtures/messageListResponse.json index 0582f0a..c781540 100644 --- a/fixtures/messageListResponse.json +++ b/fixtures/messageListResponse.json @@ -21,7 +21,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.1", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "1111", + "dlt_template_id": "2222", + "dlt_template_category": "promotional" }, { "error_code": null, @@ -37,7 +40,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.2", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": null, @@ -53,7 +59,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.3", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": null, @@ -69,7 +78,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.4", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": null, @@ -85,7 +97,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.5", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": null, @@ -101,7 +116,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.6", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": null, @@ -117,7 +135,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.7", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": null, @@ -133,7 +154,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.8", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": "000", @@ -149,7 +173,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.9", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": null, @@ -165,7 +192,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.10", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": "000", @@ -181,7 +211,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.11", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": null, @@ -197,7 +230,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.12", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": "000", @@ -213,7 +249,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.13", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": null, @@ -229,7 +268,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.14", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": "000", @@ -245,7 +287,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.15", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": null, @@ -261,7 +306,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.16", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": "000", @@ -277,7 +325,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.17", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": "000", @@ -293,7 +344,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.18", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": "000", @@ -309,7 +363,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.19", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" }, { "error_code": "000", @@ -325,7 +382,10 @@ "total_rate": "0.00250", "units": 1, "requester_ip": "192.168.1.20", - "is_domestic": false + "is_domestic": false, + "dlt_entity_id": "", + "dlt_template_id": "", + "dlt_template_category": "" } ] } diff --git a/messages.go b/messages.go index 59bbec0..3177466 100644 --- a/messages.go +++ b/messages.go @@ -23,8 +23,11 @@ type MessageCreateParams struct { MediaUrls []string `json:"media_urls,omitempty" url:"media_urls,omitempty"` MediaIds []string `json:"media_ids,omitempty" url:"media_ids,omitempty"` // Either one of src and powerpackuuid should be given - PowerpackUUID string `json:"powerpack_uuid,omitempty" url:"powerpack_uuid,omitempty"` - MessageExpiry int `json:"message_expiry,omitempty" url:"message_expiry,omitempty"` + PowerpackUUID string `json:"powerpack_uuid,omitempty" url:"powerpack_uuid,omitempty"` + MessageExpiry int `json:"message_expiry,omitempty" url:"message_expiry,omitempty"` + DLTEntityID string `json:"dlt_entity_id,omitempty" url:"dlt_entity_id,omitempty"` + DLTTemplateID string `json:"dlt_template_id,omitempty" url:"dlt_template_id,omitempty"` + DLTTemplateCategory string `json:"dlt_template_category,omitempty" url:"dlt_template_category,omitempty"` } type Message struct { @@ -48,6 +51,9 @@ type Message struct { TendlcCampaignID string `json:"tendlc_campaign_id" url:"tendlc_campaign_id,omitempty"` TendlcRegistrationStatus string `json:"tendlc_registration_status" url:"tendlc_registration_status,omitempty"` DestinationCountryISO2 string `json:"destination_country_iso2" url:"destination_country_iso2,omitempty"` + DLTEntityID string `json:"dlt_entity_id" url:"dlt_entity_id,omitempty"` + DLTTemplateID string `json:"dlt_template_id" url:"dlt_template_id,omitempty"` + DLTTemplateCategory string `json:"dlt_template_category" url:"dlt_template_category,omitempty"` } // Stores response for ending a message. diff --git a/messages_test.go b/messages_test.go index ee91b54..ba6b2c3 100644 --- a/messages_test.go +++ b/messages_test.go @@ -12,10 +12,20 @@ func TestMessageService_List(t *testing.T) { resp, err := client.Messages.List(MessageListParams{}) assert.NotNil(resp) assert.Nil(err) + assert.NotNil(resp.Objects) assert.NotEmpty(resp.Objects[0].MessageUUID) + assert.Equal(resp.Objects[0].RequesterIP, "192.168.1.1") assert.Equal(resp.Objects[19].RequesterIP, "192.168.1.20") - assert.NotNil(resp.Objects) + + assert.Equal(resp.Objects[0].DLTEntityID, "1111") + assert.Equal(resp.Objects[0].DLTTemplateID, "2222") + assert.Equal(resp.Objects[0].DLTTemplateCategory, "promotional") + + assert.Equal(resp.Objects[19].DLTEntityID, "") + assert.Equal(resp.Objects[19].DLTTemplateID, "") + assert.Equal(resp.Objects[19].DLTTemplateCategory, "") + assert.NotNil(resp.Meta) cl := client.httpClient client.httpClient = nil @@ -35,6 +45,11 @@ func TestMessageService_Get(t *testing.T) { assert.Nil(err) assert.Equal(resp.MessageUUID, uuid) assert.Equal(resp.RequesterIP, "192.168.1.1") + + assert.Equal(resp.DLTEntityID, "1234") + assert.Equal(resp.DLTTemplateID, "5678") + assert.Equal(resp.DLTTemplateCategory, "service_implicit") + cl := client.httpClient client.httpClient = nil resp, err = client.Messages.Get(uuid)