plivo 4.45.0 → 4.46.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: b33e83271ea1b3c2e5c41896af84fb49c3c07bee
4
- data.tar.gz: 97ba20e8311a213e6db92cc1a7d29a88b62254a1
3
+ metadata.gz: 5a1adf70a4fde50a292d378f057a7f65bfa9ed7b
4
+ data.tar.gz: 5d89de13e75759f0cfbb7ca9661b43fa743ef8de
5
5
  SHA512:
6
- metadata.gz: 287c22be5c57c14d03b932d3387f95872ef748809a04ba88419f38dc0f6df06d47a7e43327484da59717b1d282a46a8f4661cc4e2defdf560a76e7ca4b8f6a49
7
- data.tar.gz: 1b49da62504fd9f7dd178db676d3402be0bfdd72aa5f0d1a904e5b560697bdeca452e052b06030403880654edc46d0ba269de69a0d9ef7fd748a1aefcd313950
6
+ metadata.gz: 32ff933158008f134dbc6159cfd9f9bf512f1be42c73aa891afd805a354500065459b0e8d5a6fcac33957f9e3c49445ac903b4b28ca9aeeaf4a4b5213128263f
7
+ data.tar.gz: fad484cd5da48a0843ec94b182d3d3adb199505b7552cff1dcc017636eb34d917b1d2649ff0fac2519e21933b363807798c6fa89fcc5c05b1d662a5b7084df32
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## [4.46.0](https://github.com/plivo/plivo-go/tree/v4.46.0) (2023-06-28)
4
+ **Feature - Audio Streaming**
5
+ - Added functionality to start, stop and fetch audio streams
6
+ - Added functionality to create stream XML
7
+
3
8
  ## [4.45.0](https://github.com/plivo/plivo-ruby/tree/v4.45.0) (2023-05-02)
4
9
  **Feature - CNAM Lookup**
5
10
  - Added New Param `cnam_lookup` in to the response of the [list all numbers API], [list single number API]
@@ -61,7 +66,6 @@
61
66
  **Adding new attribute - 'message_expiry' in Send Message API**
62
67
  - Added new attribute - message_expiry in Send Message API
63
68
 
64
-
65
69
  ## [4.34.0](https://github.com/plivo/plivo-ruby/tree/v4.34.0) (2022-12-16)
66
70
  **10DLC: Update Campaign API**
67
71
  - Added Update Campaign API
