Skip to content

Commit

Permalink
Merge pull request #221 from plivo/SMS-6010
Browse files Browse the repository at this point in the history
SMS-6010: Add DLT parameters to APIs
  • Loading branch information
renoldthomas-plivo authored Aug 3, 2023
2 parents af1a0b5 + b8b2396 commit 1190383
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 26 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Change Log

## [4.46.0](https://github.com/plivo/plivo-go/tree/v4.46.0) (2023-06-28)
## [4.47.0](https://github.com/plivo/plivo-ruby/tree/v4.47.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.46.0](https://github.com/plivo/plivo-ruby/tree/v4.46.0) (2023-06-28)
**Feature - Audio Streaming**
- Added functionality to start, stop and fetch audio streams
- Added functionality to create stream XML
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 rubySDK)

test:
@[ "${CONTAINER}" ] && \
docker exec -it $$CONTAINER /bin/bash -c "bundle exec rake" || \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The Plivo Ruby SDK makes it simpler to integrate communications into your Ruby a
Add this line to your application's Gemfile:

```ruby
gem 'plivo', '>= 4.46.0'
gem 'plivo', '>= 4.47.0'
```

And then execute:
Expand Down
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
2 changes: 1 addition & 1 deletion lib/plivo/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Plivo
VERSION = "4.46.0".freeze
VERSION = "4.47.0".freeze
end
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

0 comments on commit 1190383

Please sign in to comment.