plivo 4.3.4 → 4.3.5

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: 5962f4f0c724be4b4041d248880aef8e05583a8f
4
- data.tar.gz: 5fa933a52d9bd3cd1cdcb1883b17d9522a5e52a9
3
+ metadata.gz: 859a4bb8671de018a138cee7b6df8cc51aeb5c02
4
+ data.tar.gz: 8f5d2dd2b05ded734250e3bda0098e66f5e37bf2
5
5
  SHA512:
6
- metadata.gz: 980c62fc69181eaee7b55e75aea5ec3bb4760fdc557e731806b16066df14cafedf10dc8c2218b3ed166843ee5a5867fefe2e622ca84fefcae02b89de5c5b8ee5
7
- data.tar.gz: 7359e55b9abd47381150463df81d3b98f3d1ff930b653e26a159e7bb1943db3a17184ceb883ace145790e5547f976292c329c633334c903dfae24b4b88ec759a
6
+ metadata.gz: 3b1eadfded3bcc822272221366c427e832d7761cecd937f6febbde0dd8cca1871fbbe565f35a46158de2f0792754c5fa10cbecde78b7b32e5e4ae66bd90e65a8
7
+ data.tar.gz: d6154df50e1a3286c02b42e181a61f27f9516c1184085ac058f927de3e98ed90a2b5eecbcdcd37498a831433764060b5ded161fbe0968dc7f2dd5fbcad2cc279
@@ -1,5 +1,8 @@
1
1
  # Change Log
2
2
 
3
+ ## [4.3.5](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.5) (2019-12-28)
4
+ - Add Media support
5
+
3
6
  ## [4.3.4](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.4) (2019-12-20)
4
7
  - Add Powerpack 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.4'
11
+ gem 'plivo', '>= 4.3.5'
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -33,7 +33,7 @@ module Plivo
33
33
  raise Exceptions::PlivoRESTError, "Resource at #{response[:url]} "\
34
34
  'couldn\'t be deleted'
35
35
  end
36
- elsif !([200, 201, 202].include? response[:status])
36
+ elsif !([200, 201, 202, 207].include? response[:status])
37
37
  raise Exceptions::PlivoRESTError, "Received #{response[:status]} for #{method}"
38
38
  end
39
39
 
@@ -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/media'
16
17
 
17
18
  module Plivo
18
19
  module Resources
@@ -0,0 +1,97 @@
1
+ module Plivo
2
+ module Resources
3
+ include Plivo::Utils
4
+ class Media < Base::Resource
5
+ def initialize(client, options = nil)
6
+ @_name = 'Media'
7
+ @_identifier_string = 'media_id'
8
+ super
9
+ end
10
+
11
+ def to_s
12
+ {
13
+ content_type: @content_type,
14
+ file_name: @file_name,
15
+ api_id: @api_id,
16
+ media_id: @media_id,
17
+ size: @size,
18
+ upload_time: @upload_time,
19
+ url: @url
20
+ }.to_s
21
+ end
22
+ end
23
+
24
+ class MediaInterface < Base::ResourceInterface
25
+ def initialize(client, resource_list_json = nil)
26
+ @_name = 'Media'
27
+ @_resource_type = Media
28
+ @_identifier_string = 'media_id'
29
+ super
30
+ end
31
+
32
+ ##
33
+ # Get an Media
34
+ # @param [String] media_id
35
+ # @return [Media] Media
36
+ def get(media_id)
37
+ valid_param?(:media_id, media_id, [String, Symbol], true)
38
+ perform_get(media_id)
39
+ end
40
+
41
+ ##
42
+ # List all Media
43
+ # @param [Hash] options
44
+ # @option options [Int] :offset
45
+ # @option options [Int] :limit
46
+ # @return [Hash]
47
+ def list(options=nil)
48
+ return perform_list_without_object if options.nil?
49
+
50
+ params = {}
51
+ %i[offset limit].each do |param|
52
+ if options.key?(param) && valid_param?(param, options[param],
53
+ [Integer], true)
54
+ params[param] = options[param]
55
+ end
56
+ end
57
+
58
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
59
+ raise_invalid_request('The maximum number of results that can be '\
60
+ "fetched is 20. limit can't be more than 20 or less than 1")
61
+ end
62
+
63
+ if options.key?(:offset) && options[:offset] < 0
64
+ raise_invalid_request("Offset can't be negative")
65
+ end
66
+
67
+ perform_list_without_object(params)
68
+ end
69
+
70
+ ##
71
+ # Create a new upload
72
+ def upload(filepath)
73
+ params = {}
74
+ for file_to_upload in filepath do
75
+ unless file_to_upload.nil?
76
+ file_extension = file_to_upload.split('.')[-1]
77
+
78
+ content_type = case file_extension
79
+ when 'jpeg' then 'image/jpeg'
80
+ when 'jpg' then 'image/jpeg'
81
+ when 'png' then 'image/png'
82
+ when 'pdf' then 'application/pdf'
83
+ when 'xcf' then 'image/xcf'
84
+ when 'text' then 'text/plain'
85
+ when 'mpeg' then 'video/mpeg'
86
+ when 'mp4' then 'video/mp4'
87
+ else raise_invalid_request("#{file_extension} is not yet supported for upload")
88
+ end
89
+
90
+ params[:file] = Faraday::UploadIO.new(file_to_upload, content_type)
91
+ end
92
+ end
93
+ perform_create(params, true)
94
+ end
95
+ end
96
+ end
97
+ end
@@ -10,7 +10,7 @@ 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 :powerpacks
13
+ attr_reader :powerpacks, :media
14
14
 
15
15
  def initialize(auth_id = nil, auth_token = nil, proxy_options = nil, timeout=5)
16
16
  configure_base_uri
@@ -28,6 +28,7 @@ module Plivo
28
28
  @account = Resources::AccountInterface.new(self)
29
29
  @messages = Resources::MessagesInterface.new(self)
30
30
  @powerpacks = Resources::PowerpackInterface.new(self)
31
+ @media = Resources::MediaInterface.new(self)
31
32
  @subaccounts = Resources::SubaccountInterface.new(self)
32
33
  @recordings = Resources::RecordingInterface.new(self)
33
34
  @pricings = Resources::PricingInterface.new(self)
@@ -1,3 +1,3 @@
1
1
  module Plivo
2
- VERSION = '4.3.4'.freeze
2
+ VERSION = '4.3.5'.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.4
4
+ version: 4.3.5
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: 2019-12-20 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -168,6 +168,7 @@ files:
168
168
  - lib/plivo/resources/conferences.rb
169
169
  - lib/plivo/resources/endpoints.rb
170
170
  - lib/plivo/resources/identities.rb
171
+ - lib/plivo/resources/media.rb
171
172
  - lib/plivo/resources/member.rb
172
173
  - lib/plivo/resources/messages.rb
173
174
  - lib/plivo/resources/nodes.rb