ringcentral_sdk 1.0.0 → 1.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 +44 -18
- data/Gemfile +1 -0
- data/Gemfile.lock +5 -0
- data/README.md +32 -33
- data/Rakefile +1 -1
- data/lib/ringcentral_sdk/rest/client.rb +43 -18
- data/lib/ringcentral_sdk/rest/event.rb +61 -0
- data/lib/ringcentral_sdk/rest/extension.rb +7 -7
- data/lib/ringcentral_sdk/rest/extension_presence.rb +3 -3
- data/lib/ringcentral_sdk/rest/messages.rb +4 -4
- data/lib/ringcentral_sdk/rest/messages_retriever.rb +45 -0
- data/lib/ringcentral_sdk/rest/request/base.rb +18 -7
- data/lib/ringcentral_sdk/rest/request/fax.rb +9 -17
- data/lib/ringcentral_sdk/rest/request/inflator.rb +1 -1
- data/lib/ringcentral_sdk/rest/request/simple.rb +40 -0
- data/lib/ringcentral_sdk/rest/request.rb +2 -1
- data/lib/ringcentral_sdk/rest/simple_client.rb +30 -16
- data/lib/ringcentral_sdk/rest/subscription.rb +24 -24
- data/lib/ringcentral_sdk/rest.rb +3 -1
- data/lib/ringcentral_sdk.rb +3 -5
- data/mkdocs.yml +2 -1
- data/ringcentral_sdk.gemspec +4 -2
- data/test/test_client.rb +43 -0
- data/test/test_event.rb +51 -0
- data/test/test_extension_presence.rb +8 -0
- data/test/test_helper_fax.rb +7 -0
- data/test/test_helper_request.rb +6 -5
- metadata +42 -5
- data/ringcentral_sdk-0.5.2.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98d2a8eb022ff4511a3d145f3b5aa893f30ba796
|
4
|
+
data.tar.gz: 163dd6efc182dda1ab77523d21955fa5ac8b7348
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5d99ea86065b3c9c52af955f6171541205ab90cf047c0a7502f3ff280e4920178a96ef1b772c5c0c276bcb63f08c3c63eb9699a1f39d8db43b595cb758ba2bd
|
7
|
+
data.tar.gz: 684f7792e42327cc036917a9f41e09d711ccad403e2b7417892b9b3a6b3c2d826f005ad45e90ba0148f8186c959897064538165c97bd8d9f889f91878bc632f3
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,34 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
|
-
- **2016-
|
4
|
-
-
|
5
|
-
|
3
|
+
- **2016-02-07**: 1.1.0
|
4
|
+
- Add Subscription to Retrieve New Messages functionality
|
5
|
+
- `./lib`
|
6
|
+
- Add `RingCentralSdk::REST::Event`
|
7
|
+
- Add `RingCentralSdk::REST::MessagesRetriever`
|
8
|
+
- Add `RingCentralSdk::REST::Request::Simple`
|
9
|
+
- Update `RingCentralSdk::REST::Client` - update `send_request`
|
10
|
+
- Update `RingCentralSdk::REST::Request::Base` - add `headers`
|
11
|
+
- `./scripts`
|
12
|
+
- Add `scripts/fax_download.rb` demo script
|
13
|
+
- Add `scripts/fax_download_new.rb` demo script
|
14
|
+
- Add `scripts/sms_to_chat.rb` demo script to send inbound SMS to chat
|
15
|
+
- **2016-01-26**: 1.0.0
|
16
|
+
- Major refactor focusing on naming changes to improve consistency
|
17
|
+
- All code moved into `RingCentralSdk::REST` namespace
|
18
|
+
- Update: rename `RingCentralSdk::Platform` to `RingCentralSdk::REST::Client`
|
19
|
+
- Update: rename `RingCentralSdk::Platform::client` to `RingCentralSdk::REST::Client::http`
|
20
|
+
- Update: rename `RingCentralSdk::Helpers` namespace to `RingCentralSdk::Request`
|
21
|
+
- Add `RingCentralSdk::REST::Config` to support `dotenv` config files
|
22
|
+
- Add `RingCentralSdk::REST::Config` reads dotenv files
|
23
|
+
- Add `scripts/account-extensions.rb` script
|
24
|
+
- Update sample scripts to use new Config object
|
25
|
+
- Add `RingCentral::REST::Messages`, `RingCentral::REST::Messages::MessagesSMS` and `RingCentral::REST::Messages::MessagesFax`
|
26
|
+
- Update `RingCentralSdk::REST::Request::Fax` helper for nicer interface, formerly `RingCentralSdk::Helpers::Fax`
|
6
27
|
- **2016-01-22**: 0.5.2
|
7
|
-
- Add
|
8
|
-
|
9
|
-
|
28
|
+
- Add Call Queue Management support
|
29
|
+
- Add `RingCentralSdk::Cache::Extensions`
|
30
|
+
- Add `RingCentralSdk::Helpers::ExtensionPresence`
|
31
|
+
- Add Call Queue Member Status mydocs documentation
|
10
32
|
- **2015-12-08**: 0.5.1
|
11
33
|
- Add call recording transcription demo script via VoiceBase
|
12
34
|
- Fix PubNub unsubscribe bug
|
@@ -15,19 +37,23 @@ CHANGELOG
|
|
15
37
|
- Update sample scripts credentials file format to be more scalable
|
16
38
|
- **2015-10-18**: 0.5.0
|
17
39
|
- Add stubbed tests via `mocha`
|
18
|
-
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
40
|
+
- Update naming and cleanup interface
|
41
|
+
- Add `RingCentralSdk.new()` sugar method
|
42
|
+
- Update `RingCentralSdk::RC_SERVER_PRODUCTION` url from `RingCentralSdk::Sdk::RC_SERVER_Production`
|
43
|
+
- Delete `lib/ringcentral_sdk/sdk.rb` file and `RingCentralSdk::Sdk` class
|
44
|
+
- Delete `lib/ringcentral_sdk/version.rb` file
|
45
|
+
- Delete `VERSION.txt` file
|
23
46
|
- **2015-10-15**: 0.4.0
|
24
|
-
- Add
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
47
|
+
- Add OAuth `authorization_code` support
|
48
|
+
- './lib'
|
49
|
+
- Add 3-Legged OAuth support via platform `authorize_url` and `authorize_code` methods
|
50
|
+
- Update SDK initialization by converting optional params to options hash
|
51
|
+
- Update `RingCentralSdk::Platform::Platform` to `RingCentralSdk::Platform`
|
52
|
+
- './scripts'
|
53
|
+
- Add `oauth2-sinatra` demo app in `scripts` directory
|
54
|
+
- Add `call_recording_download.rb` demo script
|
55
|
+
- Add `rc-credentials.json` separate demo credentials file
|
56
|
+
- Update `fax_send.rb` demo script with name change
|
31
57
|
- **2015-10-07**: 0.3.0
|
32
58
|
- Add subscription support via PubNub
|
33
59
|
- Add `ruby-head`, `jruby`, `jruby-head`, and `rbx-2` to Travis CI
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -24,6 +24,7 @@ GEM
|
|
24
24
|
http-cookie (1.0.2)
|
25
25
|
domain_name (~> 0.5)
|
26
26
|
json (1.8.3)
|
27
|
+
jsondoc (0.1.0)
|
27
28
|
jwt (1.5.2)
|
28
29
|
logger (1.2.8)
|
29
30
|
metaclass (0.0.4)
|
@@ -82,6 +83,7 @@ DEPENDENCIES
|
|
82
83
|
faraday (~> 0.9.0)
|
83
84
|
faraday_middleware
|
84
85
|
faraday_middleware-oauth2_refresh
|
86
|
+
jsondoc
|
85
87
|
logger
|
86
88
|
mime
|
87
89
|
mime-types
|
@@ -94,3 +96,6 @@ DEPENDENCIES
|
|
94
96
|
simplecov
|
95
97
|
test-unit
|
96
98
|
timers
|
99
|
+
|
100
|
+
BUNDLED WITH
|
101
|
+
1.11.2
|
data/README.md
CHANGED
@@ -22,10 +22,12 @@ RingCentral SDK for Ruby
|
|
22
22
|
1. [Authorization](#authorization)
|
23
23
|
1. [Password Grant](#password-grant)
|
24
24
|
1. [Authorization Code Grant](#authorization-code-grant)
|
25
|
+
1. [Token Reuse](#token-reuse)
|
25
26
|
1. [API Requests](#api-requests)
|
26
27
|
1. [Generic HTTP Requests](#generic-http-requests)
|
27
28
|
2. [SMS Example](#sms-example)
|
28
29
|
3. [Fax Example](#fax-example)
|
30
|
+
1. [Advanced Use Cases](#advanced-use-cases)
|
29
31
|
5. [Supported Ruby Versions](#supported-ruby-versions)
|
30
32
|
6. [Releases](#releases)
|
31
33
|
1. [Versioning](#versioning)
|
@@ -40,19 +42,16 @@ A library for using the [RingCentral REST API](https://developers.ringcentral.co
|
|
40
42
|
|
41
43
|
## Documentation
|
42
44
|
|
43
|
-
|
45
|
+
Full documentation and resources are available at:
|
44
46
|
|
45
|
-
1. [
|
46
|
-
2. [
|
47
|
+
1. [Ruby SDK Developer Guide](http://ringcentral-sdk-ruby.readthedocs.org/) - Read the Docs
|
48
|
+
2. [Ruby SDK Reference Guide](http://www.rubydoc.info/gems/ringcentral_sdk/) - RubyDoc.info
|
47
49
|
|
48
|
-
|
50
|
+
For API information, see the official RingCentral resources:
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
1. [API Developer and Reference Guide](https://developers.ringcentral.com/api-docs/latest/index.html) for information on specific APIs.
|
54
|
-
1. [API Explorer](http://ringcentral.github.io/api-explorer/)
|
55
|
-
1. [Dev Tutorial](http://ringcentral.github.io/tutorial/)
|
52
|
+
1. [API Developer and Reference Guide](https://developers.ringcentral.com/api-docs/latest/index.html)
|
53
|
+
1. [API Explorer](https://developer.ringcentral.com/api-explorer/)
|
54
|
+
1. [CTI Tutorial](http://ringcentral.github.io/tutorial/)
|
56
55
|
|
57
56
|
## Installation
|
58
57
|
|
@@ -73,12 +72,6 @@ $ gem install ringcentral_sdk
|
|
73
72
|
|
74
73
|
## Usage
|
75
74
|
|
76
|
-
This provides a very basic guide to using the SDK. Please use the following resources for more information:
|
77
|
-
|
78
|
-
1. [SDK Developer Guide](http://ringcentral-sdk-ruby.readthedocs.org/)
|
79
|
-
2. [SDK Reference](http://www.rubydoc.info/gems/ringcentral_sdk/).
|
80
|
-
1. [API Developer and Reference Guide](https://developers.ringcentral.com/api-docs/latest/index.html)
|
81
|
-
|
82
75
|
### Instantiation and Authorization
|
83
76
|
|
84
77
|
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.
|
@@ -118,7 +111,7 @@ client = RingCentralSdk::REST::Client.new(
|
|
118
111
|
'myAppKey',
|
119
112
|
'myAppSecret',
|
120
113
|
RingCentralSdk::RC_SERVER_SANDBOX,
|
121
|
-
{:
|
114
|
+
{redirect_uri: 'http://example.com/oauth'}
|
122
115
|
)
|
123
116
|
|
124
117
|
# Retrieve OAuth authorize url using default redirect URL
|
@@ -175,9 +168,9 @@ http = client.http
|
|
175
168
|
|
176
169
|
```ruby
|
177
170
|
client.messages.sms.create(
|
178
|
-
:
|
179
|
-
:
|
180
|
-
:
|
171
|
+
from: '+16505551212',
|
172
|
+
to: '+14155551212',
|
173
|
+
text: 'Hi there!'
|
181
174
|
)
|
182
175
|
```
|
183
176
|
|
@@ -187,9 +180,9 @@ Fax files:
|
|
187
180
|
|
188
181
|
```ruby
|
189
182
|
client.messages.fax.create(
|
190
|
-
:
|
191
|
-
:
|
192
|
-
:
|
183
|
+
to: '+14155551212',
|
184
|
+
coverPageText: 'Hi there!',
|
185
|
+
files: ['/path/to/myfile.pdf']
|
193
186
|
)
|
194
187
|
```
|
195
188
|
|
@@ -197,9 +190,9 @@ Fax text:
|
|
197
190
|
|
198
191
|
```ruby
|
199
192
|
client.messages.fax.create(
|
200
|
-
:
|
201
|
-
:
|
202
|
-
:
|
193
|
+
to: '+14155551212',
|
194
|
+
coverPageText: 'Hi there!',
|
195
|
+
text: 'Hi there!'
|
203
196
|
)
|
204
197
|
```
|
205
198
|
|
@@ -227,6 +220,11 @@ sub.subscribe(['/restapi/v1.0/account/~/extension/~/presence'])
|
|
227
220
|
sub.destroy()
|
228
221
|
```
|
229
222
|
|
223
|
+
### Advanced Use Cases
|
224
|
+
|
225
|
+
1. [Subscribing to All Extensions](http://ringcentral-sdk-ruby.readthedocs.org/en/latest/usage/notifications/Subscriptions-All-Extensions/)
|
226
|
+
1. [Managing Call Queue Member Status](http://ringcentral-sdk-ruby.readthedocs.org/en/latest/usage/callqueues/Member-Status/)
|
227
|
+
|
230
228
|
## Supported Ruby Versions
|
231
229
|
|
232
230
|
This library supports and is [tested against](https://travis-ci.org/grokify/ringcentral-sdk-ruby) the following Ruby implementations:
|
@@ -247,9 +245,8 @@ Releases with release notes are availabe on [GitHub releases](https://github.com
|
|
247
245
|
|
248
246
|
### Versioning
|
249
247
|
|
250
|
-
|
251
|
-
|
252
|
-
Once the project is version 1.0.0 or above, it will use [semantic versioning](http://semver.org/). At this time, breaking changes will be indicated by a change in major version.
|
248
|
+
* Versions 1.0.0 and above follow [semantic versioning](http://semver.org/). Breaking changes will be indicated by a change in major version.
|
249
|
+
* Versions below 1.0.0 are in active development. During initial development (Version 0.x.x), minor version changes will indicate either substantial feature inclusion or breaking changes.
|
253
250
|
|
254
251
|
### Change Log
|
255
252
|
|
@@ -273,11 +270,13 @@ RingCentral Official SDKs
|
|
273
270
|
|
274
271
|
* https://github.com/ringcentral
|
275
272
|
|
276
|
-
##
|
277
|
-
|
278
|
-
Any reports of problems, comments or suggestions are most welcome.
|
273
|
+
## Contributing
|
279
274
|
|
280
|
-
|
275
|
+
1. Fork it ( http://github.com/grokify/ringcentral-sdk-ruby/fork )
|
276
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
277
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
278
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
279
|
+
5. Create new Pull Request
|
281
280
|
|
282
281
|
## License
|
283
282
|
|
data/Rakefile
CHANGED
@@ -112,8 +112,8 @@ module RingCentralSdk::REST
|
|
112
112
|
|
113
113
|
def authorize_password(username, extension='', password='', remember=false)
|
114
114
|
token = @oauth2client.password.get_token(username, password, {
|
115
|
-
:
|
116
|
-
:
|
115
|
+
extension: extension,
|
116
|
+
headers: { 'Authorization' => 'Basic ' + get_api_key() } })
|
117
117
|
set_token(token)
|
118
118
|
return token
|
119
119
|
end
|
@@ -134,21 +134,21 @@ module RingCentralSdk::REST
|
|
134
134
|
@token = token
|
135
135
|
|
136
136
|
@http = Faraday.new(:url => api_version_url()) do |conn|
|
137
|
-
conn.request
|
138
|
-
conn.request
|
139
|
-
conn.request
|
137
|
+
conn.request :oauth2_refresh, @token
|
138
|
+
conn.request :json
|
139
|
+
conn.request :url_encoded
|
140
140
|
conn.headers['User-Agent'] = @user_agent
|
141
141
|
conn.headers['Rc-User-Agent'] = @user_agent
|
142
142
|
conn.response :json, :content_type => /\bjson$/
|
143
|
-
conn.adapter
|
143
|
+
conn.adapter Faraday.default_adapter
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
147
|
def new_oauth2_client()
|
148
148
|
return OAuth2::Client.new(@app_config.key, @app_config.secret,
|
149
|
-
:
|
150
|
-
:
|
151
|
-
:
|
149
|
+
site: @app_config.server_url,
|
150
|
+
authorize_url: AUTHZ_ENDPOINT,
|
151
|
+
token_url: TOKEN_ENDPOINT)
|
152
152
|
end
|
153
153
|
|
154
154
|
def set_oauth2_client(client=nil)
|
@@ -167,19 +167,44 @@ module RingCentralSdk::REST
|
|
167
167
|
return api_key
|
168
168
|
end
|
169
169
|
|
170
|
-
def send_request(
|
171
|
-
unless
|
170
|
+
def send_request(request_sdk = nil)
|
171
|
+
unless request_sdk.is_a?(RingCentralSdk::REST::Request::Base)
|
172
172
|
fail 'Request is not a RingCentralSdk::REST::Request::Base'
|
173
173
|
end
|
174
174
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
175
|
+
res = nil
|
176
|
+
|
177
|
+
method = request_sdk.method.downcase
|
178
|
+
case method
|
179
|
+
when 'delete'
|
180
|
+
res = @http.delete { |req| req = inflate_request(req, request_sdk) }
|
181
|
+
when 'get'
|
182
|
+
res = @http.get { |req| req = inflate_request(req, request_sdk) }
|
183
|
+
when 'post'
|
184
|
+
res = @http.post { |req| req = inflate_request(req, request_sdk) }
|
185
|
+
when 'put'
|
186
|
+
res = @http.put { |req| req = inflate_request(req, request_sdk) }
|
187
|
+
else
|
188
|
+
fail "#{method} not support"
|
189
|
+
end
|
190
|
+
return res
|
191
|
+
end
|
192
|
+
|
193
|
+
def inflate_request(req_faraday, req_sdk)
|
194
|
+
req_faraday.url req_sdk.url
|
195
|
+
req_faraday.body = req_sdk.body if req_sdk.body
|
196
|
+
if req_sdk.params.is_a? Hash
|
197
|
+
req_sdk.params.each { |k,v| req_faraday.params[k] = v }
|
198
|
+
end
|
199
|
+
if req_sdk.headers.is_a? Hash
|
200
|
+
req_sdk.headers.each { |k,v| req_faraday.headers[k] = v }
|
201
|
+
end
|
202
|
+
|
203
|
+
ct = req_sdk.content_type
|
204
|
+
if !ct.nil? && ct.to_s.length > 0
|
205
|
+
req_faraday.headers['Content-Type'] = ct.to_s
|
182
206
|
end
|
207
|
+
return req_faraday
|
183
208
|
end
|
184
209
|
|
185
210
|
def get_user_agent()
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'jsondoc'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module RingCentralSdk::REST
|
5
|
+
class Event
|
6
|
+
attr_accessor :doc
|
7
|
+
def initialize(data = nil)
|
8
|
+
if data.is_a? JsonDoc::Document
|
9
|
+
@doc = data
|
10
|
+
elsif data.is_a? Hash
|
11
|
+
data = _symbolize_keys data
|
12
|
+
@doc = JsonDoc::Document.new(data, false, false, false)
|
13
|
+
elsif data.nil?
|
14
|
+
@doc = JsonDoc::Document.new({}, false, false, false)
|
15
|
+
else
|
16
|
+
raise 'initialize needs JsonDoc::Document or Hash argument'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def _hash_has_string_keys(hash={})
|
21
|
+
hash.each do |k,v|
|
22
|
+
return true if k.is_a? String
|
23
|
+
end
|
24
|
+
return false
|
25
|
+
end
|
26
|
+
|
27
|
+
def _symbolize_keys(hash={})
|
28
|
+
if _hash_has_string_keys hash
|
29
|
+
return MultiJson.decode(MultiJson.encode(hash), :symbolize_keys=>true)
|
30
|
+
end
|
31
|
+
return hash
|
32
|
+
end
|
33
|
+
|
34
|
+
def new_fax_count
|
35
|
+
new_type_count('fax')
|
36
|
+
end
|
37
|
+
|
38
|
+
def new_sms_count
|
39
|
+
new_type_count('sms')
|
40
|
+
end
|
41
|
+
|
42
|
+
def new_type_count(type)
|
43
|
+
count = 0
|
44
|
+
have_type = false
|
45
|
+
changes = @doc.getAttr('body.changes')
|
46
|
+
if changes.is_a?(Array) && changes.length > 0
|
47
|
+
changes.each do |change|
|
48
|
+
if change.key?(:type) && change[:type].to_s.downcase == type
|
49
|
+
have_type = true
|
50
|
+
if change.key?(:newCount)
|
51
|
+
count += change[:newCount]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
return have_type ? count : -1
|
57
|
+
end
|
58
|
+
|
59
|
+
private :_hash_has_string_keys, :_symbolize_keys
|
60
|
+
end
|
61
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module RingCentralSdk::REST
|
2
2
|
class Extension
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
attr_reader :extension_id
|
4
|
+
attr_reader :presence
|
5
|
+
attr_accessor :client
|
6
|
+
def initialize(extension_id, opts={})
|
7
|
+
@extension_id = extension_id
|
8
|
+
@client = opts.has_key?(:client) ? opts[:client] : nil
|
9
9
|
@presence = RingCentralSdk::REST::ExtensionPresence.new(extension_id, opts)
|
10
|
-
|
10
|
+
end
|
11
11
|
end
|
12
12
|
end
|
@@ -29,7 +29,7 @@ module RingCentralSdk::REST
|
|
29
29
|
def department_calls_enable(enable)
|
30
30
|
retrieve()
|
31
31
|
|
32
|
-
|
32
|
+
unless @presence.is_a?(Hash) && @presence_data.key?('dndStatus')
|
33
33
|
raise 'invalid presence info'
|
34
34
|
end
|
35
35
|
|
@@ -81,11 +81,11 @@ module RingCentralSdk::REST
|
|
81
81
|
|
82
82
|
def new_status_dnd_department_calls(current_status, enable)
|
83
83
|
new_statuses = {
|
84
|
-
:
|
84
|
+
enable: {
|
85
85
|
'DoNotAcceptAnyCalls' => 'TakeDepartmentCallsOnly',
|
86
86
|
'DoNotAcceptDepartmentCalls' => 'TakeAllCalls'
|
87
87
|
},
|
88
|
-
:
|
88
|
+
disable: {
|
89
89
|
'TakeAllCalls' => 'DoNotAcceptDepartmentCalls',
|
90
90
|
'TakeDepartmentCallsOnly' => 'DoNotAcceptAnyCalls'
|
91
91
|
}
|
@@ -22,9 +22,9 @@ module RingCentralSdk::REST
|
|
22
22
|
req.url 'account/~/extension/~/sms'
|
23
23
|
req.headers['Content-Type'] = 'application/json'
|
24
24
|
req.body = {
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
25
|
+
from: { phoneNumber: opts[:from].to_s },
|
26
|
+
to: [ { phoneNumber: opts[:to].to_s } ],
|
27
|
+
text: opts[:text].to_s
|
28
28
|
}
|
29
29
|
end
|
30
30
|
return response
|
@@ -43,4 +43,4 @@ module RingCentralSdk::REST
|
|
43
43
|
return @client.send_request(fax)
|
44
44
|
end
|
45
45
|
end
|
46
|
-
end
|
46
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'jsondoc'
|
3
|
+
|
4
|
+
module RingCentralSdk::REST
|
5
|
+
class MessagesRetriever
|
6
|
+
attr_accessor :range
|
7
|
+
def initialize(client)
|
8
|
+
@client = client
|
9
|
+
@range = 1.0 # minutes
|
10
|
+
end
|
11
|
+
|
12
|
+
def retrieve_for_event(event, params={})
|
13
|
+
unless event.is_a? RingCentralSdk::REST::Event
|
14
|
+
fail 'retrieve_for_event requires RingCentralSdk::REST::Event argument'
|
15
|
+
end
|
16
|
+
url = event.doc.getAttr :event
|
17
|
+
last_updated_s = event.doc.getAttr('body.lastUpdated')
|
18
|
+
last_updated_dt = DateTime.iso8601(last_updated_s)
|
19
|
+
|
20
|
+
params.merge!(
|
21
|
+
dateFrom: (last_updated_dt - (@range/1440.0)).to_s,
|
22
|
+
dateTo: (last_updated_dt + (@range/1440.0)).to_s)
|
23
|
+
|
24
|
+
if event.new_sms_count > 0
|
25
|
+
params[:messageType] = 'SMS'
|
26
|
+
end
|
27
|
+
|
28
|
+
res = @client.http.get do |req|
|
29
|
+
req.url url
|
30
|
+
req.params = params
|
31
|
+
end
|
32
|
+
|
33
|
+
messages = []
|
34
|
+
|
35
|
+
res.body['records'].each do |rec|
|
36
|
+
rec_last_modified_time = rec['lastModifiedTime']
|
37
|
+
rec_last_modified_time_dt = DateTime.iso8601(rec_last_modified_time)
|
38
|
+
if rec_last_modified_time_dt == last_updated_dt
|
39
|
+
messages.push rec
|
40
|
+
end
|
41
|
+
end
|
42
|
+
return messages
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -1,16 +1,27 @@
|
|
1
1
|
module RingCentralSdk::REST::Request
|
2
2
|
class Base
|
3
|
-
def method
|
4
|
-
return 'get'
|
3
|
+
def method
|
4
|
+
return 'get' # HTTP methods
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
|
+
def url
|
7
8
|
return ''
|
8
9
|
end
|
9
|
-
|
10
|
-
|
10
|
+
|
11
|
+
def params
|
12
|
+
return {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def headers
|
16
|
+
return {}
|
11
17
|
end
|
12
|
-
|
18
|
+
|
19
|
+
def content_type
|
13
20
|
return ''
|
14
21
|
end
|
22
|
+
|
23
|
+
def body
|
24
|
+
return '' # '' || Hash
|
25
|
+
end
|
15
26
|
end
|
16
|
-
end
|
27
|
+
end
|
@@ -25,16 +25,8 @@ module RingCentralSdk::REST::Request
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def add_path(opts={})
|
28
|
-
|
29
|
-
|
30
|
-
else
|
31
|
-
@account_id = '~'
|
32
|
-
end
|
33
|
-
if opts.key?(:extensionId) && opts[:extensionId].to_s.length>0
|
34
|
-
@extension_id = opts[:extensionId]
|
35
|
-
else
|
36
|
-
@extension_id = '~'
|
37
|
-
end
|
28
|
+
@account_id = opts[:accountId] ||= '~'
|
29
|
+
@extension_id = opts[:extensionId] ||= '~'
|
38
30
|
end
|
39
31
|
|
40
32
|
def add_part_meta(opts={})
|
@@ -57,12 +49,12 @@ module RingCentralSdk::REST::Request
|
|
57
49
|
meta[:to] = inf.inflate_to_array opts[:to]
|
58
50
|
|
59
51
|
processed = {
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
52
|
+
accountId: 1,
|
53
|
+
extensionId: 1,
|
54
|
+
to: 1,
|
55
|
+
text: 1,
|
56
|
+
files: 1,
|
57
|
+
parts: 1
|
66
58
|
}
|
67
59
|
|
68
60
|
opts.each do |k,v|
|
@@ -118,4 +110,4 @@ module RingCentralSdk::REST::Request
|
|
118
110
|
@msg.body.to_s
|
119
111
|
end
|
120
112
|
end
|
121
|
-
end
|
113
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module RingCentralSdk::REST::Request
|
2
|
+
class Simple < RingCentralSdk::REST::Request::Base
|
3
|
+
def initialize(opts = {})
|
4
|
+
@method = opts[:method]
|
5
|
+
@url = opts[:url]
|
6
|
+
@params = opts[:params]
|
7
|
+
@headers = opts[:headers]
|
8
|
+
@body = body.nil? ? '' : body
|
9
|
+
if body.is_a? Hash
|
10
|
+
@headers = {} unless @headers.is_a? Hash
|
11
|
+
@headers['Content-Type'] = 'application/json'
|
12
|
+
end
|
13
|
+
|
14
|
+
def content_type
|
15
|
+
ct = @headers.is_a?(Hash) \
|
16
|
+
? @headers['Content-Type'] || '' : 'application/json'
|
17
|
+
end
|
18
|
+
|
19
|
+
def method
|
20
|
+
@method
|
21
|
+
end
|
22
|
+
|
23
|
+
def url
|
24
|
+
@url
|
25
|
+
end
|
26
|
+
|
27
|
+
def params
|
28
|
+
@params
|
29
|
+
end
|
30
|
+
|
31
|
+
def headers
|
32
|
+
@headers
|
33
|
+
end
|
34
|
+
|
35
|
+
def body
|
36
|
+
@body
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -2,4 +2,5 @@ module RingCentralSdk::REST::Request
|
|
2
2
|
autoload :Base, 'ringcentral_sdk/rest/request/base'
|
3
3
|
autoload :Fax, 'ringcentral_sdk/rest/request/fax'
|
4
4
|
autoload :Inflator, 'ringcentral_sdk/rest/request/inflator'
|
5
|
-
|
5
|
+
autoload :Simple, 'ringcentral_sdk/rest/request/simple'
|
6
|
+
end
|
@@ -1,4 +1,20 @@
|
|
1
1
|
module RingCentralSdk::REST
|
2
|
+
|
3
|
+
# A simplified, but still generic, REST interface.
|
4
|
+
#
|
5
|
+
# NOTE: This is an experimental module.
|
6
|
+
#
|
7
|
+
# client = RingCentralSdk::REST::Client.new ...
|
8
|
+
# simple = RingCentralSdk::REST::SimpleClient client
|
9
|
+
#
|
10
|
+
# simple.post(
|
11
|
+
# path: 'sms',
|
12
|
+
# body: {
|
13
|
+
# from: {phoneNumber: '+16505551212'},
|
14
|
+
# to: [{phoneNumber: '+14155551212'}],
|
15
|
+
# text: 'Hi There!'
|
16
|
+
# }
|
17
|
+
# )
|
2
18
|
class SimpleClient
|
3
19
|
attr_accessor :client
|
4
20
|
|
@@ -13,7 +29,7 @@ module RingCentralSdk::REST
|
|
13
29
|
raise "Request is not a RingCentralSdk::Helpers::Request or Hash"
|
14
30
|
end
|
15
31
|
|
16
|
-
verb = request.
|
32
|
+
verb = request.key?(:verb) ? request[:verb].to_s.downcase : 'get'
|
17
33
|
|
18
34
|
if verb == 'get'
|
19
35
|
return get(request)
|
@@ -42,26 +58,25 @@ module RingCentralSdk::REST
|
|
42
58
|
|
43
59
|
def post(opts={})
|
44
60
|
return @client.http.post do |req|
|
45
|
-
req
|
46
|
-
if opts.has_key?(:body)
|
47
|
-
req.body = opts[:body]
|
48
|
-
if opts[:body].is_a?(Hash)
|
49
|
-
req.headers['Content-Type'] = 'application/json'
|
50
|
-
end
|
51
|
-
end
|
61
|
+
req = inflate_request req, opts
|
52
62
|
end
|
53
63
|
end
|
54
64
|
|
55
65
|
def put(opts={})
|
56
66
|
return @client.http.put do |req|
|
57
|
-
req
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
67
|
+
req = inflate_request req, opts
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def inflate_request(req, opts={})
|
72
|
+
req.url build_url(opts[:path])
|
73
|
+
if opts.key? :body
|
74
|
+
req.body = opts[:body]
|
75
|
+
if opts[:body].is_a?(Hash)
|
76
|
+
req.headers['Content-Type'] = 'application/json'
|
63
77
|
end
|
64
78
|
end
|
79
|
+
req
|
65
80
|
end
|
66
81
|
|
67
82
|
def build_url(path)
|
@@ -69,7 +84,7 @@ module RingCentralSdk::REST
|
|
69
84
|
if !path.is_a?(Array)
|
70
85
|
path = [path]
|
71
86
|
end
|
72
|
-
if path.length>0
|
87
|
+
if path.length > 0
|
73
88
|
path0 = path[0].to_s
|
74
89
|
if path0 !~ /\//
|
75
90
|
if path0.index('account') != 0
|
@@ -83,6 +98,5 @@ module RingCentralSdk::REST
|
|
83
98
|
url = path.join('/')
|
84
99
|
return url
|
85
100
|
end
|
86
|
-
|
87
101
|
end
|
88
102
|
end
|
@@ -46,7 +46,7 @@ module RingCentralSdk::REST
|
|
46
46
|
return @_pubnub
|
47
47
|
end
|
48
48
|
|
49
|
-
def register(events=nil)
|
49
|
+
def register(events = nil)
|
50
50
|
return alive?() ? renew(events) : subscribe(events)
|
51
51
|
end
|
52
52
|
|
@@ -54,7 +54,7 @@ module RingCentralSdk::REST
|
|
54
54
|
unless events.is_a?(Array)
|
55
55
|
raise 'Events is not an array.'
|
56
56
|
end
|
57
|
-
@event_filters.push(events) if events.length>0
|
57
|
+
@event_filters.push(events) if events.length > 0
|
58
58
|
end
|
59
59
|
|
60
60
|
def set_events(events)
|
@@ -67,7 +67,7 @@ module RingCentralSdk::REST
|
|
67
67
|
def subscribe(events=nil)
|
68
68
|
set_events(events) if events.is_a?(Array)
|
69
69
|
|
70
|
-
if !@event_filters.is_a?(Array) || @event_filters.length ==0
|
70
|
+
if !@event_filters.is_a?(Array) || @event_filters.length == 0
|
71
71
|
raise 'Events are undefined'
|
72
72
|
end
|
73
73
|
|
@@ -75,9 +75,9 @@ module RingCentralSdk::REST
|
|
75
75
|
response = @_client.http.post do |req|
|
76
76
|
req.url 'subscription'
|
77
77
|
req.body = {
|
78
|
-
:
|
79
|
-
:
|
80
|
-
:
|
78
|
+
eventFilters: @_client.create_urls(@event_filters),
|
79
|
+
deliveryMode: {
|
80
|
+
transportType: 'PubNub'
|
81
81
|
}
|
82
82
|
}
|
83
83
|
end
|
@@ -95,7 +95,7 @@ module RingCentralSdk::REST
|
|
95
95
|
|
96
96
|
end
|
97
97
|
|
98
|
-
def renew(events=nil)
|
98
|
+
def renew(events = nil)
|
99
99
|
set_events(events) if events.is_a?(Array)
|
100
100
|
|
101
101
|
unless alive?()
|
@@ -112,7 +112,7 @@ module RingCentralSdk::REST
|
|
112
112
|
response = @_client.http.put do |req|
|
113
113
|
req.url 'subscription/' + @_subscription['id'].to_s
|
114
114
|
req.body = {
|
115
|
-
:
|
115
|
+
eventFilters: @_client.create_urls(@event_filters)
|
116
116
|
}
|
117
117
|
end
|
118
118
|
|
@@ -191,16 +191,17 @@ module RingCentralSdk::REST
|
|
191
191
|
callback = lambda { |envelope|
|
192
192
|
_notify(envelope.msg)
|
193
193
|
changed
|
194
|
-
|
194
|
+
#notify_observers {}
|
195
|
+
#notify_observers('GOT_PUBNUB_MESSAGE_NOTIFY')
|
195
196
|
}
|
196
197
|
|
197
198
|
@_pubnub.subscribe(
|
198
|
-
:
|
199
|
-
:
|
200
|
-
:
|
201
|
-
:
|
202
|
-
:
|
203
|
-
:
|
199
|
+
channel: @_subscription['deliveryMode']['address'],
|
200
|
+
callback: callback,
|
201
|
+
error: lambda { |envelope| puts('ERROR: ' + envelope.msg.to_s) },
|
202
|
+
connect: lambda { |envelope| puts('CONNECTED') },
|
203
|
+
reconnect: lambda { |envelope| puts('RECONNECTED') },
|
204
|
+
disconnect: lambda { |envelope| puts('DISCONNECTED') }
|
204
205
|
)
|
205
206
|
end
|
206
207
|
|
@@ -225,7 +226,7 @@ module RingCentralSdk::REST
|
|
225
226
|
ciphertext = Base64.decode64(message)
|
226
227
|
plaintext = cipher.update(ciphertext) + cipher.final
|
227
228
|
|
228
|
-
message = MultiJson.decode(plaintext)
|
229
|
+
message = MultiJson.decode(plaintext, :symbolize_keys=>false)
|
229
230
|
end
|
230
231
|
|
231
232
|
return message
|
@@ -257,7 +258,7 @@ module RingCentralSdk::REST
|
|
257
258
|
end
|
258
259
|
|
259
260
|
def _clear_timeout()
|
260
|
-
if @_timeout.is_a?
|
261
|
+
if @_timeout.is_a? Timers::Group
|
261
262
|
@_timeout.cancel()
|
262
263
|
end
|
263
264
|
end
|
@@ -266,17 +267,16 @@ module RingCentralSdk::REST
|
|
266
267
|
my_logger = Logger.new(STDOUT) if my_logger.nil?
|
267
268
|
|
268
269
|
return Pubnub.new(
|
269
|
-
:
|
270
|
-
:
|
271
|
-
:
|
270
|
+
subscribe_key: subscribe_key.to_s,
|
271
|
+
publish_key: publish_key.to_s,
|
272
|
+
error_callback: lambda { |msg|
|
272
273
|
puts "Error callback says: #{msg.inspect}"
|
273
274
|
},
|
274
|
-
:
|
275
|
+
connect_callback: lambda { |msg|
|
275
276
|
puts "CONNECTED: #{msg.inspect}"
|
276
277
|
},
|
277
|
-
:
|
278
|
+
logger: my_logger
|
278
279
|
)
|
279
280
|
end
|
280
|
-
|
281
281
|
end
|
282
|
-
end
|
282
|
+
end
|
data/lib/ringcentral_sdk/rest.rb
CHANGED
@@ -5,11 +5,13 @@ module RingCentralSdk::REST
|
|
5
5
|
autoload :ConfigApp, 'ringcentral_sdk/rest/config'
|
6
6
|
autoload :ConfigUser, 'ringcentral_sdk/rest/config'
|
7
7
|
autoload :ConfigEnvRc, 'ringcentral_sdk/rest/config'
|
8
|
+
autoload :Event, 'ringcentral_sdk/rest/event'
|
8
9
|
autoload :Extension, 'ringcentral_sdk/rest/extension'
|
9
10
|
autoload :ExtensionPresence, 'ringcentral_sdk/rest/extension_presence'
|
10
11
|
autoload :Messages, 'ringcentral_sdk/rest/messages'
|
11
12
|
autoload :MessagesFax, 'ringcentral_sdk/rest/messages'
|
12
13
|
autoload :MessagesSMS, 'ringcentral_sdk/rest/messages'
|
14
|
+
autoload :MessagesRetriever, 'ringcentral_sdk/rest/messages_retriever'
|
13
15
|
autoload :Request, 'ringcentral_sdk/rest/request'
|
14
16
|
autoload :Subscription, 'ringcentral_sdk/rest/subscription'
|
15
|
-
end
|
17
|
+
end
|
data/lib/ringcentral_sdk.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module RingCentralSdk
|
2
|
-
|
3
|
-
VERSION = '1.0.0'
|
2
|
+
VERSION = '1.1.0'
|
4
3
|
|
5
4
|
RC_SERVER_PRODUCTION = 'https://platform.ringcentral.com'
|
6
5
|
RC_SERVER_SANDBOX = 'https://platform.devtest.ringcentral.com'
|
@@ -8,9 +7,8 @@ module RingCentralSdk
|
|
8
7
|
autoload :REST, 'ringcentral_sdk/rest'
|
9
8
|
|
10
9
|
class << self
|
11
|
-
def new(app_key, app_secret, server_url=RC_SERVER_SANDBOX, opts={})
|
10
|
+
def new(app_key, app_secret, server_url = RC_SERVER_SANDBOX, opts = {})
|
12
11
|
RingCentralSdk::REST::Client.new(app_key, app_secret, server_url, opts)
|
13
12
|
end
|
14
13
|
end
|
15
|
-
|
16
|
-
end
|
14
|
+
end
|
data/mkdocs.yml
CHANGED
@@ -27,4 +27,5 @@ pages:
|
|
27
27
|
|
28
28
|
## Notifications:
|
29
29
|
- ['usage/notifications/Subscriptions.md', 'Notifications', 'Subscriptions']
|
30
|
-
- ['usage/notifications/
|
30
|
+
- ['usage/notifications/Subscribe_to_All_Extensions.md', 'Notifications', 'Subscribe to All Extensions']
|
31
|
+
- ['usage/notifications/Subscribe_for_New_SMS.md', 'Notifications', 'Subscribe for New SMS']
|
data/ringcentral_sdk.gemspec
CHANGED
@@ -7,7 +7,7 @@ version = $1
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = 'ringcentral_sdk'
|
9
9
|
s.version = version
|
10
|
-
s.date = '2016-
|
10
|
+
s.date = '2016-02-07'
|
11
11
|
s.summary = 'RingCentral SDK - Ruby SDK for the RingCentral Connect Platform API'
|
12
12
|
s.description = 'A Ruby SDK for the RingCentral Connect Platform API'
|
13
13
|
s.authors = ['John Wang']
|
@@ -22,10 +22,12 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_dependency 'faraday', '~> 0.9', '>= 0.9'
|
23
23
|
s.add_dependency 'faraday_middleware', '~> 0', '>= 0'
|
24
24
|
s.add_dependency 'faraday_middleware-oauth2_refresh', '~> 0'
|
25
|
+
s.add_dependency 'jsondoc', '~> 0.1', '>= 0.1.0'
|
25
26
|
s.add_dependency 'mime', '~> 0.4', '>= 0.4.3'
|
26
27
|
s.add_dependency 'mime-types', '~> 1.25' # >= 1.9 '~> 2.5', '>= 2.5'
|
28
|
+
s.add_dependency 'mime_builder', '~> 0'
|
27
29
|
s.add_dependency 'multi_json', '~> 1.3'
|
28
30
|
s.add_dependency 'oauth2', '~> 1.0', '>= 1.0.0'
|
29
31
|
s.add_dependency 'pubnub', '~> 3.7', '>= 3.7.3'
|
30
|
-
s.add_dependency 'timers', '~>
|
32
|
+
s.add_dependency 'timers', '~> 4.1'
|
31
33
|
end
|
data/test/test_client.rb
CHANGED
@@ -209,6 +209,49 @@ class RingCentralSdkPlatformTest < Test::Unit::TestCase
|
|
209
209
|
:text => 'RingCentral fax demo using Ruby SDK!'
|
210
210
|
)
|
211
211
|
assert_equal 'Faraday::Response', res.class.name
|
212
|
+
|
213
|
+
######
|
214
|
+
# Simple Request - GET
|
215
|
+
######
|
216
|
+
request = RingCentralSdk::REST::Request::Simple.new(
|
217
|
+
method: 'get',
|
218
|
+
url: 'account/~/extension/~/message-store',
|
219
|
+
params: {
|
220
|
+
direction: 'Inbound',
|
221
|
+
messageType: 'SMS'
|
222
|
+
}
|
223
|
+
)
|
224
|
+
assert_equal 'get', request.method
|
225
|
+
|
226
|
+
res = client.send_request request
|
227
|
+
assert_equal 'Faraday::Response', res.class.name
|
228
|
+
|
229
|
+
######
|
230
|
+
# Simple Request - PUT
|
231
|
+
######
|
232
|
+
request = RingCentralSdk::REST::Request::Simple.new(
|
233
|
+
method: 'put',
|
234
|
+
url: 'account/~/extension/~/message-store/11111111',
|
235
|
+
body: {
|
236
|
+
readStatus: 'Read'
|
237
|
+
}
|
238
|
+
)
|
239
|
+
assert_equal 'put', request.method
|
240
|
+
|
241
|
+
res = client.send_request request
|
242
|
+
assert_equal 'Faraday::Response', res.class.name
|
243
|
+
|
244
|
+
######
|
245
|
+
# Simple Request - DELETE
|
246
|
+
######
|
247
|
+
request = RingCentralSdk::REST::Request::Simple.new(
|
248
|
+
method: 'delete',
|
249
|
+
url: 'account/~/extension/~/message-store/11111111',
|
250
|
+
)
|
251
|
+
assert_equal 'delete', request.method
|
252
|
+
|
253
|
+
res = client.send_request request
|
254
|
+
assert_equal 'Faraday::Response', res.class.name
|
212
255
|
end
|
213
256
|
|
214
257
|
def test_sms
|
data/test/test_event.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require './test/test_base.rb'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
class RingCentralSdkRESTEventTest < Test::Unit::TestCase
|
5
|
+
def test_new_sms_count
|
6
|
+
data = data_test_json_sms()
|
7
|
+
|
8
|
+
event = RingCentralSdk::REST::Event.new data
|
9
|
+
|
10
|
+
assert_equal '11112222-3333-4444-5555-666677778888', event.doc.getAttr('uuid')
|
11
|
+
assert_equal 1, event.new_sms_count
|
12
|
+
assert_equal -1, event.new_fax_count
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_new_fax_count
|
16
|
+
data = data_test_json_fax()
|
17
|
+
|
18
|
+
event = RingCentralSdk::REST::Event.new data
|
19
|
+
|
20
|
+
assert_equal '11112222-3333-4444-5555-666677778888', event.doc.getAttr('uuid')
|
21
|
+
assert_equal -1, event.new_sms_count
|
22
|
+
assert_equal 1, event.new_fax_count
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_new_empty
|
26
|
+
event = RingCentralSdk::REST::Event.new
|
27
|
+
assert_equal 'RingCentralSdk::REST::Event', event.class.name
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_new_failure
|
31
|
+
assert_raise do
|
32
|
+
event = RingCentralSdk::REST::Event.new ''
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def data_test_hash(opts={})
|
37
|
+
json = data_test_json()
|
38
|
+
hash = MultiJson.decode(json, symbolize_keys: false)
|
39
|
+
return hash
|
40
|
+
end
|
41
|
+
|
42
|
+
def data_test_json_sms
|
43
|
+
json = '{"uuid":"11112222-3333-4444-5555-666677778888","event":"/restapi/v1.0/account/~/extension/22222222/message-store","timestamp":"2016-01-31T00:15:30.196Z","body":{"extensionId":22222222,"lastUpdated":"2016-01-31T00:15:15.923+0000","changes":[{"type":"SMS","newCount":1,"updatedCount":1}]}}'
|
44
|
+
MultiJson.decode(json, symbolize_keys: true)
|
45
|
+
end
|
46
|
+
|
47
|
+
def data_test_json_fax
|
48
|
+
json = '{"uuid":"11112222-3333-4444-5555-666677778888","event":"/restapi/v1.0/account/~/extension/22222222/message-store","timestamp":"2016-02-07T14:28:29.010Z","body":{"extensionId":22222222,"lastUpdated":"2016-02-07T14:28:21.961+0000","changes":[{"type":"Fax","newCount":1,"updatedCount":0}]}}'
|
49
|
+
MultiJson.decode(json, symbolize_keys: false)
|
50
|
+
end
|
51
|
+
end
|
@@ -78,6 +78,14 @@ class RingCentralSdkRESTExtensionPresenceTest < Test::Unit::TestCase
|
|
78
78
|
end
|
79
79
|
|
80
80
|
presence.update({:dndStatus=>'TakeAllCalls'})
|
81
|
+
|
82
|
+
######
|
83
|
+
# Test with good data
|
84
|
+
######
|
85
|
+
|
86
|
+
assert_raise do
|
87
|
+
presence.department_calls_enable true
|
88
|
+
end
|
81
89
|
end
|
82
90
|
|
83
91
|
def data_extension_presence
|
data/test/test_helper_fax.rb
CHANGED
@@ -88,5 +88,12 @@ class RingCentralSdkHelperFaxTest < Test::Unit::TestCase
|
|
88
88
|
:parts => [{:text=>'RingCentral fax demo using Ruby SDK!'}]
|
89
89
|
)
|
90
90
|
assert_equal 'account/111111111/extension/222222222/fax', fax6.url()
|
91
|
+
|
92
|
+
fax7 = RingCentralSdk::REST::Request::Fax.new(
|
93
|
+
:coverPageText => "RingCentral fax demo using Ruby SDK!",
|
94
|
+
:parts => [{:text=>'RingCentral fax demo using Ruby SDK!'}]
|
95
|
+
)
|
96
|
+
assert_equal '~', fax7.account_id
|
97
|
+
assert_equal '~', fax7.extension_id
|
91
98
|
end
|
92
99
|
end
|
data/test/test_helper_request.rb
CHANGED
@@ -2,12 +2,13 @@ require './test/test_base.rb'
|
|
2
2
|
|
3
3
|
class RingCentralSdkHelperRequestTest < Test::Unit::TestCase
|
4
4
|
def testSetup
|
5
|
-
|
6
5
|
req = RingCentralSdk::REST::Request::Base.new
|
7
6
|
|
8
|
-
assert_equal 'get', req.method
|
9
|
-
assert_equal '', req.url
|
10
|
-
assert_equal '', req.
|
11
|
-
assert_equal '', req.
|
7
|
+
assert_equal 'get', req.method
|
8
|
+
assert_equal '', req.url
|
9
|
+
assert_equal 'Hash', req.params.class.name
|
10
|
+
assert_equal 'Hash', req.headers.class.name
|
11
|
+
assert_equal '', req.content_type
|
12
|
+
assert_equal '', req.body
|
12
13
|
end
|
13
14
|
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: 1.
|
4
|
+
version: 1.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: 2016-
|
11
|
+
date: 2016-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -84,6 +84,26 @@ dependencies:
|
|
84
84
|
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: '0'
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: jsondoc
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0.1'
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.0
|
97
|
+
type: :runtime
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.1'
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 0.1.0
|
87
107
|
- !ruby/object:Gem::Dependency
|
88
108
|
name: mime
|
89
109
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,6 +138,20 @@ dependencies:
|
|
118
138
|
- - "~>"
|
119
139
|
- !ruby/object:Gem::Version
|
120
140
|
version: '1.25'
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: mime_builder
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
type: :runtime
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - "~>"
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
121
155
|
- !ruby/object:Gem::Dependency
|
122
156
|
name: multi_json
|
123
157
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,14 +212,14 @@ dependencies:
|
|
178
212
|
requirements:
|
179
213
|
- - "~>"
|
180
214
|
- !ruby/object:Gem::Version
|
181
|
-
version: '
|
215
|
+
version: '4.1'
|
182
216
|
type: :runtime
|
183
217
|
prerelease: false
|
184
218
|
version_requirements: !ruby/object:Gem::Requirement
|
185
219
|
requirements:
|
186
220
|
- - "~>"
|
187
221
|
- !ruby/object:Gem::Version
|
188
|
-
version: '
|
222
|
+
version: '4.1'
|
189
223
|
description: A Ruby SDK for the RingCentral Connect Platform API
|
190
224
|
email: johncwang@gmail.com
|
191
225
|
executables: []
|
@@ -204,22 +238,25 @@ files:
|
|
204
238
|
- lib/ringcentral_sdk/rest/cache/extensions.rb
|
205
239
|
- lib/ringcentral_sdk/rest/client.rb
|
206
240
|
- lib/ringcentral_sdk/rest/config.rb
|
241
|
+
- lib/ringcentral_sdk/rest/event.rb
|
207
242
|
- lib/ringcentral_sdk/rest/extension.rb
|
208
243
|
- lib/ringcentral_sdk/rest/extension_presence.rb
|
209
244
|
- lib/ringcentral_sdk/rest/messages.rb
|
245
|
+
- lib/ringcentral_sdk/rest/messages_retriever.rb
|
210
246
|
- lib/ringcentral_sdk/rest/request.rb
|
211
247
|
- lib/ringcentral_sdk/rest/request/base.rb
|
212
248
|
- lib/ringcentral_sdk/rest/request/fax.rb
|
213
249
|
- lib/ringcentral_sdk/rest/request/inflator.rb
|
214
250
|
- lib/ringcentral_sdk/rest/request/inflator/contact_info.rb
|
251
|
+
- lib/ringcentral_sdk/rest/request/simple.rb
|
215
252
|
- lib/ringcentral_sdk/rest/simple_client.rb
|
216
253
|
- lib/ringcentral_sdk/rest/subscription.rb
|
217
254
|
- mkdocs.yml
|
218
|
-
- ringcentral_sdk-0.5.2.gem
|
219
255
|
- ringcentral_sdk.gemspec
|
220
256
|
- test/test_base.rb
|
221
257
|
- test/test_client.rb
|
222
258
|
- test/test_config.rb
|
259
|
+
- test/test_event.rb
|
223
260
|
- test/test_extension_presence.rb
|
224
261
|
- test/test_helper_fax.rb
|
225
262
|
- test/test_helper_inflator_contact_info.rb
|
data/ringcentral_sdk-0.5.2.gem
DELETED
Binary file
|