ringcentral_sdk 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +35 -81
- data/lib/ringcentral_sdk.rb +2 -1
- data/lib/ringcentral_sdk/cache.rb +3 -0
- data/lib/ringcentral_sdk/cache/extensions.rb +123 -0
- data/lib/ringcentral_sdk/helpers.rb +2 -0
- data/lib/ringcentral_sdk/helpers/extension_presence.rb +129 -0
- data/lib/ringcentral_sdk/helpers/messages.rb +19 -0
- data/lib/ringcentral_sdk/platform.rb +3 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96b95c556e178ef01ddbc722d0c3218957847cb0
|
4
|
+
data.tar.gz: 265aa9e0b869a20fd04a137e96639eb33ef63366
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4beda03bae9a21852650aea069973125272e0f9872450868588be2656ea3fc63129e0eb881191682c58db92715ac901cb858e2b96e014dd34d66738731491a4
|
7
|
+
data.tar.gz: 2841f8cd41b0db6df6fa5fd42a8faf7e83dafe3d35bf797c449fe456e5696b5fc0a02389f6f7eacbd87f9067187dccbf8fc593f82535a8df8012f025dd293ebf
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -7,6 +7,7 @@ RingCentral SDK for Ruby
|
|
7
7
|
[![Dependency Status][dependency-status-svg]][dependency-status-link]
|
8
8
|
[![Code Climate][codeclimate-status-svg]][codeclimate-status-link]
|
9
9
|
[![Scrutinizer Code Quality][scrutinizer-status-svg]][scrutinizer-status-link]
|
10
|
+
[![Downloads][downloads-svg]][downloads-link]
|
10
11
|
[![Docs][docs-readthedocs-svg]][docs-readthedocs-link]
|
11
12
|
[![Docs][docs-rubydoc-svg]][docs-rubydoc-link]
|
12
13
|
[![License][license-svg]][license-link]
|
@@ -15,7 +16,6 @@ RingCentral SDK for Ruby
|
|
15
16
|
|
16
17
|
1. [Overview](#overview)
|
17
18
|
1. [Included](#included)
|
18
|
-
2. [To Do](#to-do)
|
19
19
|
2. [Documentation](#documentation)
|
20
20
|
3. [Installation](#installation)
|
21
21
|
4. [Usage](#usage)
|
@@ -27,7 +27,6 @@ RingCentral SDK for Ruby
|
|
27
27
|
1. [Generic HTTP Requests](#generic-http-requests)
|
28
28
|
2. [SMS Example](#sms-example)
|
29
29
|
3. [Fax Example](#fax-example)
|
30
|
-
1. [Subscriptions](#subscriptions)
|
31
30
|
5. [Supported Ruby Versions](#supported-ruby-versions)
|
32
31
|
6. [Releases](#releases)
|
33
32
|
1. [Versioning](#versioning)
|
@@ -38,11 +37,7 @@ RingCentral SDK for Ruby
|
|
38
37
|
|
39
38
|
## Overview
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
The core SDK objects follow the general design of the [official RingCentral SDKs](https://github.com/ringcentral). Additional functionality is provided for ease of use including request helpers and generalized OAuth2 support.
|
44
|
-
|
45
|
-
This SDK is an early stage library and subject to breaking changes.
|
40
|
+
A gem for using the [RingCentral REST API](https://developers.ringcentral.com). [Click here to read the full documentation](http://ringcentral-sdk-ruby.readthedocs.org/)
|
46
41
|
|
47
42
|
### Included
|
48
43
|
|
@@ -53,16 +48,14 @@ This SDK is an early stage library and subject to breaking changes.
|
|
53
48
|
* Unit test suite via `Test::Unit` and `mocha`
|
54
49
|
* Docs via [Read the Docs](http://ringcentral-sdk-ruby.readthedocs.org/) and [RubyDoc](http://www.rubydoc.info/gems/ringcentral_sdk/)
|
55
50
|
|
56
|
-
|
51
|
+
## Documentation
|
57
52
|
|
58
|
-
|
53
|
+
Documentation is available on:
|
59
54
|
|
60
|
-
|
55
|
+
1. [Read the Docs](http://ringcentral-sdk-ruby.readthedocs.org/)
|
56
|
+
2. [RubyDoc](http://www.rubydoc.info/gems/ringcentral_sdk/).
|
61
57
|
|
62
|
-
|
63
|
-
and [RubyDoc](http://www.rubydoc.info/gems/ringcentral_sdk/). The documentation philosophy is to
|
64
|
-
use RubyDoc / YARD for brief documentation and code specific docs while using Read the Docs for
|
65
|
-
user guide / tutorial / FAQ style documentation.
|
58
|
+
Read the Docs is the primary documentation solution used, however, RubyDoc is useful for examining code.
|
66
59
|
|
67
60
|
In addition the documentation for this Ruby SDK, refer to the official RingCentral guides for
|
68
61
|
more information on individual API calls:
|
@@ -75,15 +68,10 @@ more information on individual API calls:
|
|
75
68
|
|
76
69
|
### Via Bundler
|
77
70
|
|
78
|
-
Add
|
79
|
-
|
80
|
-
```ruby
|
81
|
-
gem 'ringcentral_sdk'
|
82
|
-
```
|
83
|
-
|
84
|
-
And then execute:
|
71
|
+
Add 'ringcentral_sdk' to Gemfile and then run `bundle`:
|
85
72
|
|
86
73
|
```sh
|
74
|
+
$ echo "gem 'ringcentral_sdk'" >> Gemfile
|
87
75
|
$ bundle
|
88
76
|
```
|
89
77
|
|
@@ -97,6 +85,8 @@ $ gem install ringcentral_sdk
|
|
97
85
|
|
98
86
|
This provides a very basic guide to using the SDK. Please use the following resources for more information:
|
99
87
|
|
88
|
+
1. [SDK Developer Guide](http://ringcentral-sdk-ruby.readthedocs.org/)
|
89
|
+
2. [SDK Reference](http://www.rubydoc.info/gems/ringcentral_sdk/).
|
100
90
|
1. [API Developer and Reference Guide](https://developers.ringcentral.com/api-docs/latest/index.html)
|
101
91
|
|
102
92
|
### Instantiation
|
@@ -153,13 +143,13 @@ auth_url = rcsdk.authorize_url()
|
|
153
143
|
Customizing authorize URL:
|
154
144
|
|
155
145
|
```ruby
|
156
|
-
|
146
|
+
rcapi = RingCentralSdk.new(
|
157
147
|
'myAppKey',
|
158
148
|
'myAppSecret',
|
159
149
|
RingCentralSdk::RC_SERVER_SANDBOX
|
160
150
|
)
|
161
151
|
# Retrieve OAuth authorize url using override redirect URL
|
162
|
-
auth_url =
|
152
|
+
auth_url = rcapi.authorize_url({
|
163
153
|
:redirect_uri => 'my_registered_oauth_url', # optional override of default URL
|
164
154
|
:display => '', # optional: page|popup|touch|mobile, default 'page'
|
165
155
|
:prompt => '', # optional: sso|login|consent, default is 'login sso consent'
|
@@ -173,7 +163,7 @@ On your redirect page, you can exchange your authorization code for an access to
|
|
173
163
|
|
174
164
|
```ruby
|
175
165
|
code = params['code'] # retrieve GET 'code' parameter in Sinatra
|
176
|
-
|
166
|
+
rcapi.authorize_code(code)
|
177
167
|
```
|
178
168
|
|
179
169
|
For a complete working example, a demo Sinatra app is available in the scripts directory at [scripts/oauth2-sinatra](scripts/oauth2-sinatra).
|
@@ -192,13 +182,13 @@ After you have saved the token hash, e.g. as JSON, you can reload it in another
|
|
192
182
|
|
193
183
|
```ruby
|
194
184
|
# Reuse token_hash in another SDK instance
|
195
|
-
|
185
|
+
rcapi2 = RingCentralSdk.new(
|
196
186
|
'myAppKey',
|
197
187
|
'myAppSecret',
|
198
188
|
RingCentralSdk::RC_SERVER_SANDBOX
|
199
189
|
)
|
200
190
|
# set_token() accepts a hash or OAuth2::AccessToken object
|
201
|
-
|
191
|
+
rcapi2.set_token(token_hash)
|
202
192
|
```
|
203
193
|
|
204
194
|
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.
|
@@ -211,37 +201,20 @@ API requests can be made via the included `Faraday` client or `RingCentralSdk::H
|
|
211
201
|
|
212
202
|
#### Generic HTTP Requests
|
213
203
|
|
214
|
-
To make generic API requests, use included `Faraday` client which can be accessed via `
|
204
|
+
To make generic API requests, use included `Faraday` client which can be accessed via `rcapi.client`. The client automatically adds the correct access token to the HTTP request and handles OAuth token refresh using the `OAuth` gem.
|
215
205
|
|
216
206
|
```ruby
|
217
|
-
client =
|
207
|
+
client = rcapi.client
|
218
208
|
```
|
219
209
|
|
220
|
-
Faraday request middleware has been loaded for the following:
|
221
|
-
|
222
|
-
* `:oauth2_refresh`
|
223
|
-
* `:json`
|
224
|
-
* `:url_encoded`
|
225
|
-
|
226
|
-
Faraday response middleware is loaded for the following:
|
227
|
-
|
228
|
-
* `:json`
|
229
|
-
|
230
210
|
#### SMS Example
|
231
211
|
|
232
|
-
SMS and other requests can be easily sent directly without helpers.
|
233
|
-
|
234
212
|
```ruby
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
:from => { :phoneNumber => '16505551212' },
|
241
|
-
:to => [ { :phoneNumber => '14155551212'} ],
|
242
|
-
:text => 'RingCentral SMS demo using Ruby!'
|
243
|
-
}
|
244
|
-
end
|
213
|
+
rcapi.messages.create(
|
214
|
+
:from => '+16505551212',
|
215
|
+
:to => '+14155551212',
|
216
|
+
:text => 'Hi there!'
|
217
|
+
)
|
245
218
|
```
|
246
219
|
|
247
220
|
#### Fax Example
|
@@ -270,48 +243,27 @@ fax = RingCentralSdk::Helpers::CreateFaxRequest.new(
|
|
270
243
|
)
|
271
244
|
|
272
245
|
# sending request via request helper methods
|
273
|
-
response =
|
246
|
+
response = rcapi.request(fax)
|
274
247
|
|
275
248
|
# sending request via standard Faraday client
|
276
|
-
response =
|
249
|
+
response = rcapi.client.post do |req|
|
277
250
|
req.url fax.url
|
278
251
|
req.headers['Content-Type'] = fax.content_type
|
279
252
|
req.body = fax.body
|
280
253
|
end
|
281
254
|
```
|
282
255
|
|
283
|
-
### Subscriptions
|
284
|
-
|
285
|
-
To make subscriptions with RingCentral, use the SDK object to create subscription Observer object and then add observers to it.
|
286
|
-
|
287
|
-
```ruby
|
288
|
-
# Create an observer object
|
289
|
-
class MyObserver
|
290
|
-
def update(message)
|
291
|
-
puts "Subscription Message Received"
|
292
|
-
puts JSON.dump(message)
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
# Create an observable subscription and add your observer
|
297
|
-
sub = rcsdk.create_subscription()
|
298
|
-
sub.subscribe(['/restapi/v1.0/account/~/extension/~/presence'])
|
299
|
-
sub.add_observer(MyObserver.new())
|
300
|
-
|
301
|
-
# End the subscription
|
302
|
-
sub.destroy()
|
303
|
-
```
|
304
|
-
|
305
256
|
## Supported Ruby Versions
|
306
257
|
|
307
258
|
This library supports and is [tested against](https://travis-ci.org/grokify/ringcentral-sdk-ruby) the following Ruby implementations:
|
308
259
|
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
260
|
+
1. Ruby 2.3.0
|
261
|
+
2. Ruby 2.2.0
|
262
|
+
3. Ruby 2.1.0
|
263
|
+
4. Ruby 2.0.0
|
264
|
+
5. Ruby 1.9.3
|
265
|
+
6. [JRuby](http://jruby.org/)
|
266
|
+
7. [Rubinius](http://rubinius.com/)
|
315
267
|
|
316
268
|
Note: Ruby 1.8.7 works except for subscription support which relies on the `pubnub` gem. If there is a need for 1.8.7 support, consider creating a GitHub issue so we can evalute creating a separate library for subscription handling.
|
317
269
|
|
@@ -357,10 +309,12 @@ Please report these on [Github](https://github.com/grokify/ringcentral-sdk-ruby)
|
|
357
309
|
|
358
310
|
RingCentral SDK is available under an MIT-style license. See [LICENSE.txt](LICENSE.txt) for details.
|
359
311
|
|
360
|
-
RingCentral SDK © 2015 by John Wang
|
312
|
+
RingCentral SDK © 2015-2016 by John Wang
|
361
313
|
|
362
314
|
[gem-version-svg]: https://badge.fury.io/rb/ringcentral_sdk.svg
|
363
315
|
[gem-version-link]: http://badge.fury.io/rb/ringcentral_sdk
|
316
|
+
[downloads-svg]: http://ruby-gem-downloads-badge.herokuapp.com/ringcentral_sdk
|
317
|
+
[downloads-link]: https://rubygems.org/gems/ringcentral_sdk
|
364
318
|
[build-status-svg]: https://api.travis-ci.org/grokify/ringcentral-sdk-ruby.svg?branch=master
|
365
319
|
[build-status-link]: https://travis-ci.org/grokify/ringcentral-sdk-ruby
|
366
320
|
[coverage-status-svg]: https://coveralls.io/repos/grokify/ringcentral-sdk-ruby/badge.svg?branch=master
|
data/lib/ringcentral_sdk.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module RingCentralSdk
|
2
2
|
|
3
|
-
VERSION = '0.5.
|
3
|
+
VERSION = '0.5.2'
|
4
4
|
|
5
5
|
RC_SERVER_PRODUCTION = 'https://platform.ringcentral.com'
|
6
6
|
RC_SERVER_SANDBOX = 'https://platform.devtest.ringcentral.com'
|
7
7
|
|
8
|
+
autoload :Cache, 'ringcentral_sdk/cache'
|
8
9
|
autoload :Helpers, 'ringcentral_sdk/helpers'
|
9
10
|
autoload :Platform, 'ringcentral_sdk/platform'
|
10
11
|
autoload :Simple, 'ringcentral_sdk/simple'
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'time'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module RingCentralSdk::Cache
|
5
|
+
class Extensions
|
6
|
+
|
7
|
+
attr_accessor :rc_api
|
8
|
+
attr_accessor :account_id
|
9
|
+
attr_reader :extensions_hash
|
10
|
+
attr_reader :extensions_num2id
|
11
|
+
attr_reader :last_retrieved
|
12
|
+
|
13
|
+
def initialize(rc_api)
|
14
|
+
@rc_api = rc_api
|
15
|
+
@account_id = '~'
|
16
|
+
@extensions_hash = {}
|
17
|
+
@extensions_num2id = {}
|
18
|
+
@last_retrieved = -1
|
19
|
+
end
|
20
|
+
|
21
|
+
def retrieve(params={}, retrieve_all=true)
|
22
|
+
@last_retrieved = Time.now.to_i
|
23
|
+
uri = URI.parse "account/#{@account_id}/extension"
|
24
|
+
if params.length > 0
|
25
|
+
uri.query = URI.encode_www_form params
|
26
|
+
end
|
27
|
+
res = @rc_api.client.get do |req|
|
28
|
+
req.url uri.to_s
|
29
|
+
if retrieve_all
|
30
|
+
req.params['page'] = 1
|
31
|
+
req.params['perPage'] = 1000
|
32
|
+
end
|
33
|
+
end
|
34
|
+
res.body['records'].each do |extension|
|
35
|
+
if extension.has_key?('id') && extension['id']>0
|
36
|
+
@extensions_hash[extension['id'].to_s] = extension
|
37
|
+
end
|
38
|
+
end
|
39
|
+
if retrieve_all
|
40
|
+
while res.body.has_key?('navigation') && res.body['navigation'].has_key?('nextPage')
|
41
|
+
res = rcsdk.client.get do |req|
|
42
|
+
req.url res.body['navigation']['nextPage']['uri']
|
43
|
+
end
|
44
|
+
res.body['records'].each do |record|
|
45
|
+
if extension.has_key?('id') && extension['id'].length>0
|
46
|
+
@extensions_hash[extension['id'].to_s] = extension
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
inflate_num2id()
|
52
|
+
return @extensions_hash
|
53
|
+
end
|
54
|
+
|
55
|
+
def retrieve_all()
|
56
|
+
retrieve({}, true)
|
57
|
+
end
|
58
|
+
|
59
|
+
def inflate_num2id()
|
60
|
+
num2id = {}
|
61
|
+
@extensions_hash.each do |k,v|
|
62
|
+
if v.has_key?('id') && v['id']>0 &&
|
63
|
+
v.has_key?('extensionNumber') && v['extensionNumber'].length>0
|
64
|
+
num2id[v['extensionNumber']] = v['id'].to_s
|
65
|
+
end
|
66
|
+
end
|
67
|
+
@extensions_num2id = num2id
|
68
|
+
return num2id
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_extension_by_id(extension_id)
|
72
|
+
if !extension_id.is_a?(String)
|
73
|
+
extension_id = extension_id.to_s
|
74
|
+
end
|
75
|
+
if @extensions_hash.has_key?(extension_id)
|
76
|
+
return @extensions_hash[extension_id]
|
77
|
+
end
|
78
|
+
return nil
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_extension_by_number(extension_number)
|
82
|
+
if !extension_number.is_a?(String)
|
83
|
+
extension_number = extension_number.to_s
|
84
|
+
end
|
85
|
+
if @extensions_num2id.has_key?(extension_number)
|
86
|
+
extension_id = @extensions_num2id[extension_number]
|
87
|
+
if @extensions_hash.has_key?(extension_id)
|
88
|
+
return @extensions_hash[extension_id]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
return nil
|
92
|
+
end
|
93
|
+
|
94
|
+
def get_department_members(department_id)
|
95
|
+
if !department_id.is_a?(String)
|
96
|
+
department_id = department_id.to_s
|
97
|
+
end
|
98
|
+
if department_id !~ /^[0-9]+$/
|
99
|
+
raise 'department_id parameter must be a positive integer'
|
100
|
+
end
|
101
|
+
|
102
|
+
members = []
|
103
|
+
|
104
|
+
res = @rc_api.client.get do |req|
|
105
|
+
req.url "account/#{account_id}/department/#{department_id}/members"
|
106
|
+
end
|
107
|
+
|
108
|
+
if res.body.has_key?('records')
|
109
|
+
res.body['records'].each do |extension|
|
110
|
+
if extension.has_key?('id')
|
111
|
+
member = get_extension_by_id extension['id']
|
112
|
+
if !member.nil?
|
113
|
+
members.push member
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
return members
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module RingCentralSdk::Helpers
|
2
2
|
autoload :CreateFaxRequest, 'ringcentral_sdk/helpers/fax'
|
3
|
+
autoload :ExtensionPresence, 'ringcentral_sdk/helpers/extension_presence'
|
3
4
|
autoload :Inflator, 'ringcentral_sdk/helpers/inflator'
|
5
|
+
autoload :Messages, 'ringcentral_sdk/helpers/messages'
|
4
6
|
autoload :Request, 'ringcentral_sdk/helpers/request'
|
5
7
|
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
module RingCentralSdk::Helpers
|
2
|
+
class ExtensionPresence
|
3
|
+
|
4
|
+
attr_accessor :rc_api
|
5
|
+
attr_accessor :account_id
|
6
|
+
attr_accessor :exension_id
|
7
|
+
attr_accessor :presence_info
|
8
|
+
|
9
|
+
def initialize(rc_api, extension_id=nil)
|
10
|
+
@rc_api = rc_api
|
11
|
+
@account_id = '~'
|
12
|
+
@extension_id = extension_id.to_s
|
13
|
+
@presence_info = {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def retrieve()
|
17
|
+
if @extension_id !~ /^[0-9]+$/
|
18
|
+
raise "extension_id is not an integer"
|
19
|
+
end
|
20
|
+
|
21
|
+
res = @rc_api.client.get do |req|
|
22
|
+
req.url "account/#{@account_id}/extension/#{@extension_id}/presence"
|
23
|
+
end
|
24
|
+
|
25
|
+
@presence_info = res.body
|
26
|
+
|
27
|
+
return @presence_info
|
28
|
+
end
|
29
|
+
|
30
|
+
def department_calls_enable(enable)
|
31
|
+
retrieve()
|
32
|
+
|
33
|
+
if !@presence_info.has_key?('dndStatus')
|
34
|
+
raise 'invalid presence info'
|
35
|
+
end
|
36
|
+
|
37
|
+
current_status = @presence_info['dndStatus']
|
38
|
+
new_status = enable ?
|
39
|
+
status_enable_dnd_department_calls(current_status) :
|
40
|
+
status_disable_dnd_department_calls(current_status)
|
41
|
+
|
42
|
+
if current_status != new_status
|
43
|
+
update({:dndStatus => new_status})
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def department_calls_enabled?(reload=false)
|
48
|
+
if reload
|
49
|
+
retrieve()
|
50
|
+
elsif !@presence_info.has_key?('dndStatus')
|
51
|
+
retrieve()
|
52
|
+
end
|
53
|
+
|
54
|
+
current_status = @presence_info['dndStatus']
|
55
|
+
|
56
|
+
status_enabled = {
|
57
|
+
'DoNotAcceptAnyCalls' => false,
|
58
|
+
'DoNotAcceptDepartmentCalls' => false,
|
59
|
+
'TakeAllCalls' => true,
|
60
|
+
'TakeDepartmentCallsOnly' => true
|
61
|
+
}
|
62
|
+
|
63
|
+
return status_enabled.has_key?(current_status) ?
|
64
|
+
status_enabled[current_status] : nil
|
65
|
+
end
|
66
|
+
|
67
|
+
def disable_department_calls()
|
68
|
+
retrieve()
|
69
|
+
|
70
|
+
if !@presence_info.has_key?('dndStatus')
|
71
|
+
raise 'invalid presence info'
|
72
|
+
end
|
73
|
+
|
74
|
+
current_status = @presence_info['dndStatus']
|
75
|
+
new_status = status_disable_dnd_department_calls(current_status)
|
76
|
+
|
77
|
+
if current_status != new_status
|
78
|
+
update({:dndStatus => new_status})
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def update(body=nil)
|
83
|
+
if body.nil?
|
84
|
+
raise 'HTTP request body is required to update presence'
|
85
|
+
end
|
86
|
+
|
87
|
+
res = @rc_api.client.put do |req|
|
88
|
+
req.url "account/#{@account_id}/extension/#{@extension_id}/presence"
|
89
|
+
req.headers['Content-Type'] = 'application/json'
|
90
|
+
req.body = body
|
91
|
+
end
|
92
|
+
|
93
|
+
@presence_info = res.body
|
94
|
+
|
95
|
+
return @presence_info
|
96
|
+
end
|
97
|
+
|
98
|
+
def status_enable_dnd_department_calls(current_status)
|
99
|
+
new_status = current_status
|
100
|
+
|
101
|
+
new_statuses = {
|
102
|
+
'DoNotAcceptAnyCalls' => 'TakeDepartmentCallsOnly',
|
103
|
+
'DoNotAcceptDepartmentCalls' => 'TakeAllCalls'
|
104
|
+
}
|
105
|
+
|
106
|
+
if new_statuses.has_key?(current_status.to_s)
|
107
|
+
new_status = new_statuses[current_status.to_s]
|
108
|
+
end
|
109
|
+
|
110
|
+
return new_status
|
111
|
+
end
|
112
|
+
|
113
|
+
def status_disable_dnd_department_calls(current_status)
|
114
|
+
new_status = current_status
|
115
|
+
|
116
|
+
new_statuses = {
|
117
|
+
'TakeAllCalls' => 'DoNotAcceptDepartmentCalls',
|
118
|
+
'TakeDepartmentCallsOnly' => 'DoNotAcceptAnyCalls'
|
119
|
+
}
|
120
|
+
|
121
|
+
if new_statuses.has_key?(current_status.to_s)
|
122
|
+
new_status = new_statuses[current_status.to_s]
|
123
|
+
end
|
124
|
+
|
125
|
+
return new_status
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module RingCentralSdk::Helpers
|
2
|
+
class Messages
|
3
|
+
def initialize(rcapi)
|
4
|
+
@rcapi = rcapi
|
5
|
+
end
|
6
|
+
def create(opts)
|
7
|
+
response = @rcapi.client.post do |req|
|
8
|
+
req.url 'account/~/extension/~/sms'
|
9
|
+
req.headers['Content-Type'] = 'application/json'
|
10
|
+
req.body = {
|
11
|
+
:from => { :phoneNumber => opts[:from].to_s },
|
12
|
+
:to => [ { :phoneNumber => opts[:to].to_s } ],
|
13
|
+
:text => opts[:text].to_s
|
14
|
+
}
|
15
|
+
end
|
16
|
+
return response
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -26,6 +26,8 @@ module RingCentralSdk
|
|
26
26
|
attr_reader :user_agent
|
27
27
|
attr_reader :redirect_uri
|
28
28
|
|
29
|
+
attr_reader :messages
|
30
|
+
|
29
31
|
def initialize(app_key, app_secret, server_url=RingCentralSdk::RC_SERVER_SANDBOX, opts={})
|
30
32
|
@app_key = app_key.to_s
|
31
33
|
@app_secret = app_secret.to_s
|
@@ -42,6 +44,7 @@ module RingCentralSdk
|
|
42
44
|
authorize_password(opts[:username], extension, opts[:password])
|
43
45
|
end
|
44
46
|
end
|
47
|
+
@messages = RingCentralSdk::Helpers::Messages.new(self)
|
45
48
|
end
|
46
49
|
|
47
50
|
def get_api_version_url()
|
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.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -154,9 +154,13 @@ executables: []
|
|
154
154
|
extensions: []
|
155
155
|
extra_rdoc_files: []
|
156
156
|
files:
|
157
|
+
- lib/ringcentral_sdk/cache/extensions.rb
|
158
|
+
- lib/ringcentral_sdk/cache.rb
|
159
|
+
- lib/ringcentral_sdk/helpers/extension_presence.rb
|
157
160
|
- lib/ringcentral_sdk/helpers/fax.rb
|
158
161
|
- lib/ringcentral_sdk/helpers/inflator/contact_info.rb
|
159
162
|
- lib/ringcentral_sdk/helpers/inflator.rb
|
163
|
+
- lib/ringcentral_sdk/helpers/messages.rb
|
160
164
|
- lib/ringcentral_sdk/helpers/request.rb
|
161
165
|
- lib/ringcentral_sdk/helpers.rb
|
162
166
|
- lib/ringcentral_sdk/platform.rb
|