Skip to content

Commit

Permalink
SMS-6010: Add DLT Params to Send and Get Message APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsin-plivo committed Jul 11, 2023
1 parent 989f83c commit ecef0fd
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 24 deletions.
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 goSDK)

test:
@[ "${CONTAINER}" ] && \
(docker exec -it $$CONTAINER /bin/bash -c "go test -v -race -cover") || \
Expand Down
5 changes: 4 additions & 1 deletion fixtures/messageGetResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
100 changes: 80 additions & 20 deletions fixtures/messageListResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": null,
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": null,
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": null,
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": null,
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": null,
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": null,
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": "000",
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": null,
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": "000",
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": null,
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": "000",
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": null,
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": "000",
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": null,
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": "000",
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": "000",
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": "000",
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
},
{
"error_code": "000",
Expand All @@ -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": null,
"dlt_template_id": null,
"dlt_template_category": null
}
]
}
10 changes: 8 additions & 2 deletions messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down
17 changes: 16 additions & 1 deletion messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit ecef0fd

Please sign in to comment.