@@ -79,7 +83,6 @@
79
83
  -Added 3 new keys to AccountPhoneNumber object:`tendlc_registration_status`, `tendlc_campaign_id` and `toll_free_sms_verification` (https://www.plivo.com/docs/numbers/api/account-phone-number#the-accountphonenumber-object)
80
84
  -Added 3 new filters to AccountPhoneNumber - list all my numbers API:`tendlc_registration_status`, `tendlc_campaign_id` and `toll_free_sms_verification` (https://www.plivo.com/docs/numbers/api/account-phone-number#list-all-my-numbers)
81
85
 
82
-
83
86
  ## [4.30.2](https://github.com/plivo/plivo-ruby/tree/v4.30.2) (2022-09-28)
84
87
  **10DLC: Campaign request**
85
88
  - Added more attributes to create campaign request
@@ -88,7 +91,6 @@
88
91
  **stability - faraday upgrade**
89
92
  - faraday version upgrade
90
93
 
91
-
92
94
  ## [4.30.0](https://github.com/plivo/plivo-ruby/tree/v4.30.0) (2022-08-26)
93
95
  **Feature - 10DLC APIs**
94
96
  - Added new 10DLC APIs
data/README.md CHANGED
@@ -9,7 +9,7 @@ The Plivo Ruby SDK makes it simpler to integrate communications into your Ruby a
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'plivo', '>= 4.45.0'
12
+ gem 'plivo', '>= 4.46.0'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -203,6 +203,73 @@ module Plivo
203
203
  @_client.send_request(resource_path, 'DELETE', nil, nil, false , is_voice_request: @_is_voice_request)
204
204
  end
205
205
 
206
+ def start_stream(service_url, options = nil)
207
+ valid_param?(:service_url, service_url, [String, Symbol], true)
208
+ if options.nil?
209
+ return perform_action('Stream', 'POST', { service_url: service_url }, true)
210
+ end
211
+
212
+ valid_param?(:options, options, Hash, true)
213
+
214
+ params = { service_url: service_url }
215
+
216
+ if options.key?(:bidirectional) &&
217
+ valid_param?(:bidirectional, options[:bidirectional], [TrueClass, FalseClass], false )
218
+ params[:bidirectional] = options[:bidirectional]
219
+ end
220
+
221
+ if options.key?(:audio_track) &&
222
+ valid_param?(:audio_track, options[:audio_track],
223
+ [String, Symbol], false, %w[inbound outbound both])
224
+ params[:audio_track] = options[:audio_track]
225
+ end
226
+
227
+ if options.key?(:stream_timeout) &&
228
+ valid_param?(:stream_timeout, options[:stream_timeout], Integer, false)
229
+ params[:stream_timeout] = options[:stream_timeout]
230
+ end
231
+
232
+ if options.key?(:status_callback_url) &&
233
+ valid_param?(:status_callback_url, options[:status_callback_url], [String, Symbol], false)
234
+ params[:status_callback_url] = options[:status_callback_url]
235
+ end
236
+
237
+ if options.key?(:status_callback_method) &&
238
+ valid_param?(:status_callback_method, options[:status_callback_method],
239
+ [String, Symbol], false, %w[GET POST get post])
240
+ params[:status_callback_method] = options[:status_callback_method]
241
+ end
242
+
243
+ if options.key?(:content_type) &&
244
+ valid_param?(:content_type, options[:content_type], [String, Symbol, Integer], false)
245
+ params[:content_type] = options[:content_type]
246
+ end
247
+
248
+ if options.key?(:extra_headers) &&
249
+ valid_param?(:extra_headers, options[:extra_headers], [String], false)
250
+ params[:extra_headers] = options[:extra_headers]
251
+ end
252
+ perform_action('Stream', 'POST', params, true)
253
+ end
254
+
255
+ def stop_all_streams
256
+ perform_action('Stream', 'DELETE', nil, false)
257
+ end
258
+
259
+ def stop_stream(stream_id)
260
+ valid_param?(:stream_id, stream_id, [String, Symbol, Integer], true)
261
+ perform_action('Stream/' + stream_id, 'DELETE', nil, false)
262
+ end
263
+
264
+ def get_all_streams
265
+ perform_action('Stream', 'GET', nil, true )
266
+ end
267
+
268
+ def get_stream(stream_id)
269
+ valid_param?(:stream_id, stream_id, [String, Symbol, Integer], true)
270
+ perform_action('Stream/' + stream_id, 'GET', nil, true)
271
+ end
272
+
206
273
  def to_s
207
274
  call_details = {
208
275
  answer_time: @answer_time,
@@ -577,6 +644,62 @@ module Plivo
577
644
  valid_param?(:call_uuid, call_uuid, [String, Symbol], true)
578
645
  Call.new(@_client, resource_id: call_uuid).cancel_request
579
646
  end
647
+
648
+ # @param [String] service_url
649
+ # @param [Hash] options
650
+ # @option options [Boolean] :bidirectional
651
+ # @option options [String] :audio_track
652
+ # @option options [Int] :stream_timeout
653
+ # @option options [String] :status_callback_url
654
+ # @option options [String] :status_callback_method
655
+ # @option options [String] :content_type
656
+ # @option options [String] :extra_headers
657
+ def start_stream(call_uuid, service_url, options = {})
658
+ valid_param?(:call_uuid, call_uuid, [String, Symbol], true)
659
+ response = Call.new(@_client, resource_id: call_uuid).start_stream(service_url, options)
660
+ return Base::Response.new(Hash["api_id" => response.api_id,
661
+ "stream_id" => response.stream_id,
662
+ "message" => response.message])
663
+ end
664
+
665
+ def stop_all_streams(call_uuid)
666
+ valid_param?(:call_uuid, call_uuid, [String, Symbol], true )
667
+ Call.new(@_client, resource_id: call_uuid).stop_all_streams
668
+ end
669
+
670
+ def stop_stream(call_uuid, stream_id)
671
+ valid_param?(:call_uuid, call_uuid, [String, Symbol], true )
672
+ Call.new(@_client, resource_id: call_uuid).stop_stream(stream_id)
673
+ end
674
+
675
+ def get_all_streams(call_uuid)
676
+ valid_param?(:call_uuid, call_uuid, [String, Symbol], true )
677
+ response = Call.new(@_client, resource_id: call_uuid).get_all_streams
678
+ return Base::Response.new(Hash["api_id" => response.api_id,
679
+ "meta" => response.meta,
680
+ "objects" => response.objects])
681
+ end
682
+
683
+ def get_stream(call_uuid, stream_id)
684
+ valid_param?(:call_uuid, call_uuid, [String, Symbol], true )
685
+ response = Call.new(@_client, resource_id: call_uuid).get_stream(stream_id)
686
+ return Base::Response.new(Hash["api_id" => response.instance_variable_get(:@api_id),
687
+ "audio_track" => response.instance_variable_get(:@audio_track),
688
+ "bidirectional" => response.instance_variable_get(:@bidirectional),
689
+ "bill_duration" => response.instance_variable_get(:@bill_duration),
690
+ "billed_amount" => response.instance_variable_get(:@billed_amount),
691
+ "call_uuid" => response.instance_variable_get(:@call_uuid),
692
+ "created_at" => response.instance_variable_get(:@created_at),
693
+ "end_time" => response.instance_variable_get(:@end_time),
694
+ "plivo_auth_id" => response.instance_variable_get(:@plivo_auth_id),
695
+ "resource_uri" => response.instance_variable_get(:@resource_uri),
696
+ "rounded_bill_duration" => response.instance_variable_get(:@rounded_bill_duration),
697
+ "service_url" => response.instance_variable_get(:@service_url),
698
+ "start_time" => response.instance_variable_get(:@start_time),
699
+ "status" => response.instance_variable_get(:@status),
700
+ "status_callback_url" => response.instance_variable_get(:@status_callback_url),
701
+ "stream_id" => response.instance_variable_get(:@stream_id)])
702
+ end
580
703
  end
581
704
  end
582
705
  end
data/lib/plivo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Plivo
2
- VERSION = "4.45.0".freeze
2
+ VERSION = "4.46.0".freeze
3
3
  end
@@ -8,11 +8,11 @@ module Plivo
8
8
  end
9
9
 
10
10
  def to_xml
11
- '<?xml version="1.0" encoding="utf-8" ?>' + @response.to_xml
11
+ '<?xml version="1.0" encoding="utf-8" ?>' + @response.to_xml.gsub("&quot;", "\"")
12
12
  end
13
13
 
14
14
  def to_s
15
- '<?xml version="1.0" encoding="utf-8" ?>' + @response.to_s
15
+ '<?xml version="1.0" encoding="utf-8" ?>' + @response.to_s.gsub("&quot;", "\"")
16
16
  end
17
17
  end
18
18
  end
@@ -2,7 +2,7 @@ module Plivo
2
2
  module XML
3
3
  class Response < Element
4
4
  @nestables = %w[Speak Play GetDigits GetInput Record Dial Message
5
- Redirect Wait Hangup PreAnswer Conference DTMF MultiPartyCall]
5
+ Redirect Wait Hangup PreAnswer Conference DTMF MultiPartyCall Stream]
6
6
  @valid_attributes = []
7
7
 
8
8
  def initialize
@@ -0,0 +1,27 @@
1
+ module Plivo
2
+ module XML
3
+ class Stream < Element
4
+ @nestables = []
5
+ @valid_attributes = %w[bidirectional audioTrack streamTimeout statusCallbackUrl
6
+ statusCallbackMethod contentType extraHeaders]
7
+
8
+ SUPPORTED_BIDIRECTIONAL=%w(true false)
9
+ SUPPORTED_AUDIOTRACK=%w(inbound outbound both)
10
+ SUPPORTED_CALLBACKMETHOD=%w(GET POST)
11
+
12
+ def initialize(body, attributes = {})
13
+ if attributes[:bidirectional] && !SUPPORTED_BIDIRECTIONAL.include?(attributes[:bidirectional])
14
+ raise PlivoXMLError, "<Stream> bidirectional #{attributes[:bidirectional]} is not valid."
15
+ end
16
+ if attributes[:audioTrack] && !SUPPORTED_AUDIOTRACK.include?(attributes[:audioTrack])
17
+ raise PlivoXMLError, "<Stream> audioTrack #{attributes[:audioTrack]} is not valid."
18
+ end
19
+ if attributes[:statusCallbackMethod] && !SUPPORTED_CALLBACKMETHOD.include?(attributes[:statusCallbackMethod].upcase)
20
+ raise PlivoXMLError, "<Stream> statusCallbackMethod #{attributes[:statusCallbackMethod]} is not valid."
21
+ end
22
+ raise PlivoXMLError, 'No text set for Stream' unless body
23
+ super(body, attributes)
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/plivo/xml.rb CHANGED
@@ -31,6 +31,7 @@ require_relative 'xml/w'
31
31
  require_relative 'xml/plivo_xml'
32
32
  require_relative 'xml/multipartycall'
33
33
  require_relative 'xml/cont'
34
+ require_relative 'xml/stream'
34
35
  include Plivo::Exceptions
35
36
 
36
37
  module Plivo
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.45.0
4
+ version: 4.46.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: 2023-06-02 00:00:00.000000000 Z
11
+ date: 2023-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -236,6 +236,7 @@ files:
236
236
  - lib/plivo/xml/s.rb
237
237
  - lib/plivo/xml/say_as.rb
238
238
  - lib/plivo/xml/speak.rb
239
+ - lib/plivo/xml/stream.rb
239
240
  - lib/plivo/xml/sub.rb
240
241
  - lib/plivo/xml/user.rb
241
242
  - lib/plivo/xml/w.rb