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 parameters to APIs #221

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
38 changes: 37 additions & 1 deletion lib/plivo/resources/messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def to_s
tendlc_registration_status: @tendlc_registration_status,
requester_ip: @requester_ip,
is_domestic: @is_domestic,
replaced_sender: @replaced_sender
replaced_sender: @replaced_sender,
dlt_entity_id: @dlt_entity_id,
dlt_template_id: @dlt_template_id,
dlt_template_category: @dlt_template_category
}.to_s
end
end
Expand Down Expand Up @@ -78,6 +81,9 @@ def get(message_uuid)
# @option options[Int]: message_expiry, int value
# @option options[List]: media_urls Minimum one media url should be present in Media urls list to send mms. Maximum allowd 10 media urls inside the list (e.g, media_urls : ['https//example.com/test.jpg', 'https://example.com/abcd.gif'])
# @option options[List]: media_ids Minimum one media ids should be present in Media ids list to send mms. Maximum allowd 10 media ids inside the list (e.g, media_ids : ['1fs211ba-355b-11ea-bbc9-02121c1190q7'])
# @option options [String] :dlt_entity_id This is the DLT entity id passed in the message request.
# @option options [String] :dlt_template_id This is the DLT template id passed in the message request.
# @option options [String] :dlt_template_category This is the DLT template category passed in the message request.

def create(src = nil, dst = nil, text = nil, options = nil, powerpack_uuid = nil)
#All params in One HASH
Expand Down Expand Up @@ -158,6 +164,21 @@ def create(src = nil, dst = nil, text = nil, options = nil, powerpack_uuid = nil
params[:media_ids] = value[:media_ids]
end

if value.key?(:dlt_entity_id) &&
valid_param?(:dlt_entity_id, value[:dlt_entity_id], String, true)
params[:dlt_entity_id] = value[:dlt_entity_id]
end

if value.key?(:dlt_template_id) &&
valid_param?(:dlt_template_id, value[:dlt_template_id], String, true)
params[:dlt_template_id] = value[:dlt_template_id]
end

if value.key?(:dlt_template_category) &&
valid_param?(:dlt_template_category, value[:dlt_template_category], String, true)
params[:dlt_template_category] = value[:dlt_template_category]
end

#legacy code compatibility
else
valid_param?(:src, src, [Integer, String, Symbol], false)
Expand Down Expand Up @@ -247,6 +268,21 @@ def create(src = nil, dst = nil, text = nil, options = nil, powerpack_uuid = nil
valid_param?(:trackable, options[:trackable], [TrueClass, FalseClass], true)
params[:trackable] = options[:trackable]
end

if options.key?(:dlt_entity_id) &&
valid_param?(:dlt_entity_id, options[:dlt_entity_id], String, true)
params[:dlt_entity_id] = options[:dlt_entity_id]
end

if options.key?(:dlt_template_id) &&
valid_param?(:dlt_template_id, options[:dlt_template_id], String, true)
params[:dlt_template_id] = options[:dlt_template_id]
end

if options.key?(:dlt_template_category) &&
valid_param?(:dlt_template_category, options[:dlt_template_category], String, true)
params[:dlt_template_category] = options[:dlt_template_category]
end
end
perform_create(params)
end
Expand Down
5 changes: 4 additions & 1 deletion spec/mocks/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 spec/mocks/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": "1245",
"dlt_template_id": "9585",
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
},
{
"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": "",
"dlt_template_id": "",
"dlt_template_category": ""
}
]
}
16 changes: 15 additions & 1 deletion spec/resource_messages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def to_json(message)
total_rate: message.total_rate,
units: message.units,
requester_ip: message.requester_ip,
is_domestic: message.is_domestic
is_domestic: message.is_domestic,
dlt_entity_id: message.dlt_entity_id,
dlt_template_id: message.dlt_template_id,
dlt_template_category: message.dlt_template_category
}.to_json
end

Expand Down Expand Up @@ -76,6 +79,9 @@ def to_json_list(list_object)
data: nil)
expect(response.id).to eql(response.message_uuid)
expect(response.requester_ip).to eql("192.168.1.1")
expect(response.dlt_entity_id).to eql("1234")
expect(response.dlt_template_id).to eql("5678")
expect(response.dlt_template_category).to eql("service_implicit")
end

it 'lists all mms media' do
Expand Down Expand Up @@ -120,6 +126,14 @@ def to_json_list(list_object)
})
expect(JSON.parse(response)['objects'][0]['requester_ip']). to eql("192.168.1.1")
expect(JSON.parse(response)['objects'][19]['requester_ip']). to eql("192.168.1.20")

expect(JSON.parse(response)['objects'][0]["dlt_entity_id"]).to eql("1245")
expect(JSON.parse(response)['objects'][0]["dlt_template_id"]).to eql("9585")
expect(JSON.parse(response)['objects'][0]["dlt_template_category"]).to eql("promotional")

expect(JSON.parse(response)['objects'][19]["dlt_entity_id"]).to eql("")
expect(JSON.parse(response)['objects'][19]["dlt_template_id"]).to eql("")
expect(JSON.parse(response)['objects'][19]["dlt_template_category"]).to eql("")
end

it 'sends a message' do
Expand Down