bulutfon_sdk 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bulutfon_sdk/rest/base_request.rb +24 -5
- data/lib/bulutfon_sdk/rest/bulutfon.rb +11 -11
- data/lib/bulutfon_sdk/rest/call_record.rb +6 -6
- data/lib/bulutfon_sdk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98c31d0193c61fa20c3a76dbf332211dc048c27f
|
4
|
+
data.tar.gz: 8e8bd10c57f436e6a6480f5f0ec909ebae814857
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74c9581899a61cde11566b9aeb54a4235565ced86336b4e62ecf95662c5cb0609a174f2556dbdd4827041abf1684ee6ccfb6845278491da325d7842ccdc5fcb9
|
7
|
+
data.tar.gz: 55d1b436c81ebe6784ec9518c6eebe89a0d929728ab7f343cd07e77fa5254167afd2133a24fc1df15a497b70f428f1393c6f880d2181535e96a7334ded25b466
|
@@ -10,9 +10,17 @@ module BulutfonSDK
|
|
10
10
|
|
11
11
|
def initialize(*args)
|
12
12
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
13
|
+
args.select! {|arg| !arg.nil?}
|
13
14
|
@config = BulutfonSDK::Util::ClientConfig.new options
|
14
|
-
|
15
|
-
|
15
|
+
if args.count > 1
|
16
|
+
@email = args[0] || nil
|
17
|
+
@password = args[1] || nil
|
18
|
+
@auth_type = 'credentials'
|
19
|
+
else
|
20
|
+
@token = args[0] || nil
|
21
|
+
@auth_type = 'token'
|
22
|
+
end
|
23
|
+
raise ArgumentError, 'Auth token or user credentials are required' if (@token.nil? && (@email.nil? || @password.nil?))
|
16
24
|
set_up_connection
|
17
25
|
end
|
18
26
|
|
@@ -41,14 +49,25 @@ module BulutfonSDK
|
|
41
49
|
def uri_parse(params, path)
|
42
50
|
request_path = "#{@config.host}/#{path}"
|
43
51
|
uri = URI.parse(request_path)
|
44
|
-
|
52
|
+
encrypt_token = params.delete(:encrypt_token)
|
53
|
+
id = params.delete(:id)
|
54
|
+
if @auth_type == 'credentials'
|
55
|
+
params[:email] = @email
|
56
|
+
params[:password] = @password
|
57
|
+
else
|
58
|
+
if encrypt_token && id.present?
|
59
|
+
params[:access_token] = Digest::SHA1.hexdigest(@token.to_s + id.to_s)
|
60
|
+
else
|
61
|
+
params[:access_token] = @token
|
62
|
+
end
|
63
|
+
end
|
45
64
|
uri
|
46
65
|
end
|
47
66
|
|
48
67
|
##
|
49
68
|
# Prepare http request for file saving
|
50
|
-
def save_file(method, path, save_path)
|
51
|
-
uri = prepare_uri(path)
|
69
|
+
def save_file(method, path, save_path, params = {})
|
70
|
+
uri = prepare_uri(path, params)
|
52
71
|
method_class = Net::HTTP.const_get method.to_s.capitalize
|
53
72
|
request = method_class.new(uri.to_s, HTTP_HEADERS)
|
54
73
|
response = connect_and_send(request, is_file: true )
|
@@ -13,47 +13,47 @@ module BulutfonSDK
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def messages
|
16
|
-
BulutfonSDK::REST::Message.new(@token)
|
16
|
+
BulutfonSDK::REST::Message.new(@token || @email, @password)
|
17
17
|
end
|
18
18
|
|
19
19
|
def message_titles
|
20
|
-
BulutfonSDK::REST::MessageTitle.new(@token)
|
20
|
+
BulutfonSDK::REST::MessageTitle.new(@token || @email, @password)
|
21
21
|
end
|
22
22
|
|
23
23
|
def extensions
|
24
|
-
BulutfonSDK::REST::Extension.new(@token)
|
24
|
+
BulutfonSDK::REST::Extension.new(@token || @email, @password)
|
25
25
|
end
|
26
26
|
|
27
27
|
def dids
|
28
|
-
BulutfonSDK::REST::Did.new(@token)
|
28
|
+
BulutfonSDK::REST::Did.new(@token || @email, @password)
|
29
29
|
end
|
30
30
|
|
31
31
|
def groups
|
32
|
-
BulutfonSDK::REST::Group.new(@token)
|
32
|
+
BulutfonSDK::REST::Group.new(@token || @email, @password)
|
33
33
|
end
|
34
34
|
|
35
35
|
def cdrs
|
36
|
-
BulutfonSDK::REST::Cdr.new(@token)
|
36
|
+
BulutfonSDK::REST::Cdr.new(@token || @email, @password)
|
37
37
|
end
|
38
38
|
|
39
39
|
def call_records
|
40
|
-
BulutfonSDK::REST::CallRecord.new(@token)
|
40
|
+
BulutfonSDK::REST::CallRecord.new(@token || @email, @password)
|
41
41
|
end
|
42
42
|
|
43
43
|
def incoming_faxes
|
44
|
-
BulutfonSDK::REST::IncomingFax.new(@token)
|
44
|
+
BulutfonSDK::REST::IncomingFax.new(@token || @email, @password)
|
45
45
|
end
|
46
46
|
|
47
47
|
def outgoing_faxes
|
48
|
-
BulutfonSDK::REST::OutgoingFax.new(@token)
|
48
|
+
BulutfonSDK::REST::OutgoingFax.new(@token || @email, @password)
|
49
49
|
end
|
50
50
|
|
51
51
|
def announcements
|
52
|
-
BulutfonSDK::REST::Announcement.new(@token)
|
52
|
+
BulutfonSDK::REST::Announcement.new(@token || @email, @password)
|
53
53
|
end
|
54
54
|
|
55
55
|
def automatic_calls
|
56
|
-
BulutfonSDK::REST::AutomaticCall.new(@token)
|
56
|
+
BulutfonSDK::REST::AutomaticCall.new(@token || @email, @password)
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|
@@ -9,18 +9,18 @@ module BulutfonSDK
|
|
9
9
|
@resource = 'call-records'
|
10
10
|
end
|
11
11
|
|
12
|
-
def get( uuid )
|
13
|
-
uri = prepare_uri("#{@resource}/#{uuid}")
|
12
|
+
def get( uuid, encrypt_token = false )
|
13
|
+
uri = prepare_uri("#{@resource}/#{uuid}", {encrypt_token: encrypt_token, id: uuid})
|
14
14
|
{ download_path: uri.to_s }
|
15
15
|
end
|
16
16
|
|
17
|
-
def get_stream( uuid)
|
18
|
-
uri = prepare_uri("#{@resource}/#{uuid}/stream")
|
17
|
+
def get_stream( uuid, encrypt_token = false )
|
18
|
+
uri = prepare_uri("#{@resource}/#{uuid}/stream", {encrypt_token: encrypt_token, id: uuid})
|
19
19
|
{ download_path: uri.to_s }
|
20
20
|
end
|
21
21
|
|
22
|
-
def save( uuid, save_path)
|
23
|
-
save_file( 'get', "#{@resource}/#{uuid}", save_path)
|
22
|
+
def save( uuid, save_path, encrypt_token = false)
|
23
|
+
save_file( 'get', "#{@resource}/#{uuid}", save_path, {encrypt_token: encrypt_token, id: uuid})
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
data/lib/bulutfon_sdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bulutfon_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ismail Akbudak
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|