ringcentral_sdk 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +4 -5
- data/VERSION.txt +1 -1
- data/lib/ringcentral_sdk/helpers.rb +1 -0
- data/lib/ringcentral_sdk/helpers/fax.rb +73 -79
- data/lib/ringcentral_sdk/helpers/inflator.rb +3 -0
- data/lib/ringcentral_sdk/helpers/inflator/contact_info.rb +15 -0
- data/lib/ringcentral_sdk/platform.rb +0 -2
- data/lib/ringcentral_sdk/platform/platform.rb +29 -40
- data/lib/ringcentral_sdk/sdk.rb +2 -2
- data/test/test_setup.rb +0 -1
- metadata +29 -13
- data/lib/ringcentral_sdk/platform/auth.rb +0 -36
- data/lib/ringcentral_sdk/platform/parser.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07264090af5d1e993dcdf5a5b09ef2dbf6c0c85b
|
4
|
+
data.tar.gz: b062c4ae0cf678e992e8b0612a465f9c416f428a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3011b35d44c0c67626064f1c60d0262cfa15d862b3117cb54f7a965a045384a9b90ee40c4e6c29e821ccbedd95c1bd97d5f671292ecba55df10d2f2021491ab3
|
7
|
+
data.tar.gz: 228f26ac20d9dcd1ac2d3be50ededa6b23fadbe5af57cbf009cd509b150ba1739a66747c2625dd240fd0f29dd10b4909ecb12f115e67d997e283f62c8b1be31e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
|
+
- **2015-05-31**: 0.1.0
|
4
|
+
- Add OAuth token refresh
|
5
|
+
- Add OAuth2::AccessToken support
|
6
|
+
- Add Code Climate hook
|
7
|
+
- **2015-05-19**: 0.0.4
|
8
|
+
- Request helpers are now subclasses
|
9
|
+
- sdk.request() and platform.request() methods added to handle request helpers
|
10
|
+
- Fax helper uses file mime-type in preference to generic octet-stream
|
11
|
+
- Initial mkdocs and Read the Docs effort added
|
12
|
+
- Travis CI and Coveralls hooks added
|
3
13
|
- **2015-05-14**: 0.0.3
|
4
14
|
- First public release
|
5
15
|
- **2015-03-08**: 0.0.2
|
data/README.md
CHANGED
@@ -11,11 +11,14 @@ This is an unofficial Ruby SDK for the RingCentral Connect Platform REST API (ht
|
|
11
11
|
|
12
12
|
The core SDK objects follow the general design of the [official RingCentral SDKs](https://github.com/ringcentral). The SDK helper additions are included to make it easier to interact with features of the API.
|
13
13
|
|
14
|
+
Preliminary documentation can be found on [Read the Docs](http://ringcentral-sdk-ruby.readthedocs.org/).
|
15
|
+
|
14
16
|
This SDK is an early stage library and subject to breaking changes.
|
15
17
|
|
16
18
|
## Included
|
17
19
|
|
18
20
|
* OAuth authorization
|
21
|
+
* OAuth token refresh
|
19
22
|
* Faraday client with OAuth bearer token handling
|
20
23
|
* Fax helper to create multipart/mixed messages
|
21
24
|
|
@@ -23,9 +26,8 @@ This SDK is an early stage library and subject to breaking changes.
|
|
23
26
|
|
24
27
|
The following items are still needed for this SDK. Contributions are most welcome.
|
25
28
|
|
26
|
-
* Token refresh
|
27
29
|
* Subscriptions
|
28
|
-
*
|
30
|
+
* Mock tests
|
29
31
|
|
30
32
|
Installation
|
31
33
|
============
|
@@ -125,7 +127,6 @@ fax = RingCentralSdk::Helpers::CreateFaxRequest.new(
|
|
125
127
|
{
|
126
128
|
# phone numbers are in E.164 format with or without leading '+'
|
127
129
|
:to => [{ :phoneNumber => '+16505551212' }],
|
128
|
-
:faxResolution => 'High',
|
129
130
|
:coverPageText => 'RingCentral fax text demo using Ruby!'
|
130
131
|
},
|
131
132
|
:text => 'RingCentral Fax via Ruby!'
|
@@ -144,7 +145,6 @@ fax = RingCentralSdk::Helpers::CreateFaxRequest.new(
|
|
144
145
|
{
|
145
146
|
# phone numbers are in E.164 format with or without leading '+'
|
146
147
|
:to => [{ :phoneNumber => '+16505551212' }],
|
147
|
-
:faxResolution => 'High',
|
148
148
|
:coverPageText => 'RingCentral fax PDF demo using Ruby!'
|
149
149
|
},
|
150
150
|
:file_name => '/path/to/my_file.pdf'
|
@@ -162,7 +162,6 @@ fax = RingCentralSdk::Helpers::CreateFaxRequest.new(
|
|
162
162
|
{
|
163
163
|
# phone numbers are in E.164 format with or without leading '+'
|
164
164
|
:to => [{ :phoneNumber => '+16505551212' }],
|
165
|
-
:faxResolution => 'High',
|
166
165
|
:coverPageText => 'RingCentral fax TIFF base64 demo using Ruby!'
|
167
166
|
},
|
168
167
|
:file_name => '/path/to/my_file.tif',
|
data/VERSION.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
@@ -7,7 +7,7 @@ module RingCentralSdk::Helpers
|
|
7
7
|
class CreateFaxRequest < RingCentralSdk::Helpers::Request
|
8
8
|
attr_reader :msg
|
9
9
|
|
10
|
-
def initialize(path_params=nil,metadata=nil,options=nil)
|
10
|
+
def initialize(path_params=nil, metadata=nil, options=nil)
|
11
11
|
|
12
12
|
@msg = MIME::Multipart::Mixed.new
|
13
13
|
@msg.headers.delete('Content-Id')
|
@@ -20,85 +20,83 @@ module RingCentralSdk::Helpers
|
|
20
20
|
|
21
21
|
if options.is_a?(Hash)
|
22
22
|
if options.has_key?(:file_name)
|
23
|
-
|
24
|
-
add_file_base64(options[:file_name],options[:file_content_type])
|
25
|
-
else
|
26
|
-
add_file_octet_stream(options[:file_name])
|
27
|
-
end
|
23
|
+
add_file(options[:file_name], options[:file_content_type], options[:base64_encode])
|
28
24
|
elsif options.has_key?(:text)
|
29
25
|
add_file_text(options[:text])
|
30
26
|
end
|
31
27
|
end
|
32
28
|
end
|
33
29
|
|
34
|
-
def add_metadata(
|
35
|
-
|
36
|
-
|
30
|
+
def add_metadata(meta=nil)
|
31
|
+
meta = inflate_metadata(meta)
|
32
|
+
json = MultiJson.encode(meta)
|
33
|
+
json_part = MIME::Text.new(json)
|
34
|
+
json_part.headers.delete('Content-Id')
|
35
|
+
json_part.headers.set('Content-Type','application/json')
|
36
|
+
@msg.add(json_part)
|
37
|
+
return true
|
38
|
+
end
|
39
|
+
|
40
|
+
def inflate_metadata(meta=nil)
|
41
|
+
if meta.is_a?(String)
|
42
|
+
meta = MultiJson.decode(meta,:symbolize_keys=>true)
|
37
43
|
end
|
38
|
-
if
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
+
if meta.is_a?(Hash)
|
45
|
+
inf = RingCentralSdk::Helpers::Inflator::ContactInfo.new
|
46
|
+
|
47
|
+
if meta.has_key?(:to)
|
48
|
+
meta[:to] = inf.inflate_to_array( meta[:to] )
|
49
|
+
elsif meta.has_key?("to")
|
50
|
+
meta["to"] = inf.inflate_to_array( meta["to"] )
|
51
|
+
else
|
52
|
+
meta[:to] = inf.inflate_to_array( nil )
|
53
|
+
end
|
44
54
|
end
|
45
|
-
return
|
55
|
+
return meta
|
46
56
|
end
|
47
57
|
|
48
|
-
def add_file_text(text=nil,charset='UTF-8')
|
58
|
+
def add_file_text(text=nil, charset='UTF-8')
|
49
59
|
return unless text.is_a?(String)
|
50
60
|
text_part = MIME::Text.new(text,'plain')
|
51
61
|
text_part.headers.delete('Content-Id')
|
52
62
|
@msg.add(text_part)
|
53
63
|
end
|
54
64
|
|
55
|
-
def
|
56
|
-
|
57
|
-
return false
|
58
|
-
end
|
59
|
-
|
60
|
-
content_type = (content_type.is_a?(String) && content_type =~ /^[^\/\s]+\/[^\/\s]+/) \
|
61
|
-
? content_type : MIME::Types.type_for(file_name).first.content_type
|
62
|
-
|
63
|
-
base_name = File.basename(file_name)
|
64
|
-
file_base64 = Base64.encode64(File.binread(file_name))
|
65
|
+
def add_file(file_name=nil, content_type=nil, base64_encode=false)
|
66
|
+
file_part = get_file_part(file_name, content_type, base64_encode)
|
65
67
|
|
66
|
-
|
67
|
-
base64_part.headers.delete('Content-Id')
|
68
|
-
base64_part.headers.set('Content-Type', content_type)
|
69
|
-
base64_part.headers.set('Content-Transfer-Encoding','base64')
|
70
|
-
if base_name.is_a?(String) && base_name.length>0
|
71
|
-
base64_part.headers.set('Content-Disposition', "attachment; filename=\"#{base_name}\"")
|
72
|
-
else
|
73
|
-
base64_part.headers.set('Content-Disposition', 'attachment')
|
74
|
-
end
|
75
|
-
|
76
|
-
@msg.add(base64_part)
|
68
|
+
@msg.add(file_part)
|
77
69
|
return true
|
78
70
|
end
|
79
71
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
72
|
+
def get_file_part(file_name=nil, content_type=nil, base64_encode=false)
|
73
|
+
|
74
|
+
unless File.file?(file_name.to_s)
|
75
|
+
raise "File \"#{file_name.to_s}\" does not exist or cannot be read"
|
83
76
|
end
|
84
77
|
|
85
|
-
|
86
|
-
?
|
78
|
+
file_part = base64_encode \
|
79
|
+
? MIME::Text.new(Base64.encode64(File.binread(file_name))) \
|
80
|
+
: MIME::Application.new(File.binread(file_name))
|
81
|
+
file_part.headers.delete('Content-Id')
|
82
|
+
file_part.headers.set('Content-Type', get_file_content_type(file_name, content_type))
|
83
|
+
file_part.headers.set('Content-Disposition', get_attachment_content_disposition(file_name))
|
84
|
+
file_part.headers.set('Content-Transfer-Encoding', 'base64') if base64_encode
|
85
|
+
return file_part
|
86
|
+
end
|
87
87
|
|
88
|
-
|
89
|
-
|
88
|
+
def get_file_content_type(file_name=nil, content_type=nil)
|
89
|
+
return (content_type.is_a?(String) && content_type =~ /^[^\/\s]+\/[^\/\s]+/) \
|
90
|
+
? content_type : MIME::Types.type_for(file_name).first.content_type || 'application/octet-stream'
|
91
|
+
end
|
90
92
|
|
91
|
-
|
92
|
-
|
93
|
-
file_part.headers.set('Content-Type', content_type)
|
93
|
+
def get_attachment_content_disposition(file_name=nil)
|
94
|
+
base_name = File.basename(file_name.to_s)
|
94
95
|
if base_name.is_a?(String) && base_name.length>0
|
95
|
-
|
96
|
+
return "attachment; filename=\"#{base_name}\""
|
96
97
|
else
|
97
|
-
|
98
|
+
return 'attachment'
|
98
99
|
end
|
99
|
-
|
100
|
-
@msg.add(file_part)
|
101
|
-
return true
|
102
100
|
end
|
103
101
|
|
104
102
|
def method()
|
@@ -106,26 +104,22 @@ module RingCentralSdk::Helpers
|
|
106
104
|
end
|
107
105
|
|
108
106
|
def url()
|
109
|
-
|
110
|
-
|
107
|
+
|
108
|
+
vals = {:account_id => '~', :extension_id => '~'}
|
109
|
+
|
111
110
|
if @path_params.is_a?(Hash)
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
119
|
-
if @path_params.has_key?(:extension_id)
|
120
|
-
if @path_params[:extension_id].is_a?(String) && @path_params[:extension_id].length>0
|
121
|
-
extension_id = @path_params[:extension_id]
|
122
|
-
elsif @path_params[:extension_id].is_a?(Integer) && @path_params[:extension_id]>0
|
123
|
-
extension_id = @path_params[:extension_id].to_s
|
111
|
+
vals.keys.each do |key|
|
112
|
+
next unless @path_params.has_key?(key)
|
113
|
+
if @path_params[key].is_a?(String) && @path_params[key].length>0
|
114
|
+
vals[key] = @path_params[key]
|
115
|
+
elsif @path_params[key].is_a?(Integer) && @path_params[key]>0
|
116
|
+
vals[key] = @path_params[key].to_s
|
124
117
|
end
|
125
118
|
end
|
126
119
|
end
|
127
|
-
|
128
|
-
return
|
120
|
+
|
121
|
+
return "account/#{vals[:account_id].to_s}/extension/#{vals[:extension_id].to_s}/fax"
|
122
|
+
|
129
123
|
end
|
130
124
|
|
131
125
|
def content_type()
|
@@ -137,15 +131,15 @@ module RingCentralSdk::Helpers
|
|
137
131
|
end
|
138
132
|
|
139
133
|
# Experimental
|
140
|
-
def _add_file(file_name=nil)
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
end
|
149
|
-
private :_add_file
|
134
|
+
#def _add_file(file_name=nil)
|
135
|
+
# if file_name.is_a?(String) && File.file?(file_name)
|
136
|
+
# file_msg = MIME::DiscreteMediaFactory.create(file_name)
|
137
|
+
# file_msg.headers.delete('Content-Id')
|
138
|
+
# @msg.add(file_msg)
|
139
|
+
# return true
|
140
|
+
# end
|
141
|
+
# return false
|
142
|
+
#end
|
143
|
+
#private :_add_file
|
150
144
|
end
|
151
145
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module RingCentralSdk::Helpers::Inflator
|
2
|
+
class ContactInfo
|
3
|
+
def inflate_to_array(any=nil)
|
4
|
+
contacts = []
|
5
|
+
if any.is_a?(Array)
|
6
|
+
contacts = any
|
7
|
+
elsif any.is_a?(Hash)
|
8
|
+
contacts = [any]
|
9
|
+
elsif any.is_a?(String) || any.is_a?(Integer)
|
10
|
+
contacts = [{:phoneNumber=>any}]
|
11
|
+
end
|
12
|
+
return contacts
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'base64'
|
2
2
|
require 'faraday'
|
3
3
|
require 'faraday_middleware'
|
4
|
+
require 'faraday_middleware/oauth2_refresh'
|
5
|
+
require 'oauth2'
|
4
6
|
|
5
7
|
module RingCentralSdk::Platform
|
6
8
|
class Platform
|
@@ -15,21 +17,16 @@ module RingCentralSdk::Platform
|
|
15
17
|
API_VERSION = 'v1.0'
|
16
18
|
URL_PREFIX = '/restapi'
|
17
19
|
|
18
|
-
attr_reader
|
20
|
+
attr_reader :client
|
21
|
+
attr_accessor :server_url
|
19
22
|
|
20
|
-
def initialize(app_key='',app_secret='',server_url=
|
23
|
+
def initialize(app_key='', app_secret='', server_url=RingCentralSdk::Sdk::RC_SERVER_SANDBOX)
|
21
24
|
|
22
25
|
@app_key = app_key
|
23
26
|
@app_secret = app_secret
|
24
27
|
@server_url = server_url
|
25
|
-
@
|
26
|
-
|
27
|
-
@client = Faraday.new(:url => get_api_version_url()) do |conn|
|
28
|
-
conn.request :json
|
29
|
-
conn.request :url_encoded
|
30
|
-
conn.response :json, :content_type => 'application/json'
|
31
|
-
conn.adapter Faraday.default_adapter
|
32
|
-
end
|
28
|
+
@token = nil
|
29
|
+
@client = nil
|
33
30
|
|
34
31
|
end
|
35
32
|
|
@@ -37,33 +34,36 @@ module RingCentralSdk::Platform
|
|
37
34
|
return @server_url + URL_PREFIX + '/' + API_VERSION
|
38
35
|
end
|
39
36
|
|
40
|
-
def authorize(username='',extension='',password='',remember=false)
|
37
|
+
def authorize(username='', extension='', password='', remember=false)
|
41
38
|
|
42
|
-
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:extension => extension.is_a?(String) || extension.is_a?(Integer) ? extension : '',
|
46
|
-
:password => password,
|
47
|
-
:access_token_ttl => ACCESS_TOKEN_TTL,
|
48
|
-
:refresh_token_ttl => remember ? REFRESH_TOKEN_TTL_REMEMBER : REFRESH_TOKEN_TTL
|
49
|
-
})
|
39
|
+
oauth2 = OAuth2::Client.new(@app_key, @app_secret,
|
40
|
+
:site => @server_url,
|
41
|
+
:token_url => TOKEN_ENDPOINT)
|
50
42
|
|
51
|
-
|
52
|
-
|
43
|
+
token = oauth2.password.get_token(username, password, {
|
44
|
+
:extension => extension,
|
45
|
+
:headers => { 'Authorization' => 'Basic ' + get_api_key() } })
|
53
46
|
|
54
|
-
|
55
|
-
@client.headers['Authorization'] = 'Bearer ' + response.body["access_token"]
|
56
|
-
end
|
47
|
+
authorized(token)
|
57
48
|
|
58
|
-
return response
|
59
49
|
end
|
60
50
|
|
61
|
-
|
62
|
-
|
51
|
+
def authorized(token=nil)
|
52
|
+
@token = token
|
53
|
+
|
54
|
+
@client = Faraday.new(:url => get_api_version_url()) do |conn|
|
55
|
+
conn.request :oauth2_refresh, @token
|
56
|
+
conn.request :json
|
57
|
+
conn.request :url_encoded
|
58
|
+
conn.response :json, :content_type => 'application/json'
|
59
|
+
conn.adapter Faraday.default_adapter
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
63
|
|
64
64
|
def get_api_key()
|
65
65
|
api_key = (@app_key.is_a?(String) && @app_secret.is_a?(String)) \
|
66
|
-
? Base64.
|
66
|
+
? Base64.strict_encode64("#{@app_key}:#{@app_secret}") : ''
|
67
67
|
return api_key
|
68
68
|
end
|
69
69
|
|
@@ -74,17 +74,6 @@ module RingCentralSdk::Platform
|
|
74
74
|
return ''
|
75
75
|
end
|
76
76
|
|
77
|
-
def _auth_call(queryParams={},body={})
|
78
|
-
return @client.post do |req|
|
79
|
-
req.url TOKEN_ENDPOINT
|
80
|
-
req.headers['Authorization'] = 'Basic ' + get_api_key()
|
81
|
-
req.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
|
82
|
-
if body.is_a?(Hash) && body.size > 0
|
83
|
-
req.body = body
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
77
|
def request(helper=nil)
|
89
78
|
unless helper.is_a?(RingCentralSdk::Helpers::Request)
|
90
79
|
raise 'Request is not a RingCentralSdk::Helpers::Request'
|
@@ -101,6 +90,6 @@ module RingCentralSdk::Platform
|
|
101
90
|
return nil
|
102
91
|
end
|
103
92
|
|
104
|
-
private :
|
93
|
+
private :get_api_version_url
|
105
94
|
end
|
106
95
|
end
|
data/lib/ringcentral_sdk/sdk.rb
CHANGED
@@ -4,11 +4,11 @@ module RingCentralSdk
|
|
4
4
|
RC_SERVER_PRODUCTION = 'https://platform.ringcentral.com'
|
5
5
|
RC_SERVER_SANDBOX = 'https://platform.devtest.ringcentral.com'
|
6
6
|
|
7
|
-
attr_reader :parser
|
7
|
+
#attr_reader :parser
|
8
8
|
attr_reader :platform
|
9
9
|
|
10
10
|
def initialize(app_key=nil,app_secret=nil,server_url=nil,username=nil,extension=nil,password=nil)
|
11
|
-
|
11
|
+
#@parser = RingCentralSdk::Platform::Parser.new
|
12
12
|
@platform = RingCentralSdk::Platform::Platform.new(app_key, app_secret, server_url)
|
13
13
|
if not username.nil? and not password.nil?
|
14
14
|
@platform.authorize(username, extension, password)
|
data/test/test_setup.rb
CHANGED
@@ -11,7 +11,6 @@ class RingCentralSdkTest < Test::Unit::TestCase
|
|
11
11
|
|
12
12
|
assert_equal "RingCentralSdk::Sdk", rcsdk.class.name
|
13
13
|
assert_equal "RingCentralSdk::Platform::Platform", rcsdk.platform.class.name
|
14
|
-
assert_equal "Faraday::Connection", rcsdk.platform.client.class.name
|
15
14
|
|
16
15
|
end
|
17
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ringcentral_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -51,12 +51,9 @@ dependencies:
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
54
|
+
name: faraday_middleware-oauth2_refresh
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - ~>
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '0'
|
60
57
|
- - '>='
|
61
58
|
- !ruby/object:Gem::Version
|
62
59
|
version: '0'
|
@@ -64,9 +61,20 @@ dependencies:
|
|
64
61
|
prerelease: false
|
65
62
|
version_requirements: !ruby/object:Gem::Requirement
|
66
63
|
requirements:
|
67
|
-
- -
|
64
|
+
- - '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: mime
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - '>='
|
68
72
|
- !ruby/object:Gem::Version
|
69
73
|
version: '0'
|
74
|
+
type: :runtime
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
70
78
|
- - '>='
|
71
79
|
- !ruby/object:Gem::Version
|
72
80
|
version: '0'
|
@@ -94,9 +102,6 @@ dependencies:
|
|
94
102
|
name: multi_json
|
95
103
|
requirement: !ruby/object:Gem::Requirement
|
96
104
|
requirements:
|
97
|
-
- - ~>
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version: '0'
|
100
105
|
- - '>='
|
101
106
|
- !ruby/object:Gem::Version
|
102
107
|
version: '0'
|
@@ -104,9 +109,20 @@ dependencies:
|
|
104
109
|
prerelease: false
|
105
110
|
version_requirements: !ruby/object:Gem::Requirement
|
106
111
|
requirements:
|
107
|
-
- -
|
112
|
+
- - '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: oauth2
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - '>='
|
108
120
|
- !ruby/object:Gem::Version
|
109
121
|
version: '0'
|
122
|
+
type: :runtime
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
110
126
|
- - '>='
|
111
127
|
- !ruby/object:Gem::Version
|
112
128
|
version: '0'
|
@@ -124,10 +140,10 @@ files:
|
|
124
140
|
- lib/ringcentral_sdk.rb
|
125
141
|
- lib/ringcentral_sdk/helpers.rb
|
126
142
|
- lib/ringcentral_sdk/helpers/fax.rb
|
143
|
+
- lib/ringcentral_sdk/helpers/inflator.rb
|
144
|
+
- lib/ringcentral_sdk/helpers/inflator/contact_info.rb
|
127
145
|
- lib/ringcentral_sdk/helpers/request.rb
|
128
146
|
- lib/ringcentral_sdk/platform.rb
|
129
|
-
- lib/ringcentral_sdk/platform/auth.rb
|
130
|
-
- lib/ringcentral_sdk/platform/parser.rb
|
131
147
|
- lib/ringcentral_sdk/platform/platform.rb
|
132
148
|
- lib/ringcentral_sdk/sdk.rb
|
133
149
|
- test/test_setup.rb
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'time'
|
2
|
-
|
3
|
-
module RingCentralSdk::Platform
|
4
|
-
class Auth
|
5
|
-
attr_accessor :data
|
6
|
-
attr_accessor :remember
|
7
|
-
|
8
|
-
attr_reader :access_token
|
9
|
-
attr_reader :token_type
|
10
|
-
|
11
|
-
def initialize()
|
12
|
-
@data = nil
|
13
|
-
@remember = nil
|
14
|
-
end
|
15
|
-
def set_data(data={})
|
16
|
-
return false unless data.is_a?(Hash)
|
17
|
-
|
18
|
-
@access_token = data["access_token"] ? data["access_token"] : ''
|
19
|
-
@expire_time = data["expire_time"] ? data["expire_time"] : 0
|
20
|
-
@token_type = data["token_type"] ? data["token_type"] : ''
|
21
|
-
|
22
|
-
@data = data
|
23
|
-
return true
|
24
|
-
end
|
25
|
-
|
26
|
-
def is_access_token_valid()
|
27
|
-
return _is_token_date_valid(@expire_time)
|
28
|
-
end
|
29
|
-
|
30
|
-
def _is_token_date_valid(token_date=nil)
|
31
|
-
return false unless token_date.is_a?(Integer)
|
32
|
-
return token_date > Time.now.to_i
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|