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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +1 -1
- data/lib/plivo/base_client.rb +1 -1
- data/lib/plivo/resources.rb +1 -0
- data/lib/plivo/resources/media.rb +97 -0
- data/lib/plivo/rest_client.rb +2 -1
- data/lib/plivo/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 859a4bb8671de018a138cee7b6df8cc51aeb5c02
|
4
|
+
data.tar.gz: 8f5d2dd2b05ded734250e3bda0098e66f5e37bf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b1eadfded3bcc822272221366c427e832d7761cecd937f6febbde0dd8cca1871fbbe565f35a46158de2f0792754c5fa10cbecde78b7b32e5e4ae66bd90e65a8
|
7
|
+
data.tar.gz: d6154df50e1a3286c02b42e181a61f27f9516c1184085ac058f927de3e98ed90a2b5eecbcdcd37498a831433764060b5ded161fbe0968dc7f2dd5fbcad2cc279
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/plivo/base_client.rb
CHANGED
@@ -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
|
|
data/lib/plivo/resources.rb
CHANGED
@@ -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
|
data/lib/plivo/rest_client.rb
CHANGED
@@ -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)
|
data/lib/plivo/version.rb
CHANGED
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
|
+
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:
|
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
|