ringcentral_sdk 0.5.2 → 1.0.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 +7 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +96 -0
- data/README.md +66 -92
- data/Rakefile +3 -3
- data/lib/ringcentral_sdk/{cache → rest/cache}/extensions.rb +17 -19
- data/lib/ringcentral_sdk/rest/cache.rb +3 -0
- data/lib/ringcentral_sdk/{platform.rb → rest/client.rb} +61 -55
- data/lib/ringcentral_sdk/rest/config.rb +93 -0
- data/lib/ringcentral_sdk/rest/extension.rb +12 -0
- data/lib/ringcentral_sdk/rest/extension_presence.rb +104 -0
- data/lib/ringcentral_sdk/rest/messages.rb +46 -0
- data/lib/ringcentral_sdk/{helpers/request.rb → rest/request/base.rb} +2 -2
- data/lib/ringcentral_sdk/rest/request/fax.rb +121 -0
- data/lib/ringcentral_sdk/{helpers → rest/request}/inflator/contact_info.rb +1 -1
- data/lib/ringcentral_sdk/rest/request/inflator.rb +3 -0
- data/lib/ringcentral_sdk/rest/request.rb +5 -0
- data/lib/ringcentral_sdk/{simple.rb → rest/simple_client.rb} +10 -10
- data/lib/ringcentral_sdk/{subscription.rb → rest/subscription.rb} +8 -8
- data/lib/ringcentral_sdk/rest.rb +15 -0
- data/lib/ringcentral_sdk.rb +3 -7
- data/mkdocs.yml +30 -0
- data/ringcentral_sdk-0.5.2.gem +0 -0
- data/ringcentral_sdk.gemspec +31 -0
- data/test/{test_helper.rb → test_base.rb} +3 -3
- data/test/{test_platform.rb → test_client.rb} +58 -28
- data/test/test_config.rb +29 -0
- data/test/test_extension_presence.rb +154 -0
- data/test/test_helper_fax.rb +42 -39
- data/test/test_helper_inflator_contact_info.rb +3 -3
- data/test/test_helper_request.rb +3 -4
- data/test/test_setup.rb +4 -4
- data/test/test_subscription.rb +9 -9
- metadata +95 -48
- data/lib/ringcentral_sdk/cache.rb +0 -3
- data/lib/ringcentral_sdk/helpers/extension_presence.rb +0 -129
- data/lib/ringcentral_sdk/helpers/fax.rb +0 -160
- data/lib/ringcentral_sdk/helpers/inflator.rb +0 -3
- data/lib/ringcentral_sdk/helpers/messages.rb +0 -19
- data/lib/ringcentral_sdk/helpers.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df5aca1bce66925c5e3e14d134fba3f5b53625e9
|
4
|
+
data.tar.gz: 811bac728f717e58b0ab0f7c5c1b420468103c3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99e6878c0e06d67cd959eabad0ae6291714f7d11e9ab00f8d22de5fcd72f873ccbca7001f0b4fd097c1899c2c6f04be1f2b7edcac6129e9d8d049fa751ec7763
|
7
|
+
data.tar.gz: 2878c4c401b37fbe11c2ca7b7a3066bedcc5f62542f8de8dfb1071070608d0deea9b131f580ec8b2dd19f43d644ffa8c788e98031afba5832fa43a0f86b012a6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
|
+
- **2016-01-23**: 0.9.0
|
4
|
+
- Major refactor
|
5
|
+
- Add `RingCentral::REST::Config` and dotenv support
|
6
|
+
- **2016-01-22**: 0.5.2
|
7
|
+
- Add `RingCentralSdk::Cache::Extensions`
|
8
|
+
- Add `RingCentralSdk::Helpers::ExtensionPresence`
|
9
|
+
- Add Call Queue Member Status mydocs documentation
|
3
10
|
- **2015-12-08**: 0.5.1
|
4
11
|
- Add call recording transcription demo script via VoiceBase
|
5
12
|
- Fix PubNub unsubscribe bug
|
data/Gemfile
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
source ENV['GEM_SOURCE'] ||
|
1
|
+
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
|
2
2
|
|
3
3
|
gem 'coveralls'
|
4
|
+
gem 'dotenv'
|
4
5
|
gem 'faraday', '~> 0.9.0'
|
5
6
|
gem 'faraday_middleware'
|
6
7
|
gem 'faraday_middleware-oauth2_refresh'
|
7
8
|
gem 'logger'
|
8
9
|
gem 'mime'
|
9
10
|
gem 'mime-types'
|
11
|
+
gem 'mime_builder'
|
10
12
|
gem 'mocha'
|
11
13
|
gem 'multi_json'
|
12
14
|
gem 'oauth2'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
coveralls (0.8.10)
|
5
|
+
json (~> 1.8)
|
6
|
+
rest-client (>= 1.6.8, < 2)
|
7
|
+
simplecov (~> 0.11.0)
|
8
|
+
term-ansicolor (~> 1.3)
|
9
|
+
thor (~> 0.19.1)
|
10
|
+
tins (~> 1.6.0)
|
11
|
+
docile (1.1.5)
|
12
|
+
domain_name (0.5.25)
|
13
|
+
unf (>= 0.0.5, < 1.0.0)
|
14
|
+
dotenv (2.1.0)
|
15
|
+
eventmachine (1.0.9.1)
|
16
|
+
faraday (0.9.2)
|
17
|
+
multipart-post (>= 1.2, < 3)
|
18
|
+
faraday_middleware (0.10.0)
|
19
|
+
faraday (>= 0.7.4, < 0.10)
|
20
|
+
faraday_middleware-oauth2_refresh (0.0.2)
|
21
|
+
faraday (~> 0.9, >= 0.9)
|
22
|
+
faraday_middleware (~> 0, >= 0)
|
23
|
+
hitimes (1.2.3)
|
24
|
+
http-cookie (1.0.2)
|
25
|
+
domain_name (~> 0.5)
|
26
|
+
json (1.8.3)
|
27
|
+
jwt (1.5.2)
|
28
|
+
logger (1.2.8)
|
29
|
+
metaclass (0.0.4)
|
30
|
+
mime (0.4.3)
|
31
|
+
mime-types (2.99)
|
32
|
+
mime_builder (0.0.2)
|
33
|
+
mime
|
34
|
+
mime-types (>= 1.25)
|
35
|
+
mocha (1.1.0)
|
36
|
+
metaclass (~> 0.0.1)
|
37
|
+
multi_json (1.11.2)
|
38
|
+
multi_xml (0.5.5)
|
39
|
+
multipart-post (2.0.0)
|
40
|
+
net-http-persistent (2.9.4)
|
41
|
+
netrc (0.11.0)
|
42
|
+
oauth2 (1.0.0)
|
43
|
+
faraday (>= 0.8, < 0.10)
|
44
|
+
jwt (~> 1.0)
|
45
|
+
multi_json (~> 1.3)
|
46
|
+
multi_xml (~> 0.5)
|
47
|
+
rack (~> 1.2)
|
48
|
+
power_assert (0.2.7)
|
49
|
+
pubnub (3.7.10)
|
50
|
+
eventmachine (~> 1.0)
|
51
|
+
json (~> 1.8)
|
52
|
+
net-http-persistent (~> 2.9)
|
53
|
+
rack (1.6.4)
|
54
|
+
rake (10.5.0)
|
55
|
+
rest-client (1.8.0)
|
56
|
+
http-cookie (>= 1.0.2, < 2.0)
|
57
|
+
mime-types (>= 1.16, < 3.0)
|
58
|
+
netrc (~> 0.7)
|
59
|
+
simplecov (0.11.1)
|
60
|
+
docile (~> 1.1.0)
|
61
|
+
json (~> 1.8)
|
62
|
+
simplecov-html (~> 0.10.0)
|
63
|
+
simplecov-html (0.10.0)
|
64
|
+
term-ansicolor (1.3.2)
|
65
|
+
tins (~> 1.0)
|
66
|
+
test-unit (3.1.7)
|
67
|
+
power_assert
|
68
|
+
thor (0.19.1)
|
69
|
+
timers (4.1.1)
|
70
|
+
hitimes
|
71
|
+
tins (1.6.0)
|
72
|
+
unf (0.1.4)
|
73
|
+
unf_ext
|
74
|
+
unf_ext (0.0.7.1)
|
75
|
+
|
76
|
+
PLATFORMS
|
77
|
+
ruby
|
78
|
+
|
79
|
+
DEPENDENCIES
|
80
|
+
coveralls
|
81
|
+
dotenv
|
82
|
+
faraday (~> 0.9.0)
|
83
|
+
faraday_middleware
|
84
|
+
faraday_middleware-oauth2_refresh
|
85
|
+
logger
|
86
|
+
mime
|
87
|
+
mime-types
|
88
|
+
mime_builder
|
89
|
+
mocha
|
90
|
+
multi_json
|
91
|
+
oauth2
|
92
|
+
pubnub (~> 3.7.3)
|
93
|
+
rake
|
94
|
+
simplecov
|
95
|
+
test-unit
|
96
|
+
timers
|
data/README.md
CHANGED
@@ -15,7 +15,6 @@ RingCentral SDK for Ruby
|
|
15
15
|
## Table of contents
|
16
16
|
|
17
17
|
1. [Overview](#overview)
|
18
|
-
1. [Included](#included)
|
19
18
|
2. [Documentation](#documentation)
|
20
19
|
3. [Installation](#installation)
|
21
20
|
4. [Usage](#usage)
|
@@ -37,16 +36,7 @@ RingCentral SDK for Ruby
|
|
37
36
|
|
38
37
|
## Overview
|
39
38
|
|
40
|
-
A
|
41
|
-
|
42
|
-
### Included
|
43
|
-
|
44
|
-
* Authorization via `OAuth2` with authorization code and password grant flows including token refresh
|
45
|
-
* Generic API requests via `Faraday` client
|
46
|
-
* Subscriptions via `Pubnub` with auto-decryption
|
47
|
-
* Fax request helper to create `multipart/mixed` messages
|
48
|
-
* Unit test suite via `Test::Unit` and `mocha`
|
49
|
-
* Docs via [Read the Docs](http://ringcentral-sdk-ruby.readthedocs.org/) and [RubyDoc](http://www.rubydoc.info/gems/ringcentral_sdk/)
|
39
|
+
A library for using the [RingCentral REST API](https://developers.ringcentral.com). [Click here to read the full documentation](http://ringcentral-sdk-ruby.readthedocs.org/).
|
50
40
|
|
51
41
|
## Documentation
|
52
42
|
|
@@ -89,106 +79,78 @@ This provides a very basic guide to using the SDK. Please use the following reso
|
|
89
79
|
2. [SDK Reference](http://www.rubydoc.info/gems/ringcentral_sdk/).
|
90
80
|
1. [API Developer and Reference Guide](https://developers.ringcentral.com/api-docs/latest/index.html)
|
91
81
|
|
92
|
-
### Instantiation
|
82
|
+
### Instantiation and Authorization
|
83
|
+
|
84
|
+
How you instantiate the SDK can depend on whether you use OAuth 2.0 password grant or the authorization code grant which are both described here.
|
93
85
|
|
94
|
-
|
86
|
+
It is also necessary to specify your RingCentral API end point URL which are included constants:
|
95
87
|
|
96
88
|
* `RingCentralSdk::RC_SERVER_PRODUCTION`
|
97
89
|
* `RingCentralSdk::RC_SERVER_SANDBOX`
|
98
90
|
|
91
|
+
#### Password Grant
|
92
|
+
|
93
|
+
The OAuth 2.0 resource owner password grant flow is designed for server applications where the app and resource owners are the same.
|
94
|
+
|
99
95
|
```ruby
|
100
96
|
require 'ringcentral_sdk'
|
101
97
|
|
102
98
|
# Returns RingCentralSdk::Platform instance
|
103
|
-
|
99
|
+
client = RingCentralSdk::REST::Client.new(
|
104
100
|
'myAppKey',
|
105
101
|
'myAppSecret',
|
106
102
|
RingCentralSdk::RC_SERVER_SANDBOX
|
107
103
|
)
|
108
|
-
```
|
109
|
-
|
110
|
-
### Authorization
|
111
|
-
|
112
|
-
#### Password Grant
|
113
104
|
|
114
|
-
|
115
|
-
|
116
|
-
```ruby
|
117
|
-
# Initialize using main phone number and extension number
|
118
|
-
rcsdk.authorize('myUsername', 'myExtension', 'myPassword')
|
119
|
-
|
120
|
-
# Initialize using user phone number without extension number
|
121
|
-
# Extension defaults to company admin extension
|
122
|
-
rcsdk.authorize('myUsername', nil, 'myPassword')
|
105
|
+
# extension will default to company admin extension if not provided
|
106
|
+
client.authorize_password('myUsername', 'myExtension', 'myPassword')
|
123
107
|
```
|
124
108
|
|
125
109
|
#### Authorization Code Grant
|
126
110
|
|
127
|
-
The
|
111
|
+
The OAuth 2.0 authorization code grant is designed for where authorization needs to be granted by a 3rd party resource owner.
|
128
112
|
|
129
113
|
Using the default authorization URL:
|
130
114
|
|
131
115
|
```ruby
|
132
116
|
# Initialize SDK with OAuth redirect URI
|
133
|
-
|
117
|
+
client = RingCentralSdk::REST::Client.new(
|
134
118
|
'myAppKey',
|
135
119
|
'myAppSecret',
|
136
120
|
RingCentralSdk::RC_SERVER_SANDBOX,
|
137
121
|
{:redirect_uri => 'http://example.com/oauth'}
|
138
122
|
)
|
139
|
-
# Retrieve OAuth authorize url using default redirect URL
|
140
|
-
auth_url = rcsdk.authorize_url()
|
141
|
-
```
|
142
123
|
|
143
|
-
|
144
|
-
|
145
|
-
```ruby
|
146
|
-
rcapi = RingCentralSdk.new(
|
147
|
-
'myAppKey',
|
148
|
-
'myAppSecret',
|
149
|
-
RingCentralSdk::RC_SERVER_SANDBOX
|
150
|
-
)
|
151
|
-
# Retrieve OAuth authorize url using override redirect URL
|
152
|
-
auth_url = rcapi.authorize_url({
|
153
|
-
:redirect_uri => 'my_registered_oauth_url', # optional override of default URL
|
154
|
-
:display => '', # optional: page|popup|touch|mobile, default 'page'
|
155
|
-
:prompt => '', # optional: sso|login|consent, default is 'login sso consent'
|
156
|
-
:state => '', # optional
|
157
|
-
:brand_id => '' # optional: string|number
|
158
|
-
})
|
159
|
-
# Open browser window to authorization url and retrieve authorize code from redirect uri.
|
124
|
+
# Retrieve OAuth authorize url using default redirect URL
|
125
|
+
auth_url = client.authorize_url()
|
160
126
|
```
|
161
127
|
|
162
128
|
On your redirect page, you can exchange your authorization code for an access token using the following:
|
163
129
|
|
164
130
|
```ruby
|
165
|
-
code = params['code'] # retrieve
|
166
|
-
|
131
|
+
code = params['code'] # e.g. using Sinatra to retrieve code param in Redirect URI
|
132
|
+
client.authorize_code(code)
|
167
133
|
```
|
168
134
|
|
169
|
-
|
135
|
+
More information on the authorization code flow:
|
136
|
+
|
137
|
+
1. [Full documentation](http://ringcentral-sdk-ruby.readthedocs.org/en/latest/usage/authorization/Authorization/#authorization-code-grant)
|
138
|
+
2. [Sinatra example](scripts/oauth2-sinatra)
|
170
139
|
|
171
|
-
####
|
140
|
+
#### Token Reuse
|
172
141
|
|
173
142
|
The platform class performs token refresh procedure automatically if needed. To save the access and refresh tokens between instances of the SDK, you can save and reuse the token as follows:
|
174
143
|
|
175
144
|
```ruby
|
176
|
-
#
|
177
|
-
|
178
|
-
token_hash = rcsdk.token.to_hash
|
145
|
+
# Access `OAuth2::AccessToken` object as hash
|
146
|
+
token_hash = client.token.to_hash
|
179
147
|
```
|
180
148
|
|
181
|
-
|
149
|
+
You can reload the token hash in another instance of the SDK as follows:
|
182
150
|
|
183
151
|
```ruby
|
184
|
-
# Reuse token_hash in another SDK instance
|
185
|
-
rcapi2 = RingCentralSdk.new(
|
186
|
-
'myAppKey',
|
187
|
-
'myAppSecret',
|
188
|
-
RingCentralSdk::RC_SERVER_SANDBOX
|
189
|
-
)
|
190
152
|
# set_token() accepts a hash or OAuth2::AccessToken object
|
191
|
-
|
153
|
+
client.set_token(token_hash)
|
192
154
|
```
|
193
155
|
|
194
156
|
Important! You have to manually maintain synchronization of SDK's between requests if you share authentication. When two simultaneous requests will perform refresh, only one will succeed. One of the solutions would be to have semaphor and pause other pending requests while one of them is performing refresh.
|
@@ -201,16 +163,18 @@ API requests can be made via the included `Faraday` client or `RingCentralSdk::H
|
|
201
163
|
|
202
164
|
#### Generic HTTP Requests
|
203
165
|
|
204
|
-
To make generic API requests, use included `Faraday` client which can be accessed via `
|
166
|
+
To make generic API requests, use included `Faraday` client which can be accessed via `client.http`. The client automatically adds the correct access token to the HTTP request and handles OAuth token refresh using the `OAuth` gem.
|
167
|
+
|
168
|
+
This is useful to access many API endpoints which do not have custom wrappers and for debugging purposes.
|
205
169
|
|
206
170
|
```ruby
|
207
|
-
|
171
|
+
http = client.http
|
208
172
|
```
|
209
173
|
|
210
174
|
#### SMS Example
|
211
175
|
|
212
176
|
```ruby
|
213
|
-
|
177
|
+
client.messages.sms.create(
|
214
178
|
:from => '+16505551212',
|
215
179
|
:to => '+14155551212',
|
216
180
|
:text => 'Hi there!'
|
@@ -219,38 +183,48 @@ rcapi.messages.create(
|
|
219
183
|
|
220
184
|
#### Fax Example
|
221
185
|
|
222
|
-
|
223
|
-
that can be called by the `.request()` method of the Platform object. This enables the
|
224
|
-
requisite information for Faraday to be generated in a standard way.
|
186
|
+
Fax files:
|
225
187
|
|
226
|
-
|
188
|
+
```ruby
|
189
|
+
client.messages.fax.create(
|
190
|
+
:to => '+14155551212',
|
191
|
+
:coverPageText => 'Hi there!',
|
192
|
+
:files => ['/path/to/myfile.pdf']
|
193
|
+
)
|
194
|
+
```
|
227
195
|
|
228
|
-
|
229
|
-
instantiating a fax helper object and then executing a Faraday POST request. The helper can then
|
230
|
-
be used with the standard faraday client or helper `.request()` method that takes the request
|
231
|
-
helper object in its entirety.
|
196
|
+
Fax text:
|
232
197
|
|
233
198
|
```ruby
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
# phone numbers are in E.164 format with or without leading '+'
|
239
|
-
:to => [{ :phoneNumber => '+16505551212' }],
|
240
|
-
:coverPageText => 'RingCentral fax PDF demo using Ruby!'
|
241
|
-
},
|
242
|
-
:file_name => '/path/to/my_file.pdf'
|
199
|
+
client.messages.fax.create(
|
200
|
+
:to => '+14155551212',
|
201
|
+
:coverPageText => 'Hi there!',
|
202
|
+
:text => 'Hi there!'
|
243
203
|
)
|
204
|
+
```
|
244
205
|
|
245
|
-
|
246
|
-
response = rcapi.request(fax)
|
206
|
+
#### Subscription Example
|
247
207
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
208
|
+
To make subscriptions with RingCentral, use the SDK object to create subscription Observer object and then add observers to it.
|
209
|
+
|
210
|
+
```ruby
|
211
|
+
# Create an observer object
|
212
|
+
class MyObserver
|
213
|
+
def update(message)
|
214
|
+
puts "Subscription Message Received"
|
215
|
+
puts JSON.dump(message)
|
216
|
+
end
|
253
217
|
end
|
218
|
+
|
219
|
+
# Create an observable subscription and add your observer
|
220
|
+
sub = client.create_subscription()
|
221
|
+
sub.add_observer(MyObserver.new())
|
222
|
+
|
223
|
+
# Subscribe to an arbitrary number of event filters
|
224
|
+
sub.subscribe(['/restapi/v1.0/account/~/extension/~/presence'])
|
225
|
+
|
226
|
+
# End the subscription
|
227
|
+
sub.destroy()
|
254
228
|
```
|
255
229
|
|
256
230
|
## Supported Ruby Versions
|
data/Rakefile
CHANGED
@@ -14,6 +14,6 @@ end
|
|
14
14
|
desc 'Generate YARD documentation.'
|
15
15
|
task :gendoc do
|
16
16
|
# puts 'yard doc generation disabled until JRuby build native extensions for redcarpet or yard removes the dependency.'
|
17
|
-
system
|
18
|
-
system
|
19
|
-
end
|
17
|
+
system 'yardoc'
|
18
|
+
system 'yard stats --list-undoc'
|
19
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
require 'time'
|
2
2
|
require 'uri'
|
3
3
|
|
4
|
-
module RingCentralSdk::Cache
|
4
|
+
module RingCentralSdk::REST::Cache
|
5
5
|
class Extensions
|
6
6
|
|
7
|
-
attr_accessor :
|
7
|
+
attr_accessor :client
|
8
8
|
attr_accessor :account_id
|
9
9
|
attr_reader :extensions_hash
|
10
10
|
attr_reader :extensions_num2id
|
11
11
|
attr_reader :last_retrieved
|
12
12
|
|
13
|
-
def initialize(
|
14
|
-
@
|
13
|
+
def initialize(client)
|
14
|
+
@client = client
|
15
15
|
@account_id = '~'
|
16
16
|
@extensions_hash = {}
|
17
17
|
@extensions_num2id = {}
|
@@ -24,7 +24,7 @@ module RingCentralSdk::Cache
|
|
24
24
|
if params.length > 0
|
25
25
|
uri.query = URI.encode_www_form params
|
26
26
|
end
|
27
|
-
res = @
|
27
|
+
res = @client.http.get do |req|
|
28
28
|
req.url uri.to_s
|
29
29
|
if retrieve_all
|
30
30
|
req.params['page'] = 1
|
@@ -32,17 +32,17 @@ module RingCentralSdk::Cache
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
res.body['records'].each do |extension|
|
35
|
-
if extension.
|
35
|
+
if extension.key?('id') && extension['id']>0
|
36
36
|
@extensions_hash[extension['id'].to_s] = extension
|
37
37
|
end
|
38
38
|
end
|
39
39
|
if retrieve_all
|
40
|
-
while res.body.
|
40
|
+
while res.body.key?('navigation') && res.body['navigation'].key?('nextPage')
|
41
41
|
res = rcsdk.client.get do |req|
|
42
42
|
req.url res.body['navigation']['nextPage']['uri']
|
43
43
|
end
|
44
44
|
res.body['records'].each do |record|
|
45
|
-
if extension.
|
45
|
+
if extension.key?('id') && extension['id'].length>0
|
46
46
|
@extensions_hash[extension['id'].to_s] = extension
|
47
47
|
end
|
48
48
|
end
|
@@ -59,8 +59,8 @@ module RingCentralSdk::Cache
|
|
59
59
|
def inflate_num2id()
|
60
60
|
num2id = {}
|
61
61
|
@extensions_hash.each do |k,v|
|
62
|
-
if v.
|
63
|
-
v.
|
62
|
+
if v.key?('id') && v['id']>0 &&
|
63
|
+
v.key?('extensionNumber') && v['extensionNumber'].length>0
|
64
64
|
num2id[v['extensionNumber']] = v['id'].to_s
|
65
65
|
end
|
66
66
|
end
|
@@ -72,7 +72,7 @@ module RingCentralSdk::Cache
|
|
72
72
|
if !extension_id.is_a?(String)
|
73
73
|
extension_id = extension_id.to_s
|
74
74
|
end
|
75
|
-
if @extensions_hash.
|
75
|
+
if @extensions_hash.key? extension_id
|
76
76
|
return @extensions_hash[extension_id]
|
77
77
|
end
|
78
78
|
return nil
|
@@ -82,9 +82,9 @@ module RingCentralSdk::Cache
|
|
82
82
|
if !extension_number.is_a?(String)
|
83
83
|
extension_number = extension_number.to_s
|
84
84
|
end
|
85
|
-
if @extensions_num2id.
|
85
|
+
if @extensions_num2id.key?(extension_number)
|
86
86
|
extension_id = @extensions_num2id[extension_number]
|
87
|
-
if @extensions_hash.
|
87
|
+
if @extensions_hash.key?(extension_id)
|
88
88
|
return @extensions_hash[extension_id]
|
89
89
|
end
|
90
90
|
end
|
@@ -101,17 +101,15 @@ module RingCentralSdk::Cache
|
|
101
101
|
|
102
102
|
members = []
|
103
103
|
|
104
|
-
res = @
|
104
|
+
res = @client.http.get do |req|
|
105
105
|
req.url "account/#{account_id}/department/#{department_id}/members"
|
106
106
|
end
|
107
107
|
|
108
|
-
if res.body.
|
108
|
+
if res.body.key? 'records'
|
109
109
|
res.body['records'].each do |extension|
|
110
|
-
if extension.
|
110
|
+
if extension.key? 'id'
|
111
111
|
member = get_extension_by_id extension['id']
|
112
|
-
|
113
|
-
members.push member
|
114
|
-
end
|
112
|
+
members.push member unless member.nil?
|
115
113
|
end
|
116
114
|
end
|
117
115
|
end
|