plivo 4.3.5 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 859a4bb8671de018a138cee7b6df8cc51aeb5c02
4
- data.tar.gz: 8f5d2dd2b05ded734250e3bda0098e66f5e37bf2
3
+ metadata.gz: 88ca1cbed16ec4e3a12da537931eed4d5149616b
4
+ data.tar.gz: 02dc6114077ff68c1d6d71d9d240a9b6c1da20e7
5
5
  SHA512:
6
- metadata.gz: 3b1eadfded3bcc822272221366c427e832d7761cecd937f6febbde0dd8cca1871fbbe565f35a46158de2f0792754c5fa10cbecde78b7b32e5e4ae66bd90e65a8
7
- data.tar.gz: d6154df50e1a3286c02b42e181a61f27f9516c1184085ac058f927de3e98ed90a2b5eecbcdcd37498a831433764060b5ded161fbe0968dc7f2dd5fbcad2cc279
6
+ metadata.gz: 361bebcbda4512ec388ccba8536e8661ca3f4cb9dc0d24b8eda9f2b997e1dce91ce287f7d6b1970119ab983c6f74e595538a6ca522baec28220c1585bbe6d810
7
+ data.tar.gz: 57171030cb74a81ae868711f9b70a59aa4c69ef029406a6fbfe2cfa42bb97bb328dd8de5cd8f8dfc9b2d80c23c334fc5abb06c472067960a385ceef3a8c0ac7d
@@ -1,5 +1,8 @@
1
1
  # Change Log
2
2
 
3
+ ## [4.4.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.4.0) (2020-03-27)
4
+ - Add post call quality feedback API support.
5
+
3
6
  ## [4.3.5](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.5) (2019-12-28)
4
7
  - Add Media support
5
8
 
