From fa6eed3197b7abc03d64500a49ff021f25862380 Mon Sep 17 00:00:00 2001 From: mohsin-plivo Date: Tue, 11 Jul 2023 11:46:45 +0530 Subject: [PATCH 1/2] SMS-6010: Add DLT parameters to APIs --- lib/plivo/resources/messages.rb | 38 ++++++++++- spec/mocks/messageGetResponse.json | 5 +- spec/mocks/messageListResponse.json | 100 ++++++++++++++++++++++------ spec/resource_messages_spec.rb | 16 ++++- 4 files changed, 136 insertions(+), 23 deletions(-) diff --git a/lib/plivo/resources/messages.rb b/lib/plivo/resources/messages.rb index fbbd7f07..86df5c43 100644 --- a/lib/plivo/resources/messages.rb +++ b/lib/plivo/resources/messages.rb @@ -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 @@ -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 @@ -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) @@ -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 diff --git a/spec/mocks/messageGetResponse.json b/spec/mocks/messageGetResponse.json index a1a83461..1c158326 100644 --- a/spec/mocks/messageGetResponse.json +++ b/spec/mocks/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" } \ No newline at end of file diff --git a/spec/mocks/messageListResponse.json b/spec/mocks/messageListResponse.json index b0edf244..5bf2ddeb 100644 --- a/spec/mocks/messageListResponse.json +++ b/spec/mocks/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": "1245", + "dlt_template_id": "9585", + "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": "" } ] } \ No newline at end of file diff --git a/spec/resource_messages_spec.rb b/spec/resource_messages_spec.rb index d3324e15..1cb5b3cf 100644 --- a/spec/resource_messages_spec.rb +++ b/spec/resource_messages_spec.rb @@ -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 @@ -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 @@ -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 From b8b2396a3876e29a72c5398a667f91297bf09757 Mon Sep 17 00:00:00 2001 From: mohsin-plivo Date: Thu, 3 Aug 2023 15:22:14 +0530 Subject: [PATCH 2/2] Version update --- CHANGELOG.md | 7 ++++++- Makefile | 4 ++++ README.md | 2 +- lib/plivo/version.rb | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f72dac0..0b391807 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Makefile b/Makefile index e31e4f09..c3464bf9 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 rubySDK) + test: @[ "${CONTAINER}" ] && \ docker exec -it $$CONTAINER /bin/bash -c "bundle exec rake" || \ diff --git a/README.md b/README.md index 38a7c908..36271fb2 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/lib/plivo/version.rb b/lib/plivo/version.rb index ad82ace8..4a68d5cc 100644 --- a/lib/plivo/version.rb +++ b/lib/plivo/version.rb @@ -1,3 +1,3 @@ module Plivo - VERSION = "4.46.0".freeze + VERSION = "4.47.0".freeze end