plivo 4.20.0 → 4.24.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6472d23802b39086fb94ce313553e668bd3f210b
4
- data.tar.gz: b620b7efeb18cbd2680d5701ba1054e23a0e3874
3
+ metadata.gz: 15f859f3b8d4d5c86051c7707f7a0b3519bbccc6
4
+ data.tar.gz: 4058af2b93014f1552e30cae972e7f3a30bc4b3b
5
5
  SHA512:
6
- metadata.gz: c5bbacc139403864cf9ee636063d8eb9717a9b8b175a4265d08cdaa85c3813f678a97573940a2c8d90c15d364c535578932331b817b7278f96c0ccdaa6c81f2b
7
- data.tar.gz: a2ec84374d288f88cba292e667193810f51c6565be8c5457ee8deb952eb1c6f160f62205fb5d85532dc0d542c3880fe4552d79eb20c63bf0afa0e97bf3c648ac
6
+ metadata.gz: f14e5c137e14abb3775c6aca039e03ec3027688500ea265c33dcb9c3b2bd861b186f19694449f7f758de6632a8ab6cda90844ab424ee219507d7047cdd178647
7
+ data.tar.gz: a91d7d11cda391bfc9d5079b2d5ea1d233cdf82c2cb2c7083c33cafb8e9be28d2bdafb59c8671a698b24728efe4a35e001087ee7a43ea7bf7ec172e0b8e43236
@@ -0,0 +1,32 @@
1
+ name: UnitTest
2
+
3
+ on:
4
+ push:
5
+ branches: [ unitTests ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ build:
11
+ name: UnitTest
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: [ '2.4', '2.5', '2.6' ,'2.7', '3.0' ]
16
+
17
+ steps:
18
+ - name: Checkout
19
+ uses: actions/checkout@v2
20
+ - name: Set up Ruby ${{ matrix.ruby-version }}
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ - name: Dependencies Installation
25
+ run: |
26
+ bundle install --without development
27
+ - name: Run Tests
28
+ run: |
29
+ ruby --version
30
+ bundle exec rake
31
+ rm Gemfile.lock
32
+
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Change Log
2
2
 
3
+ ## [4.24.0](https://github.com/plivo/plivo-ruby/tree/v4.24.0) (2021-12-14)
4
+ **Features - Voice**
5
+ - Routing SDK traffic through Akamai endpoints for all the [Voice APIs](https://www.plivo.com/docs/voice/api/overview/)
6
+
7
+ ## [4.23.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.23.0) (2021-12-02)
8
+ **Features - Messaging: 10 DLC**
9
+ - 10DLC API's for brand and campaign support.
10
+
11
+ ## [4.22.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.22.0) (2021-11-11)
12
+ **Features - Voice: Multiparty call**
13
+ - The [Add Multiparty Call API](https://www.plivo.com/docs/voice/api/multiparty-call/participants#add-a-participant) allows for greater functionality by accepting options like `start recording audio`, `stop recording audio`, and their HTTP methods.
14
+ - [Multiparty Calls](https://www.plivo.com/docs/voice/api/multiparty-call/) now has new APIs to `stop` and `play` audio.
15
+
16
+ ## [4.21.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.21.0) (2021-10-11)
17
+ **Features - Messaging**
18
+ - This version includes advancements to the Messaging Interface that deals with the [Send SMS/MMS](https://www.plivo.com/docs/sms/api/message#send-a-message) interface, Creating a standard structure for `request/input` arguments to make implementation easier and incorporating support for the older interface.
19
+
20
+ Example for [send SMS](https://github.com/plivo/plivo-ruby#send-a-message)
21
+
3
22
  ## [4.20.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.20.0) (2021-08-04)
4
23
  - Added continue speak XML element support.
5
24
 
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ group :test do
7
7
  gem 'rspec', '~> 3.0'
8
8
  gem 'simplecov'
9
9
  gem 'json'
10
+ gem 'rexml'
10
11
  end
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # plivo-ruby
2
2
 
3
- [![Build Status](https://travis-ci.org/plivo/plivo-ruby.svg?branch=4.0)](https://travis-ci.org/plivo/plivo-ruby)
3
+ [![UnitTest](https://github.com/plivo/plivo-ruby/actions/workflows/unitTests.yml/badge.svg?branch=ns-ut-fix)](https://github.com/plivo/plivo-ruby/actions/workflows/unitTests.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/plivo.svg)](https://badge.fury.io/rb/plivo)
4
5
 
5
6
  The Plivo Ruby SDK makes it simpler to integrate communications into your Ruby applications using the Plivo REST API. Using the SDK, you will be able to make voice calls, send SMS and generate Plivo XML to control your call flows.
6
7
 
@@ -8,7 +9,7 @@ The Plivo Ruby SDK makes it simpler to integrate communications into your Ruby a
8
9
  Add this line to your application's Gemfile:
9
10
 
10
11
  ```ruby
11
- gem 'plivo', '>= 4.20.0'
12
+ gem 'plivo', '>= 4.24.0'
12
13
  ```
13
14
 
14
15
  And then execute:
@@ -39,7 +40,7 @@ client = RestClient.new;
39
40
  Alternatively, you can specifiy the authentication credentials while initializing the `RestClient`.
40
41
 
41
42
  ```ruby
42
- client = RestClient.new('your_auth_id', 'your_auth_token');
43
+ client = RestClient.new('<auth_id>', '<auth_token>');
43
44
  ```
44
45
 
45
46
  ### The basics
@@ -76,17 +77,15 @@ end
76
77
  ### Send a message
77
78
 
78
79
  ```ruby
79
- require 'rubygems'
80
- require 'plivo'
81
-
80
+ require "plivo"
82
81
  include Plivo
83
82
 
84
83
  client = RestClient.new
85
- message_created = client.messages.create(
86
- 'your_source_number',
87
- %w[your_destination_number_1 your_destination_number_2],
88
- 'Hello, world!'
89
- )
84
+ response = client.messages.create(
85
+ src: '+14156667778',
86
+ dst: '+14156667777',
87
+ text: 'Hello, this is a sample text'
88
+ )
90
89
  ```
91
90
 
92
91
  ### Make a call
@@ -99,8 +98,8 @@ include Plivo
99
98
 
100
99
  client = RestClient.new
101
100
  call_made = client.calls.create(
102
- 'your_source_number',
103
- ['your_destination_number'],
101
+ '+14156667778',
102
+ ['+14156667777'],
104
103
  'https://answer.url'
105
104
  )
106
105
  ```
@@ -149,10 +148,7 @@ require 'plivo'
149
148
 
150
149
  include Plivo
151
150
 
152
- AUTH_ID = 'AUTH_ID'
153
- AUTH_TOKEN = 'AUTH_TOKEN'
154
-
155
- client = Phlo.new(AUTH_ID, AUTH_TOKEN)
151
+ client = Phlo.new('<auth_id>', '<auth_token>')
156
152
 
157
153
  # if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
158
154
  # then initialize client as:
@@ -162,8 +158,8 @@ client = Phlo.new(AUTH_ID, AUTH_TOKEN)
162
158
  begin
163
159
  #parameters set in PHLO - params
164
160
  params = {
165
- from: '9999999999',
166
- to: '0000000000'
161
+ from: '+14156667778',
162
+ to: '+14156667777'
167
163
  }
168
164
  response = phlo.run(params)
169
165
  puts response
@@ -173,7 +169,7 @@ begin
173
169
  ```
174
170
 
175
171
  ### More examples
176
- Refer to the [Ruby API Reference](https://api-reference.plivo.com/latest/ruby/introduction/overview) for more examples. Also refer to the [guide to setting up dev environment](https://developers.plivo.com/getting-started/setting-up-dev-environment/) on [Plivo Developers Portal](https://developers.plivo.com) to setup a Sinatra server & use it to test out your integration in under 5 minutes.
172
+ More examples are available [here](https://github.com/plivo/plivo-examples-ruby). Also refer to the [guides for configuring the Rails server to run various scenarios](https://www.plivo.com/docs/sms/quickstart/ruby-rails/) & use it to test out your integration in under 5 minutes.
177
173
 
178
174
  ## Reporting issues
179
175
  Report any feedback or problems with this version by [opening an issue on Github](https://github.com/plivo/plivo-ruby/issues).
data/lib/plivo/base.rb CHANGED
@@ -6,9 +6,9 @@ module Plivo
6
6
  module Base
7
7
  PLIVO_API_URL = 'https://api.plivo.com'.freeze
8
8
 
9
- API_VOICE = 'https://voice.plivo.com'.freeze
10
- API_VOICE_FALLBACK_1 = 'https://voice-usw1.plivo.com'.freeze
11
- API_VOICE_FALLBACK_2 = 'https://voice-use1.plivo.com'.freeze
9
+ API_VOICE = 'https://api.plivo.com'.freeze
10
+ API_VOICE_FALLBACK_1 = 'https://api.plivo.com'.freeze
11
+ API_VOICE_FALLBACK_2 = 'https://api.plivo.com'.freeze
12
12
 
13
13
  CALLINSIGHTS_API_URL = 'https://stats.plivo.com'.freeze
14
14
  PHLO_API_URL = 'https://phlorunner.plivo.com'.freeze
@@ -0,0 +1,62 @@
1
+ module Plivo
2
+ module Resources
3
+ include Plivo::Utils
4
+ class Brand < Base::Resource
5
+ def initialize(client, options = nil)
6
+ @_name = '10dlc/Brand'
7
+ @_identifier_string = 'brand_id'
8
+ super
9
+ end
10
+
11
+ def to_s
12
+ {
13
+ api_id: @api_id,
14
+ brand: @brand
15
+ }.to_s
16
+ end
17
+ end
18
+
19
+ class BrandInterface < Base::ResourceInterface
20
+ def initialize(client, resource_list_json = nil)
21
+ @_name = '10dlc/Brand'
22
+ @_resource_type = Brand
23
+ @_identifier_string = 'brand_id'
24
+ super
25
+ end
26
+
27
+ ##
28
+ # Get an Brand
29
+ # @param [String] brand_id
30
+ # @return [Brand] Brand
31
+ def get(brand_id)
32
+ valid_param?(:brand_id, brand_id, [String, Symbol], true)
33
+ perform_get(brand_id)
34
+ end
35
+
36
+ ##
37
+ # List all Brand
38
+ # @param [Hash] options
39
+ # @option options [String] :type
40
+ # @option options [Status] :status
41
+ # @return [Hash]
42
+ def list(options=nil)
43
+ return perform_list_without_object if options.nil?
44
+
45
+ params = {}
46
+ %i[status type].each do |param|
47
+ if options.key?(param) && valid_param?(param, options[param],
48
+ [String], true)
49
+ params[param] = options[param]
50
+ end
51
+ end
52
+ perform_list_without_object(params)
53
+ end
54
+
55
+ ##
56
+ # Create a new brand
57
+ def create(params)
58
+ perform_create(params)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,62 @@
1
+ module Plivo
2
+ module Resources
3
+ include Plivo::Utils
4
+ class Campaign < Base::Resource
5
+ def initialize(client, options = nil)
6
+ @_name = '10dlc/Campaign'
7
+ @_identifier_string = 'campaign_id'
8
+ super
9
+ end
10
+
11
+ def to_s
12
+ {
13
+ api_id: @api_id,
14
+ campaign: @campaign
15
+ }.to_s
16
+ end
17
+ end
18
+
19
+ class CampaignInterface < Base::ResourceInterface
20
+ def initialize(client, resource_list_json = nil)
21
+ @_name = '10dlc/Campaign'
22
+ @_resource_type = Campaign
23
+ @_identifier_string = 'campaign_id'
24
+ super
25
+ end
26
+
27
+ ##
28
+ # Get an Campaign
29
+ # @param [String] campaign_id
30
+ # @return [Campaign] Campaign
31
+ def get(campaign_id)
32
+ valid_param?(:campaign_id, campaign_id, [String, Symbol], true)
33
+ perform_get(campaign_id)
34
+ end
35
+
36
+ ##
37
+ # List all Campaign
38
+ # @param [Hash] options
39
+ # @option options [String] :brand
40
+ # @option options [Status] :usecase
41
+ # @return [Hash]
42
+ def list(options=nil)
43
+ return perform_list_without_object if options.nil?
44
+
45
+ params = {}
46
+ %i[usecase brand].each do |param|
47
+ if options.key?(param) && valid_param?(param, options[param],
48
+ [String], true)
49
+ params[param] = options[param]
50
+ end
51
+ end
52
+ perform_list_without_object(params)
53
+ end
54
+
55
+ ##
56
+ # Create a new Camapign
57
+ def create(params)
58
+ perform_create(params)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -69,72 +69,160 @@ module Plivo
69
69
  # @option options [String] :method The method used to call the url. Defaults to POST.
70
70
  # @option options [String] :log If set to false, the content of this message will not be logged on the Plivo infrastructure and the dst value will be masked (e.g., 141XXXXX528). Default is set to true.
71
71
  # @option options [String] :trackable set to false
72
- #@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'])
73
- #@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'])
74
-
75
- def create(src, dst, text = nil, options = nil, powerpack_uuid = nil)
76
- valid_param?(:src, src, [Integer, String, Symbol], false)
77
- valid_param?(:text, text, [String, Symbol], false)
78
- valid_param?(:dst, dst, Array, true)
79
- valid_param?(:powerpack_uuid, powerpack_uuid, [String, Symbol], false)
80
- dst.each do |dst_num|
81
- valid_param?(:dst_num, dst_num, [Integer, String, Symbol], true)
82
- end
72
+ # @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'])
73
+ # @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'])
74
+
75
+ def create(src = nil, dst = nil, text = nil, options = nil, powerpack_uuid = nil)
76
+ #All params in One HASH
77
+ value = src
78
+ if(value.is_a?(Hash))
79
+ valid_param?(:src, value[:src], [Integer, String, Symbol], false)
80
+ valid_param?(:text, value[:text], [String, Symbol], true)
81
+ valid_param?(:dst, value[:dst], [String, Array], true)
82
+ valid_param?(:powerpack_uuid, value[:powerpack_uuid], [String, Symbol], false)
83
83
 
84
- if dst.include? src
85
- raise InvalidRequestError, 'src and dst cannot be same'
86
- end
84
+ if (value[:dst] == value[:src])
85
+ raise InvalidRequestError, 'src and dst cannot be same'
86
+ end
87
87
 
88
- if src.nil? && powerpack_uuid.nil?
89
- raise InvalidRequestError, 'src and powerpack uuid both cannot be nil'
90
- end
88
+ if value.key?(:value).nil? && value.key(:powerpack_uuid).nil?
89
+ raise InvalidRequestError, 'value and powerpack uuid both cannot be nil'
90
+ end
91
91
 
92
- if !src.nil? && !powerpack_uuid.nil?
93
- raise InvalidRequestError, 'src and powerpack uuid both cannot be present'
94
- end
92
+ if !value.key?(:value).nil? && !value.key(:powerpack_uuid).nil?
93
+ raise InvalidRequestError, 'value and powerpack uuid both cannot be present'
94
+ end
95
95
 
96
- params = {
97
- src: src,
98
- dst: dst.join('<'),
99
- text: text,
100
- powerpack_uuid: powerpack_uuid
101
- }
96
+ if !value.key?(:dst).nil? && !value.key(:powerpack_uuid).nil?
97
+ raise InvalidRequestError, 'dst is a required parameter'
98
+ end
102
99
 
103
- return perform_create(params) if options.nil?
104
- valid_param?(:options, options, Hash, true)
100
+ params = {
101
+ src: value[:src],
102
+ dst: value[:dst],
103
+ text: value[:text],
104
+ powerpack_uuid: value[:powerpack_uuid]
105
+ }
105
106
 
106
- if options.key?(:type) &&
107
- valid_param?(:type, options[:type], String, true, ['sms', 'mms'])
108
- params[:type] = options[:type]
109
- end
107
+ #Handling optional params in One HASH
108
+ if value.key?(:type) && valid_param?(:type, value[:type],String, true, %w[sms mms])
109
+ params[:type] = value[:type]
110
+ end
111
+
112
+ if value.key?(:url) && valid_param?(:url, value[:url], String, true)
113
+ params[:url] = value[:url]
114
+ if value.key?(:method) &&
115
+ valid_param?(:method, value[:method], String, true, %w[POST GET])
116
+ params[:method] = value[:method]
117
+ else
118
+ params[:method] = 'POST'
119
+ end
120
+ end
121
+
122
+ if value.key?(:log) &&
123
+ valid_param?(:log, value[:log], [TrueClass, FalseClass], true)
124
+ params[:log] = value[:log]
125
+ end
126
+
127
+ if value.key?(:trackable) &&
128
+ valid_param?(:trackable, value[:trackable], [TrueClass, FalseClass], true)
129
+ params[:trackable] = value[:trackable]
130
+ end
131
+
132
+ if value.key?(:media_urls) &&
133
+ valid_param?(:media_urls, value[:media_urls], Array, true)
134
+ params[:media_urls] = value[:media_urls]
135
+ end
136
+
137
+ if value.key?(:media_ids) &&
138
+ valid_param?(:media_ids, value[:media_ids], Array, true)
139
+ params[:media_ids] = value[:media_ids]
140
+ end
141
+
142
+ #legacy code compatibility
143
+ else
144
+ valid_param?(:src, src, [Integer, String, Symbol], false)
145
+ valid_param?(:text, text, [String, Symbol], true)
146
+ valid_param?(:dst, dst, [String, Array], true)
147
+ valid_param?(:powerpack_uuid, powerpack_uuid, [String, Symbol], false)
148
+ dst.each do |dst_num|
149
+ valid_param?(:dst_num, dst_num, [Integer, String, Symbol], true)
150
+ end
151
+
152
+ if dst.include? src
153
+ raise InvalidRequestError, 'src and dst cannot be same'
154
+ end
110
155
 
111
- if options.key?(:url) && valid_param?(:url, options[:url], String, true)
112
- params[:url] = options[:url]
113
- if options.key?(:method) &&
114
- valid_param?(:method, options[:method], String, true, %w[POST GET])
115
- params[:method] = options[:method]
156
+ if src.nil? && powerpack_uuid.nil?
157
+ raise InvalidRequestError, 'src and powerpack uuid both cannot be nil'
158
+ end
159
+
160
+ if !src.nil? && !powerpack_uuid.nil?
161
+ raise InvalidRequestError, 'src and powerpack uuid both cannot be present'
162
+ end
163
+
164
+ params = {
165
+ src: src,
166
+ text: text,
167
+ powerpack_uuid: powerpack_uuid
168
+ }
169
+
170
+ if (dst.is_a?(Array))
171
+ dst.each do |dst_num|
172
+ valid_param?(:dst_num, dst_num, [Integer, String, Symbol], true)
173
+ params[:dst] = dst.join('<')
174
+ end
116
175
  else
117
- params[:method] = 'POST'
176
+ params[:dst] = dst
118
177
  end
119
- end
120
178
 
121
- if options.key?(:log) &&
122
- valid_param?(:log, options[:log], [TrueClass, FalseClass], true)
123
- params[:log] = options[:log]
124
- end
179
+ return perform_create(params) if options.nil?
180
+ valid_param?(:options, options, Hash, true)
125
181
 
126
- if options.key?(:trackable) &&
127
- valid_param?(:trackable, options[:trackable], [TrueClass, FalseClass], true)
128
- params[:trackable] = options[:trackable]
129
- end
182
+ if options.key?(:type) &&
183
+ valid_param?(:type, options[:type], String, true, %w[sms mms])
184
+ params[:type] = options[:type]
185
+ end
130
186
 
131
- if options.key?(:media_urls) &&
132
- valid_param?(:media_urls, options[:media_urls], Array, true)
133
- params[:media_urls] = options[:media_urls]
134
- end
135
- if options.key?(:media_ids) &&
136
- valid_param?(:media_ids, options[:media_ids], Array, true)
137
- params[:media_ids] = options[:media_ids]
187
+ if options.key?(:url) && valid_param?(:url, options[:url], String, true)
188
+ params[:url] = options[:url]
189
+ if options.key?(:method) &&
190
+ valid_param?(:method, options[:method], String, true, %w[POST GET])
191
+ params[:method] = options[:method]
192
+ else
193
+ params[:method] = 'POST'
194
+ end
195
+ end
196
+
197
+ if options.key?(:media_urls) &&
198
+ valid_param?(:media_urls, options[:media_urls], Array, true)
199
+ params[:media_urls] = options[:media_urls]
200
+ end
201
+
202
+ if options.key?(:media_ids) &&
203
+ valid_param?(:media_ids, options[:media_ids], Array, true)
204
+ params[:media_ids] = options[:media_ids]
205
+ end
206
+
207
+ if options.key?(:log) &&
208
+ valid_param?(:log, options[:log], [TrueClass, FalseClass], true)
209
+ params[:log] = options[:log]
210
+ end
211
+
212
+ if options.key?(:media_urls) &&
213
+ valid_param?(:media_urls, options[:media_urls], Array, true)
214
+ params[:media_urls] = options[:media_urls]
215
+ end
216
+
217
+ if options.key?(:media_ids) &&
218
+ valid_param?(:media_ids, options[:media_ids], Array, true)
219
+ params[:media_ids] = options[:media_ids]
220
+ end
221
+
222
+ if options.key?(:trackable) &&
223
+ valid_param?(:trackable, options[:trackable], [TrueClass, FalseClass], true)
224
+ params[:trackable] = options[:trackable]
225
+ end
138
226
  end
139
227
  perform_create(params)
140
228
  end
@@ -153,7 +241,9 @@ module Plivo
153
241
  # @option options [Int] :limit Used to display the number of results per page. The maximum number of results that can be fetched is 20.
154
242
  # @option options [Int] :offset Denotes the number of value items by which the results should be offset. Eg:- If the result contains a 1000 values and limit is set to 10 and offset is set to 705, then values 706 through 715 are displayed in the results. This parameter is also used for pagination of the results.
155
243
  # @option options [String] :error_code Delivery Response code returned by the carrier attempting the delivery. See Supported error codes {https://www.plivo.com/docs/api/message/#standard-plivo-error-codes}.
156
- # @option options [String] :powerpack_id Filter the results by powerpack id.
244
+ # @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'])
245
+ # @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'])
246
+ # @option options [String] :powerpack_id Filter the results by powerpack id
157
247
  def list(options = nil)
158
248
  return perform_list if options.nil?
159
249
  valid_param?(:options, options, Hash, true)
@@ -60,7 +60,11 @@ module Plivo
60
60
  enter_sound='beep:1',
61
61
  enter_sound_method='GET',
62
62
  exit_sound='beep:2',
63
- exit_sound_method='GET')
63
+ exit_sound_method='GET',
64
+ start_recording_audio=nil,
65
+ start_recording_audio_method='GET',
66
+ stop_recording_audio=nil,
67
+ stop_recording_audio_method='GET')
64
68
  if (from and to) and call_uuid
65
69
  raise_invalid_request('cannot specify call_uuid when (from, to) is provided')
66
70
  end
@@ -117,6 +121,10 @@ module Plivo
117
121
  valid_param?(:enter_sound_method, enter_sound_method.upcase, String, false, %w[GET POST])
118
122
  is_one_among_string_url?(:exit_sound, exit_sound, false , %w[beep:1 beep:2 none])
119
123
  valid_param?(:exit_sound_method, exit_sound_method.upcase, String, false, %w[GET POST])
124
+ valid_param?(:start_recording_audio_method, start_recording_audio_method.upcase, String, false, %w[GET POST])
125
+ valid_url?(:start_recording_audio, start_recording_audio, false ) unless start_recording_audio.nil?
126
+ valid_param?(:stop_recording_audio_method, stop_recording_audio_method.upcase, String, false, %w[GET POST])
127
+ valid_url?(:stop_recording_audio, stop_recording_audio, false ) unless stop_recording_audio.nil?
120
128
  if (to!=nil) && (ring_timeout.is_a?(String)) && (to.split('<').size < ring_timeout.split('<').size)
121
129
  raise_invalid_request("RingTimeout:number of ring_timout(s) should be same as number of destination(s)")
122
130
  end
@@ -168,6 +176,10 @@ module Plivo
168
176
  params[:enter_sound_method] = enter_sound_method.upcase unless exit_sound_method.nil?
169
177
  params[:exit_sound] = exit_sound unless exit_sound.nil?
170
178
  params[:exit_sound_method] = exit_sound_method.upcase unless exit_sound_method.nil?
179
+ params[:start_recording_audio] = start_recording_audio unless start_recording_audio.nil?
180
+ params[:start_recording_audio_method] = start_recording_audio_method.upcase unless start_recording_audio_method.nil?
181
+ params[:stop_recording_audio] = stop_recording_audio unless stop_recording_audio.nil?
182
+ params[:stop_recording_audio_method] = stop_recording_audio_method.upcase unless stop_recording_audio_method.nil?
171
183
  perform_action_apiresponse('Participant', 'POST', params, true )
172
184
  end
173
185
 
@@ -204,7 +216,6 @@ module Plivo
204
216
  perform_action_apiresponse('Record/Resume', 'POST')
205
217
  end
206
218
 
207
-
208
219
  def start_participant_recording(member_id, file_format='mp3', status_callback_url=nil, status_callback_method='POST')
209
220
  valid_param?(:member_id, member_id, [String, Integer], true)
210
221
  MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], member_id: member_id).start_participant_recording(file_format, status_callback_url, status_callback_method)
@@ -246,6 +257,17 @@ module Plivo
246
257
  valid_param?(:member_id, member_id, [String, Integer], true)
247
258
  MultiPartyCallParticipant.new(@_client,resource_id: @id, member_id: member_id).get_participant
248
259
  end
260
+
261
+ def start_play_audio(member_id, url)
262
+ valid_param?(:member_id, member_id, [String, Integer], true)
263
+ valid_url?(:url, url, true)
264
+ MultiPartyCallMember.new(@_client, resource_id: @id, member_id: member_id).start_play_audio(url)
265
+ end
266
+
267
+ def stop_play_audio(member_id)
268
+ valid_param?(:member_id, member_id, [String, Integer], true)
269
+ MultiPartyCallMember.new(@_client, resource_id: @id, member_id: member_id).stop_play_audio
270
+ end
249
271
  end
250
272
 
251
273
  class MultiPartyCallParticipant < Base::SecondaryResource
@@ -311,6 +333,36 @@ module Plivo
311
333
  end
312
334
  end
313
335
 
336
+ class MultiPartyCallMember < Base::SecondaryResource
337
+ def initialize(client, options = nil)
338
+ @_name = 'MultiPartyCall'
339
+ @_identifier_string = 'mpc_uuid'
340
+ @_secondary_name = 'Member'
341
+ @_secondary_identifier_string = 'member_id'
342
+ super
343
+ @_is_voice_request = true
344
+ if options.key? :multi_party_prefix
345
+ @id = options[:multi_party_prefix] + '_' + @id
346
+ elsif @id.split('_').size > 1
347
+ nil
348
+ else
349
+ @id = 'uuid_' + @id
350
+ end
351
+ configure_secondary_resource_uri
352
+ end
353
+
354
+ def start_play_audio(url)
355
+ valid_url?(:url, url, true)
356
+ params = {}
357
+ params[:url] = url unless url.nil?
358
+ perform_action_apiresponse('Play', 'POST', params, true)
359
+ end
360
+
361
+ def stop_play_audio
362
+ perform_action_apiresponse('Play', 'DELETE')
363
+ end
364
+ end
365
+
314
366
  class MultiPartyCallInterface < Base::ResourceInterface
315
367
  def initialize(client, resource_list_json = nil)
316
368
  @_name = 'MultiPartyCall'
@@ -394,6 +446,8 @@ module Plivo
394
446
  options[:enter_sound_method] = 'GET' unless options.key?(:enter_sound_method)
395
447
  options[:exit_sound] = 'beep:2' unless options.key?(:exit_sound)
396
448
  options[:exit_sound_method] = 'GET' unless options.key?(:exit_sound_method)
449
+ options[:start_recording_audio_method] = 'GET' unless options.key?(:start_recording_audio_method)
450
+ options[:stop_recording_audio_method] = 'GET' unless options.key?(:stop_recording_audio_method)
397
451
  valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
398
452
  valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
399
453
  mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
@@ -403,7 +457,8 @@ module Plivo
403
457
  options[:wait_music_method],options[:agent_hold_music_url],options[:agent_hold_music_method],options[:customer_hold_music_url],options[:customer_hold_music_method],
404
458
  options[:recording_callback_url],options[:recording_callback_method],options[:status_callback_url],options[:status_callback_method],options[:on_exit_action_url], options[:on_exit_action_method],
405
459
  options[:record],options[:record_file_format],options[:status_callback_events],options[:stay_alone], options[:coach_mode],options[:mute],options[:hold],options[:start_mpc_on_enter],options[:end_mpc_on_exit],
406
- options[:relay_dtmf_inputs],options[:enter_sound],options[:enter_sound_method],options[:exit_sound],options[:exit_sound_method])
460
+ options[:relay_dtmf_inputs],options[:enter_sound],options[:enter_sound_method],options[:exit_sound],options[:exit_sound_method], options[:start_recording_audio], options[:start_recording_audio_method],
461
+ options[:stop_recording_audio], options[:stop_recording_audio_method])
407
462
  end
408
463
 
409
464
  def start(options = {})
@@ -549,6 +604,30 @@ module Plivo
549
604
  mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
550
605
  MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).get_participant
551
606
  end
607
+
608
+ def start_play_audio(options = {})
609
+ valid_param?(:options, options, Hash, false)
610
+ if not options[:member_id]
611
+ raise_invalid_request("Member Id is mandatory")
612
+ end
613
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
614
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
615
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
616
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
617
+ MultiPartyCallMember.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).start_play_audio(options[:url])
618
+ end
619
+
620
+ def stop_play_audio(options = {})
621
+ valid_param?(:options, options, Hash, false)
622
+ if not options[:member_id]
623
+ raise_invalid_request("Member Id is mandatory")
624
+ end
625
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
626
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
627
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
628
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
629
+ MultiPartyCallMember.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).stop_play_audio
630
+ end
552
631
  end
553
632
  end
554
633
  end
@@ -15,6 +15,8 @@ require_relative 'resources/nodes'
15
15
  require_relative 'resources/phlo_member'
16
16
  require_relative 'resources/call_feedback'
17
17
  require_relative 'resources/media'
18
+ require_relative 'resources/brand'
19
+ require_relative 'resources/campaign'
18
20
  require_relative 'resources/lookup'
19
21
  require_relative 'resources/regulatory_compliance'
20
22
  require_relative 'resources/multipartycalls'
@@ -14,6 +14,7 @@ module Plivo
14
14
  attr_reader :powerpacks
15
15
  attr_reader :powerpacks, :media
16
16
  attr_reader :lookup
17
+ attr_reader :brand, :campaign
17
18
  attr_reader :end_users
18
19
  attr_reader :compliance_document_types, :compliance_documents, :compliance_requirements, :compliance_applications
19
20
 
@@ -39,6 +40,8 @@ module Plivo
39
40
  @messages = Resources::MessagesInterface.new(self)
40
41
  @powerpacks = Resources::PowerpackInterface.new(self)
41
42
  @media = Resources::MediaInterface.new(self)
43
+ @brand = Resources::BrandInterface.new(self)
44
+ @campaign = Resources::CampaignInterface.new(self)
42
45
  @subaccounts = Resources::SubaccountInterface.new(self)
43
46
  @recordings = Resources::RecordingInterface.new(self)
44
47
  @pricings = Resources::PricingInterface.new(self)
data/lib/plivo/utils.rb CHANGED
@@ -227,7 +227,7 @@ module Plivo
227
227
  uri += "?"
228
228
  end
229
229
  if parsed_uri.query.to_s.length > 0
230
- parsed_uri_query = URI.decode(parsed_uri.query)
230
+ parsed_uri_query = URI.decode_www_form_component(parsed_uri.query)
231
231
  if method == "GET"
232
232
  queryParamMap = getMapFromQueryString?(parsed_uri_query)
233
233
  params.keys.sort.each { |key|
data/lib/plivo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Plivo
2
- VERSION = "4.20.0".freeze
2
+ VERSION = "4.24.0".freeze
3
3
  end
@@ -9,7 +9,9 @@ module Plivo
9
9
  statusCallbackEvents statusCallbackUrl statusCallbackMethod
10
10
  stayAlone coachMode mute hold startMpcOnEnter endMpcOnExit
11
11
  enterSound enterSoundMethod exitSound exitSoundMethod
12
- onExitActionUrl onExitActionMethod relayDTMFInputs]
12
+ onExitActionUrl onExitActionMethod relayDTMFInputs
13
+ startRecordingAudio startRecordingAudioMethod
14
+ stopRecordingAudio stopRecordingAudioMethod]
13
15
 
14
16
  VALID_ROLE_VALUES = %w[agent supervisor customer]
15
17
  VALID_METHOD_VALUES = %w[GET POST]
@@ -179,6 +181,26 @@ module Plivo
179
181
  raise PlivoXMLError, "invalid attribute value #{attributes[:customerHoldMusicUrl]} for customerHoldMusicUrl"
180
182
  end
181
183
 
184
+ if attributes[:startRecordingAudio] && !valid_url?(:startRecordingAudio, attributes[:startRecordingAudio], false)
185
+ raise PlivoXMLError, "invalid attribute value #{attributes[:startRecordingAudio]} for startRecordingAudio"
186
+ end
187
+
188
+ if attributes[:stopRecordingAudio] && !valid_url?(:stopRecordingAudio, attributes[:stopRecordingAudio], false)
189
+ raise PlivoXMLError, "invalid attribute value #{attributes[:stopRecordingAudio]} for stopRecordingAudio"
190
+ end
191
+
192
+ if attributes[:startRecordingAudioMethod] && !VALID_METHOD_VALUES.include?(attributes[:startRecordingAudioMethod].upcase)
193
+ raise PlivoXMLError, "invalid attribute value #{attributes[:startRecordingAudioMethod]} for startRecordingAudioMethod"
194
+ elsif !attributes[:startRecordingAudioMethod]
195
+ attributes[:startRecordingAudioMethod] = 'GET'
196
+ end
197
+
198
+ if attributes[:stopRecordingAudioMethod] && !VALID_METHOD_VALUES.include?(attributes[:stopRecordingAudioMethod].upcase)
199
+ raise PlivoXMLError, "invalid attribute value #{attributes[:stopRecordingAudioMethod]} for stopRecordingAudioMethod"
200
+ elsif !attributes[:stopRecordingAudioMethod]
201
+ attributes[:stopRecordingAudioMethod] = 'GET'
202
+ end
203
+
182
204
  raise PlivoXMLError, 'No MPC name set for the MPC' unless body
183
205
  super(body, attributes)
184
206
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plivo
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.20.0
4
+ version: 4.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Plivo SDKs Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-04 00:00:00.000000000 Z
11
+ date: 2021-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -152,6 +152,7 @@ executables: []
152
152
  extensions: []
153
153
  extra_rdoc_files: []
154
154
  files:
155
+ - ".github/workflows/unitTests.yml"
155
156
  - ".gitignore"
156
157
  - ".rspec"
157
158
  - ".travis.yml"
@@ -182,8 +183,10 @@ files:
182
183
  - lib/plivo/resources/accounts.rb
183
184
  - lib/plivo/resources/addresses.rb
184
185
  - lib/plivo/resources/applications.rb
186
+ - lib/plivo/resources/brand.rb
185
187
  - lib/plivo/resources/call_feedback.rb
186
188
  - lib/plivo/resources/calls.rb
189
+ - lib/plivo/resources/campaign.rb
187
190
  - lib/plivo/resources/conferences.rb
188
191
  - lib/plivo/resources/endpoints.rb
189
192
  - lib/plivo/resources/identities.rb