data/README.md CHANGED
@@ -8,7 +8,7 @@ The Plivo Ruby SDK makes it simpler to integrate communications into your Ruby a
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  ```ruby
11
- gem 'plivo', '>= 4.3.5'
11
+ gem 'plivo', '>= 4.4.0'
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -5,6 +5,7 @@ require_relative 'base/response'
5
5
  module Plivo
6
6
  module Base
7
7
  PLIVO_API_URL = 'https://api.plivo.com'.freeze
8
+ CALLINSIGHTS_API_URL = 'https://stats.plivo.com'.freeze
8
9
  PHLO_API_URL = 'https://phlorunner.plivo.com'.freeze
9
10
  end
10
11
  end
@@ -117,6 +117,20 @@ module Plivo
117
117
  faraday.response :json, content_type: /\bjson$/
118
118
  faraday.adapter Faraday.default_adapter
119
119
  end
120
+
121
+ @callinsights_conn = Faraday.new(@callinsights_base_uri) do |faraday|
122
+ faraday.headers = @headers
123
+
124
+ # DANGER: Basic auth should always come after headers, else
125
+ # The headers will replace the basic_auth
126
+
127
+ faraday.basic_auth(auth_id, auth_token)
128
+
129
+ faraday.proxy=@proxy_hash if @proxy_hash
130
+ faraday.response :json, content_type: /\bjson$/
131
+ faraday.adapter Faraday.default_adapter
132
+ end
133
+
120
134
  end
121
135
 
122
136
  def send_get(resource_path, data, timeout)
@@ -153,10 +167,24 @@ module Plivo
153
167
  req.body = data
154
168
  end
155
169
  else
156
- response = @conn.post do |req|
157
- req.url resource_path
158
- req.options.timeout = timeout if timeout
159
- req.body = JSON.generate(data) if data
170
+ if data.has_key? 'is_callinsights_request'
171
+ callinsight_base_url = data['callinsight_base_url']
172
+ resource_path = data['request_url']
173
+ data.delete('is_callinsights_request')
174
+ data.delete('request_url')
175
+
176
+ response = @callinsights_conn.post do |req|
177
+ req.url resource_path
178
+ req.options.timeout = timeout if timeout
179
+ req.body = JSON.generate(data) if data
180
+ end
181
+
182
+ else
183
+ response = @conn.post do |req|
184
+ req.url resource_path
185
+ req.options.timeout = timeout if timeout
186
+ req.body = JSON.generate(data) if data
187
+ end
160
188
  end
161
189
  end
162
190
  response
@@ -188,6 +216,14 @@ module Plivo
188
216
  Exceptions::InvalidRequestError,
189
217
  'HTTP method used is not allowed to access resource'
190
218
  ],
219
+ 409 => [
220
+ Exceptions::InvalidRequestError,
221
+ 'Conflict'
222
+ ],
223
+ 422 => [
224
+ Exceptions::InvalidRequestError,
225
+ 'Unprocessable Entity'
226
+ ],
191
227
  500 => [
192
228
  Exceptions::PlivoServerError,
193
229
  'A server error occurred while accessing resource'
@@ -13,6 +13,7 @@ require_relative 'resources/identities'
13
13
  require_relative 'resources/phlos'
14
14
  require_relative 'resources/nodes'
15
15
  require_relative 'resources/member'
16
+ require_relative 'resources/call_feedback'
16
17
  require_relative 'resources/media'
17
18
 
18
19
  module Plivo
@@ -0,0 +1,55 @@
1
+ require 'json'
2
+ require 'faraday'
3
+ require 'faraday_middleware'
4
+
5
+ module Plivo
6
+ module Resources
7
+ include Plivo::Utils
8
+ class CallFeedback < Base::Resource
9
+ def initialize(client, options = nil)
10
+ @_name = 'Call'
11
+ super
12
+ end
13
+ end
14
+
15
+ class CallFeedbackInterface < Base::ResourceInterface
16
+ FEEDBACK_API_PATH = "v1/Call/%s/Feedback/"
17
+ def initialize(client, resource_list_json = nil)
18
+ @_name = 'Call'
19
+ @_resource_type = CallFeedback
20
+ super
21
+ end
22
+
23
+ def create(call_uuid, rating, issues = [], notes = "")
24
+
25
+ valid_param?(:call_uuid, call_uuid, String, true)
26
+ valid_param?(:rating, rating, [Integer, Float], true)
27
+
28
+ if call_uuid == ""
29
+ raise_invalid_request("call_uuid cannot be empty")
30
+ end
31
+
32
+ if rating < 1 or rating > 5
33
+ raise_invalid_request("Rating has to be a float between 1 - 5")
34
+ end
35
+
36
+ params = {
37
+ rating: rating,
38
+ }
39
+
40
+ if issues.length() > 0
41
+ params['issues'] = issues
42
+ end
43
+
44
+ if notes.length > 0
45
+ params['notes'] = notes
46
+ end
47
+
48
+ params['is_callinsights_request'] = true
49
+ params['request_url'] = FEEDBACK_API_PATH % call_uuid
50
+
51
+ return perform_post(params)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -10,6 +10,8 @@ module Plivo
10
10
  attr_reader :pricings, :numbers, :calls, :conferences
11
11
  attr_reader :phone_numbers, :applications, :endpoints
12
12
  attr_reader :addresses, :identities
13
+ attr_reader :call_feedback
14
+ attr_reader :powerpacks
13
15
  attr_reader :powerpacks, :media
14
16
 
15
17
  def initialize(auth_id = nil, auth_token = nil, proxy_options = nil, timeout=5)
@@ -22,6 +24,7 @@ module Plivo
22
24
 
23
25
  def configure_base_uri
24
26
  @base_uri = Base::PLIVO_API_URL
27
+ @callinsights_base_uri = Base::CALLINSIGHTS_API_URL
25
28
  end
26
29
 
27
30
  def configure_interfaces
@@ -40,6 +43,7 @@ module Plivo
40
43
  @applications = Resources::ApplicationInterface.new(self)
41
44
  @addresses = Resources::AddressInterface.new(self)
42
45
  @identities = Resources::IdentityInterface.new(self)
46
+ @call_feedback = Resources::CallFeedbackInterface.new(self)
43
47
  end
44
48
  end
45
49
  end
@@ -1,3 +1,3 @@
1
1
  module Plivo
2
- VERSION = '4.3.5'.freeze
2
+ VERSION = '4.4.0'.freeze
3
3
  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.3.5
4
+ version: 4.4.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: 2020-02-28 00:00:00.000000000 Z
11
+ date: 2020-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -164,6 +164,7 @@ files:
164
164
  - lib/plivo/resources/accounts.rb
165
165
  - lib/plivo/resources/addresses.rb
166
166
  - lib/plivo/resources/applications.rb
167
+ - lib/plivo/resources/call_feedback.rb
167
168
  - lib/plivo/resources/calls.rb
168
169
  - lib/plivo/resources/conferences.rb
169
170
  - lib/plivo/resources/endpoints.rb