ringcentral-sdk 1.1.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/LICENSE.md +20 -0
- data/README.md +82 -8
- data/lib/ringcentral.rb +1 -1
- data/ringcentral-sdk.gemspec +8 -7
- data/spec/fax_spec.rb +0 -6
- data/spec/greeting_spec.rb +22 -0
- data/spec/mms_spec.rb +0 -6
- data/spec/query_params_spec.rb +0 -6
- data/spec/ringcentral_spec.rb +6 -6
- data/spec/spec_helper.rb +7 -0
- data/spec/websocket_subscription_spec.rb +31 -10
- metadata +28 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 76e77f6062730a43e898df6b7b7d8cc256c7483d44fc48e55c9349683adb1656
|
|
4
|
+
data.tar.gz: a5ddaf69dd559f720ea3b06e451fd53c7f0c7fad1db9e354602942b3218928ae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba0edca0402dffa27cfdef901a0eca14d530437045450c783e624e3d83173fbed4af1d43ce00a8ce8e4b200bb8245b97442e669160c61585d9b1119300c245f8
|
|
7
|
+
data.tar.gz: 52ce98b433ef2e347060a202f5e81652a8d6914351345e4e9e39c3abda32bfaeb839cfd2b8acebd98d52cd0bad4ff89677d854739260828427671c3ca3dd08fd
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Release notes
|
|
2
|
+
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
- **Breaking compatibility change:** require Ruby >= 3.3. Local development uses
|
|
6
|
+
Ruby 4.0; full live-suite CI covers Ruby 3.3, 3.4 and 4.0.
|
|
7
|
+
- Update runtime dependency minimums to addressable 2.9.2, concurrent-ruby 1.3.8,
|
|
8
|
+
faraday 2.15.1, faraday-multipart 1.2.0 and faye-websocket 0.12.0 within their
|
|
9
|
+
declared compatible series.
|
|
10
|
+
- Fix the default production server when constructing a client without a server;
|
|
11
|
+
explicit server selection and the existing public SDK interfaces are preserved.
|
|
12
|
+
- Add a greeting integration example using the existing multipart interface and
|
|
13
|
+
retained "hello world" WAV fixture; no new SDK runtime API is introduced.
|
|
14
|
+
- Load shared test setup and dotenv consistently, start coverage before the SDK,
|
|
15
|
+
preserve local environment overrides, and complete the sample configuration.
|
|
16
|
+
- Wait for active WebSocket subscriptions and observe real notification windows;
|
|
17
|
+
clean up subscriptions and message state even when assertions fail.
|
|
18
|
+
- Run the complete live suite in the normal and release Ruby matrices, serialize
|
|
19
|
+
shared-account jobs, report missing credentials, and upload coverage per Ruby.
|
|
20
|
+
Publish once only after the entire release matrix passes.
|
|
21
|
+
- Build PR documentation without deployment; deploy YARD documentation only on
|
|
22
|
+
pushes to master. Add weekly GitHub Actions updates without automatic merging.
|
|
23
|
+
- Document tag-based release as the primary route, with manual publication as a
|
|
24
|
+
mutually exclusive alternative for a given version.
|
|
25
|
+
|
|
26
|
+
- Include the MIT license text in the gem.
|
|
27
|
+
- Remove unused MkDocs configuration and the completed message-inspection
|
|
28
|
+
diagnostic; retain YARD documentation, test configuration, and example fixtures.
|
data/LICENSE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-2026 RingCentral, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -40,6 +40,10 @@ contributions and alternative SDKs.
|
|
|
40
40
|
|
|
41
41
|
## Installation
|
|
42
42
|
|
|
43
|
+
Version 2.0.0 requires **Ruby 3.3 or newer**. Upgrade Ruby before updating from
|
|
44
|
+
1.x if needed. Local development uses Ruby 4.0; CI validates Ruby 3.3, 3.4 and
|
|
45
|
+
4.0. The existing public SDK interfaces are preserved. See [release notes](CHANGELOG.md).
|
|
46
|
+
|
|
43
47
|
```
|
|
44
48
|
gem install ringcentral-sdk
|
|
45
49
|
```
|
|
@@ -47,8 +51,8 @@ gem install ringcentral-sdk
|
|
|
47
51
|
If for some reason `eventmachine` failed to install, please check
|
|
48
52
|
[this](https://stackoverflow.com/a/31516586/862862).
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
by us.
|
|
54
|
+
Please note that, there is a gem with a similar name "ringcentral_sdk" which is
|
|
55
|
+
not maintained by us. Please make sure that you install the correct gem.
|
|
52
56
|
|
|
53
57
|
### Name collision with `ringcentral` gem
|
|
54
58
|
|
|
@@ -165,6 +169,23 @@ r = rc.post('/restapi/v1.0/account/~/extension/~/sms',
|
|
|
165
169
|
)
|
|
166
170
|
```
|
|
167
171
|
|
|
172
|
+
### Upload and apply a voicemail greeting
|
|
173
|
+
|
|
174
|
+
After authorization, use the existing multipart upload interface:
|
|
175
|
+
|
|
176
|
+
```ruby
|
|
177
|
+
rc.post('/restapi/v1.0/account/~/extension/~/greeting',
|
|
178
|
+
params: { apply: true },
|
|
179
|
+
payload: { type: 'Voicemail', stateId: 'work-hours' },
|
|
180
|
+
files: [['spec/test.wav', 'audio/wav']]
|
|
181
|
+
)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
This replaces the extension's work-hours voicemail greeting. Use `apply: false`
|
|
185
|
+
to upload without assigning it. The retained checkout fixture `spec/test.wav`
|
|
186
|
+
says "hello world"; fixtures are not included in the installed gem. This example
|
|
187
|
+
uses an existing SDK capability, with no new multipart API.
|
|
188
|
+
|
|
168
189
|
## Subscriptions
|
|
169
190
|
|
|
170
191
|
### WebSocket Subscriptions
|
|
@@ -200,17 +221,70 @@ subscription.on_ws_closed = lambda { |event|
|
|
|
200
221
|
|
|
201
222
|
## How to test
|
|
202
223
|
|
|
203
|
-
|
|
204
|
-
bundle install
|
|
224
|
+
Use Ruby 3.3, 3.4 or 4.0 (the supported CI matrix). Install dependencies with
|
|
225
|
+
`bundle install`, then copy `.env.sample` to `.env`
|
|
226
|
+
and fill in every value:
|
|
227
|
+
|
|
228
|
+
- `RINGCENTRAL_SERVER_URL`: API server (production by default in the sample).
|
|
229
|
+
- `RINGCENTRAL_CLIENT_ID` and `RINGCENTRAL_CLIENT_SECRET`: application credentials.
|
|
230
|
+
- `RINGCENTRAL_JWT_TOKEN`: JWT for the test extension.
|
|
231
|
+
- `RINGCENTRAL_SENDER`: the test extension's SMS/MMS-capable phone number.
|
|
232
|
+
- `RINGCENTRAL_RECEIVER`: a phone number that can receive the test SMS/MMS and fax.
|
|
233
|
+
|
|
234
|
+
Keep real credentials and phone numbers in the ignored `.env` file. Values in
|
|
235
|
+
that file override inherited environment variables. RSpec automatically loads
|
|
236
|
+
`spec/spec_helper.rb` through `.rspec`; the helper starts coverage before loading
|
|
237
|
+
the SDK and loads dotenv for every spec.
|
|
238
|
+
|
|
239
|
+
Run the complete suite from the repository root:
|
|
240
|
+
|
|
241
|
+
```sh
|
|
242
|
+
bundle exec rspec
|
|
205
243
|
```
|
|
206
244
|
|
|
207
|
-
|
|
245
|
+
The default suite makes live API calls: it sends fax, MMS and pager messages,
|
|
246
|
+
changes message read/deletion state, uploads and applies a voicemail greeting,
|
|
247
|
+
and opens WebSocket subscriptions. Use a dedicated test account and agreed
|
|
248
|
+
recipient. Run suites sharing the account, recipient or greeting sequentially.
|
|
249
|
+
The greeting example uses the SDK's existing multipart upload functionality.
|
|
250
|
+
WebSocket examples wait for a new active subscription before sending, allow up to
|
|
251
|
+
30 seconds for each notification, and observe revoked subscriptions for 30 seconds.
|
|
252
|
+
Cleanup runs even when an assertion fails.
|
|
208
253
|
|
|
209
|
-
|
|
254
|
+
Select a single file or example by line number with the same shared setup:
|
|
210
255
|
|
|
211
|
-
|
|
256
|
+
```sh
|
|
257
|
+
bundle exec rspec spec/ringcentral_spec.rb
|
|
258
|
+
bundle exec rspec spec/ringcentral_spec.rb:15
|
|
259
|
+
```
|
|
212
260
|
|
|
213
|
-
|
|
261
|
+
Coverage is written to `coverage/index.html` for both full and selected runs.
|
|
262
|
+
A selected run measures only the SDK code exercised by those examples.
|
|
263
|
+
|
|
264
|
+
### Continuous integration
|
|
265
|
+
|
|
266
|
+
Normal push/PR CI and release-tag validation run the complete live suite on Ruby
|
|
267
|
+
3.3, 3.4 and 4.0. Matrix entries run sequentially against the shared account,
|
|
268
|
+
recipient and greeting. This limit applies within each workflow run: maintainers
|
|
269
|
+
must also avoid overlapping test workflows, release workflows and local suites
|
|
270
|
+
using the same account. Wait for the active run to finish before starting another.
|
|
271
|
+
Coverage artifacts are named by Ruby version; missing coverage fails the job.
|
|
272
|
+
Release publication runs once, only after every release-matrix entry succeeds.
|
|
273
|
+
|
|
274
|
+
Both workflows use the `prod` environment and require all six `RINGCENTRAL_*`
|
|
275
|
+
variables listed above as secrets. Before tests run, missing values fail the job
|
|
276
|
+
with variable names only. Maintainers must configure secrets and environment
|
|
277
|
+
access/approval rules for trusted code; never approve untrusted PR code for access
|
|
278
|
+
to the test account. Ordinary `pull_request` events are retained: fork PRs cannot
|
|
279
|
+
receive the repository's secrets, so their full-suite CI will fail clearly until
|
|
280
|
+
trusted changes can be validated in an authorized context. No privileged PR
|
|
281
|
+
trigger runs untrusted code with credentials.
|
|
282
|
+
|
|
283
|
+
[Dependabot does not receive ordinary Actions secrets](https://docs.github.com/en/code-security/reference/supply-chain-security/dependabot-on-actions). Maintainers must provision
|
|
284
|
+
separately supported Dependabot secrets and check the `prod` environment's access
|
|
285
|
+
rules if trusted Dependabot runs are to execute the full suite. If the event or
|
|
286
|
+
environment cannot supply credentials, CI fails rather than skipping live tests.
|
|
287
|
+
Environment protections remain in force; no secret values belong in PRs or logs.
|
|
214
288
|
|
|
215
289
|
## License
|
|
216
290
|
|
data/lib/ringcentral.rb
CHANGED
|
@@ -13,7 +13,7 @@ class RingCentral
|
|
|
13
13
|
attr_reader :client_id, :client_secret, :server, :token
|
|
14
14
|
attr_accessor :auto_refresh, :debug_mode
|
|
15
15
|
|
|
16
|
-
def initialize(client_id, client_secret, server =
|
|
16
|
+
def initialize(client_id, client_secret, server = RingCentral.PRODUCTION_SERVER, debug_mode = false)
|
|
17
17
|
@client_id = client_id
|
|
18
18
|
@client_secret = client_secret
|
|
19
19
|
@server = server
|
data/ringcentral-sdk.gemspec
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Gem::Specification.new do |gem|
|
|
2
2
|
gem.name = 'ringcentral-sdk'
|
|
3
|
-
gem.version
|
|
3
|
+
gem.version = '2.0.0'
|
|
4
|
+
gem.required_ruby_version = '>= 3.3'
|
|
4
5
|
gem.authors = ['Tyler Liu']
|
|
5
6
|
gem.email = ['tyler.liu@ringcentral.com']
|
|
6
7
|
gem.description = 'This is the **official** RingCentral SDK for the Ruby programming language. While there are other Ruby SDKs for RingCentral, those are maintained by the community. We\'re including this clarification to help avoid confusion, as some SDKs have similar names. That said, we truly appreciate and welcome community contributions and alternative SDKs.'
|
|
@@ -9,13 +10,13 @@ Gem::Specification.new do |gem|
|
|
|
9
10
|
gem.license = 'MIT'
|
|
10
11
|
|
|
11
12
|
gem.require_paths = ['lib']
|
|
12
|
-
gem.files = %w(README.md ringcentral-sdk.gemspec)
|
|
13
|
+
gem.files = %w(README.md CHANGELOG.md LICENSE.md ringcentral-sdk.gemspec)
|
|
13
14
|
gem.files += Dir['lib/**/*.rb']
|
|
14
15
|
gem.test_files = Dir['spec/**/*.rb']
|
|
15
16
|
|
|
16
|
-
gem.add_dependency('addressable', '~> 2.
|
|
17
|
-
gem.add_dependency('concurrent-ruby', '~> 1.3', '>= 1.3.
|
|
18
|
-
gem.add_dependency('faraday', '~> 2.
|
|
19
|
-
gem.add_dependency('faraday-multipart', '~> 1.
|
|
20
|
-
gem.add_dependency('faye-websocket', '~> 0.
|
|
17
|
+
gem.add_dependency('addressable', '~> 2.9', '>= 2.9.2')
|
|
18
|
+
gem.add_dependency('concurrent-ruby', '~> 1.3', '>= 1.3.8')
|
|
19
|
+
gem.add_dependency('faraday', '~> 2.15', '>= 2.15.1')
|
|
20
|
+
gem.add_dependency('faraday-multipart', '~> 1.2', '>= 1.2.0')
|
|
21
|
+
gem.add_dependency('faye-websocket', '~> 0.12', '>= 0.12.0')
|
|
21
22
|
end
|
data/spec/fax_spec.rb
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
require 'dotenv'
|
|
2
|
-
require 'ringcentral'
|
|
3
|
-
require "simplecov"
|
|
4
|
-
SimpleCov.start
|
|
5
|
-
|
|
6
1
|
RSpec.describe 'Fax' do
|
|
7
2
|
describe 'send fax' do
|
|
8
3
|
it 'should send a fax' do
|
|
9
|
-
Dotenv.load
|
|
10
4
|
rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
|
|
11
5
|
rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
12
6
|
r = rc.post('/restapi/v1.0/account/~/extension/~/fax',
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
RSpec.describe 'Greeting' do
|
|
2
|
+
describe 'create custom user greeting' do
|
|
3
|
+
it 'should upload and apply a custom work-hours voicemail greeting' do
|
|
4
|
+
rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
|
|
5
|
+
rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
6
|
+
|
|
7
|
+
r = rc.post('/restapi/v1.0/account/~/extension/~/greeting',
|
|
8
|
+
params: { apply: true },
|
|
9
|
+
payload: { type: 'Voicemail', stateId: 'work-hours' },
|
|
10
|
+
files: [
|
|
11
|
+
['spec/test.wav', 'audio/wav']
|
|
12
|
+
]
|
|
13
|
+
)
|
|
14
|
+
expect(r).not_to be_nil
|
|
15
|
+
greeting = r.body
|
|
16
|
+
expect(greeting['id']).not_to be_nil
|
|
17
|
+
expect(greeting['type']).to eq('Voicemail')
|
|
18
|
+
|
|
19
|
+
rc.revoke()
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/spec/mms_spec.rb
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
require 'dotenv'
|
|
2
|
-
require 'ringcentral'
|
|
3
|
-
require "simplecov"
|
|
4
|
-
SimpleCov.start
|
|
5
|
-
|
|
6
1
|
RSpec.describe 'MMS' do
|
|
7
2
|
describe 'send MMS' do
|
|
8
3
|
it 'should send an MMS' do
|
|
9
|
-
Dotenv.load
|
|
10
4
|
rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
|
|
11
5
|
rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
12
6
|
|
data/spec/query_params_spec.rb
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
require 'dotenv'
|
|
2
|
-
require 'ringcentral'
|
|
3
|
-
require "simplecov"
|
|
4
|
-
SimpleCov.start
|
|
5
|
-
|
|
6
1
|
RSpec.describe 'query params' do
|
|
7
2
|
describe 'single' do
|
|
8
3
|
it 'contain single query param' do
|
|
9
|
-
Dotenv.load
|
|
10
4
|
rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
|
|
11
5
|
rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
12
6
|
r = rc.get('/restapi/v1.0/account/~/extension/~/address-book/contact', { phoneNumber: '666' })
|
data/spec/ringcentral_spec.rb
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
require 'ringcentral'
|
|
2
|
-
require "simplecov"
|
|
3
|
-
SimpleCov.start
|
|
4
|
-
|
|
5
1
|
RSpec.describe 'RingCentral' do
|
|
6
2
|
describe 'ringcentral' do
|
|
7
3
|
it 'test_class_variables' do
|
|
@@ -16,13 +12,18 @@ RSpec.describe 'RingCentral' do
|
|
|
16
12
|
expect(false).to eq(rc.auto_refresh)
|
|
17
13
|
end
|
|
18
14
|
|
|
15
|
+
it 'uses the production server by default without making a request' do
|
|
16
|
+
expect_any_instance_of(Faraday::Connection).not_to receive(:run_request)
|
|
17
|
+
rc = RingCentral.new('client_id', 'client_secret')
|
|
18
|
+
expect(rc.server).to eq(RingCentral.PRODUCTION_SERVER)
|
|
19
|
+
end
|
|
20
|
+
|
|
19
21
|
it 'test_authorize_uri' do
|
|
20
22
|
rc = RingCentral.new('client_id', 'client_secret', RingCentral.PRODUCTION_SERVER)
|
|
21
23
|
expect(RingCentral.PRODUCTION_SERVER + '/restapi/oauth/authorize?client_id=client_id&redirect_uri=https%3A%2F%2Fexample.com&response_type=code&state=mystate').to eq(rc.authorize_uri('https://example.com', {state: 'mystate'}))
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
it 'test_jwt_flow' do
|
|
25
|
-
Dotenv.load
|
|
26
27
|
rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
|
|
27
28
|
expect(rc.token).to be_nil
|
|
28
29
|
|
|
@@ -40,7 +41,6 @@ RSpec.describe 'RingCentral' do
|
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
it 'test_http_methods' do
|
|
43
|
-
Dotenv.load
|
|
44
44
|
rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
|
|
45
45
|
rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
46
46
|
|
data/spec/spec_helper.rb
ADDED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
require 'ringcentral'
|
|
2
1
|
require 'subscription'
|
|
3
|
-
require 'dotenv'
|
|
4
2
|
require 'rspec'
|
|
5
|
-
require "simplecov"
|
|
6
|
-
SimpleCov.start
|
|
7
3
|
|
|
8
|
-
Dotenv.load
|
|
9
4
|
$rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
|
|
10
5
|
|
|
11
6
|
RSpec.describe 'WebSocket Subscription' do
|
|
@@ -13,10 +8,31 @@ RSpec.describe 'WebSocket Subscription' do
|
|
|
13
8
|
events = [
|
|
14
9
|
'/restapi/v1.0/account/~/extension/~/message-store?type=Pager',
|
|
15
10
|
]
|
|
11
|
+
existing_ids = $rc.get('/restapi/v1.0/subscription').body.fetch('records').map { |record| record.fetch('id') }
|
|
16
12
|
subscription = WS.new($rc, events, lambda { |message|
|
|
17
13
|
callback.call(message)
|
|
18
14
|
})
|
|
19
15
|
subscription.subscribe()
|
|
16
|
+
# subscribe starts a thread; wait for server acceptance before sending a pager.
|
|
17
|
+
begin
|
|
18
|
+
deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + 30
|
|
19
|
+
loop do
|
|
20
|
+
records = $rc.get('/restapi/v1.0/subscription').body.fetch('records')
|
|
21
|
+
ready = records.any? do |record|
|
|
22
|
+
!existing_ids.include?(record.fetch('id')) && record['status'] == 'Active' &&
|
|
23
|
+
record.dig('deliveryMode', 'transportType') == 'WebSocket' &&
|
|
24
|
+
record.fetch('eventFilters').any? { |filter| filter.end_with?('/message-store?type=Pager') }
|
|
25
|
+
end
|
|
26
|
+
break if ready
|
|
27
|
+
if Process.clock_gettime(Process::CLOCK_MONOTONIC) >= deadline
|
|
28
|
+
raise 'WebSocket Pager subscription did not become active within 30 seconds'
|
|
29
|
+
end
|
|
30
|
+
sleep(1)
|
|
31
|
+
end
|
|
32
|
+
rescue StandardError
|
|
33
|
+
subscription.revoke()
|
|
34
|
+
raise
|
|
35
|
+
end
|
|
20
36
|
# subscription.on_ws_closed = lambda { |event|
|
|
21
37
|
# puts 'WebSocket closed'
|
|
22
38
|
# }
|
|
@@ -27,8 +43,10 @@ RSpec.describe 'WebSocket Subscription' do
|
|
|
27
43
|
it 'receives message notification' do
|
|
28
44
|
$rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
29
45
|
count = 0
|
|
46
|
+
notifications = Queue.new
|
|
30
47
|
sub = createSubscription(lambda { |message|
|
|
31
48
|
count += 1
|
|
49
|
+
notifications << true
|
|
32
50
|
})
|
|
33
51
|
|
|
34
52
|
$rc.post('/restapi/v1.0/account/~/extension/~/company-pager', payload: {
|
|
@@ -36,20 +54,21 @@ RSpec.describe 'WebSocket Subscription' do
|
|
|
36
54
|
from: {extensionId: $rc.token['owner_id']},
|
|
37
55
|
text: 'Hello world'
|
|
38
56
|
})
|
|
39
|
-
|
|
57
|
+
expect(notifications.pop(timeout: 30)).to eq(true)
|
|
40
58
|
expect(count).to be > 0
|
|
41
59
|
|
|
42
60
|
# sleep for some time and see if the websocket is still alive
|
|
43
61
|
sleep(20)
|
|
62
|
+
notifications.clear
|
|
44
63
|
$rc.post('/restapi/v1.0/account/~/extension/~/company-pager', payload: {
|
|
45
64
|
to: [{extensionId: $rc.token['owner_id']}],
|
|
46
65
|
from: {extensionId: $rc.token['owner_id']},
|
|
47
66
|
text: 'Hello world'
|
|
48
67
|
})
|
|
49
|
-
|
|
68
|
+
expect(notifications.pop(timeout: 30)).to eq(true)
|
|
50
69
|
expect(count).to be > 1
|
|
51
|
-
|
|
52
|
-
sub
|
|
70
|
+
ensure
|
|
71
|
+
sub&.revoke()
|
|
53
72
|
$rc.revoke()
|
|
54
73
|
end
|
|
55
74
|
|
|
@@ -67,9 +86,11 @@ RSpec.describe 'WebSocket Subscription' do
|
|
|
67
86
|
from: {extensionId: $rc.token['owner_id']},
|
|
68
87
|
text: 'Hello world'
|
|
69
88
|
})
|
|
70
|
-
sleep(
|
|
89
|
+
sleep(30)
|
|
71
90
|
|
|
72
91
|
expect(count).to eq(0)
|
|
92
|
+
ensure
|
|
93
|
+
subscription&.revoke()
|
|
73
94
|
$rc.revoke()
|
|
74
95
|
end
|
|
75
96
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ringcentral-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tyler Liu
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: addressable
|
|
@@ -16,20 +15,20 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2.
|
|
18
|
+
version: '2.9'
|
|
20
19
|
- - ">="
|
|
21
20
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: 2.
|
|
21
|
+
version: 2.9.2
|
|
23
22
|
type: :runtime
|
|
24
23
|
prerelease: false
|
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
25
|
requirements:
|
|
27
26
|
- - "~>"
|
|
28
27
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '2.
|
|
28
|
+
version: '2.9'
|
|
30
29
|
- - ">="
|
|
31
30
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 2.
|
|
31
|
+
version: 2.9.2
|
|
33
32
|
- !ruby/object:Gem::Dependency
|
|
34
33
|
name: concurrent-ruby
|
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,7 +38,7 @@ dependencies:
|
|
|
39
38
|
version: '1.3'
|
|
40
39
|
- - ">="
|
|
41
40
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: 1.3.
|
|
41
|
+
version: 1.3.8
|
|
43
42
|
type: :runtime
|
|
44
43
|
prerelease: false
|
|
45
44
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -49,67 +48,67 @@ dependencies:
|
|
|
49
48
|
version: '1.3'
|
|
50
49
|
- - ">="
|
|
51
50
|
- !ruby/object:Gem::Version
|
|
52
|
-
version: 1.3.
|
|
51
|
+
version: 1.3.8
|
|
53
52
|
- !ruby/object:Gem::Dependency
|
|
54
53
|
name: faraday
|
|
55
54
|
requirement: !ruby/object:Gem::Requirement
|
|
56
55
|
requirements:
|
|
57
56
|
- - "~>"
|
|
58
57
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: '2.
|
|
58
|
+
version: '2.15'
|
|
60
59
|
- - ">="
|
|
61
60
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: 2.
|
|
61
|
+
version: 2.15.1
|
|
63
62
|
type: :runtime
|
|
64
63
|
prerelease: false
|
|
65
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
65
|
requirements:
|
|
67
66
|
- - "~>"
|
|
68
67
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: '2.
|
|
68
|
+
version: '2.15'
|
|
70
69
|
- - ">="
|
|
71
70
|
- !ruby/object:Gem::Version
|
|
72
|
-
version: 2.
|
|
71
|
+
version: 2.15.1
|
|
73
72
|
- !ruby/object:Gem::Dependency
|
|
74
73
|
name: faraday-multipart
|
|
75
74
|
requirement: !ruby/object:Gem::Requirement
|
|
76
75
|
requirements:
|
|
77
76
|
- - "~>"
|
|
78
77
|
- !ruby/object:Gem::Version
|
|
79
|
-
version: '1.
|
|
78
|
+
version: '1.2'
|
|
80
79
|
- - ">="
|
|
81
80
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 1.
|
|
81
|
+
version: 1.2.0
|
|
83
82
|
type: :runtime
|
|
84
83
|
prerelease: false
|
|
85
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
86
85
|
requirements:
|
|
87
86
|
- - "~>"
|
|
88
87
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '1.
|
|
88
|
+
version: '1.2'
|
|
90
89
|
- - ">="
|
|
91
90
|
- !ruby/object:Gem::Version
|
|
92
|
-
version: 1.
|
|
91
|
+
version: 1.2.0
|
|
93
92
|
- !ruby/object:Gem::Dependency
|
|
94
93
|
name: faye-websocket
|
|
95
94
|
requirement: !ruby/object:Gem::Requirement
|
|
96
95
|
requirements:
|
|
97
96
|
- - "~>"
|
|
98
97
|
- !ruby/object:Gem::Version
|
|
99
|
-
version: '0.
|
|
98
|
+
version: '0.12'
|
|
100
99
|
- - ">="
|
|
101
100
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: 0.
|
|
101
|
+
version: 0.12.0
|
|
103
102
|
type: :runtime
|
|
104
103
|
prerelease: false
|
|
105
104
|
version_requirements: !ruby/object:Gem::Requirement
|
|
106
105
|
requirements:
|
|
107
106
|
- - "~>"
|
|
108
107
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '0.
|
|
108
|
+
version: '0.12'
|
|
110
109
|
- - ">="
|
|
111
110
|
- !ruby/object:Gem::Version
|
|
112
|
-
version: 0.
|
|
111
|
+
version: 0.12.0
|
|
113
112
|
description: This is the **official** RingCentral SDK for the Ruby programming language.
|
|
114
113
|
While there are other Ruby SDKs for RingCentral, those are maintained by the community.
|
|
115
114
|
We're including this clarification to help avoid confusion, as some SDKs have similar
|
|
@@ -121,20 +120,23 @@ executables: []
|
|
|
121
120
|
extensions: []
|
|
122
121
|
extra_rdoc_files: []
|
|
123
122
|
files:
|
|
123
|
+
- CHANGELOG.md
|
|
124
|
+
- LICENSE.md
|
|
124
125
|
- README.md
|
|
125
126
|
- lib/ringcentral.rb
|
|
126
127
|
- lib/subscription.rb
|
|
127
128
|
- ringcentral-sdk.gemspec
|
|
128
129
|
- spec/fax_spec.rb
|
|
130
|
+
- spec/greeting_spec.rb
|
|
129
131
|
- spec/mms_spec.rb
|
|
130
132
|
- spec/query_params_spec.rb
|
|
131
133
|
- spec/ringcentral_spec.rb
|
|
134
|
+
- spec/spec_helper.rb
|
|
132
135
|
- spec/websocket_subscription_spec.rb
|
|
133
136
|
homepage: https://github.com/ringcentral/ringcentral-ruby
|
|
134
137
|
licenses:
|
|
135
138
|
- MIT
|
|
136
139
|
metadata: {}
|
|
137
|
-
post_install_message:
|
|
138
140
|
rdoc_options: []
|
|
139
141
|
require_paths:
|
|
140
142
|
- lib
|
|
@@ -142,20 +144,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
142
144
|
requirements:
|
|
143
145
|
- - ">="
|
|
144
146
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: '
|
|
147
|
+
version: '3.3'
|
|
146
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
149
|
requirements:
|
|
148
150
|
- - ">="
|
|
149
151
|
- !ruby/object:Gem::Version
|
|
150
152
|
version: '0'
|
|
151
153
|
requirements: []
|
|
152
|
-
rubygems_version:
|
|
153
|
-
signing_key:
|
|
154
|
+
rubygems_version: 4.0.20
|
|
154
155
|
specification_version: 4
|
|
155
156
|
summary: The **official** RingCentral Ruby SDK.
|
|
156
157
|
test_files:
|
|
157
158
|
- spec/fax_spec.rb
|
|
159
|
+
- spec/greeting_spec.rb
|
|
158
160
|
- spec/mms_spec.rb
|
|
159
161
|
- spec/query_params_spec.rb
|
|
160
162
|
- spec/ringcentral_spec.rb
|
|
163
|
+
- spec/spec_helper.rb
|
|
161
164
|
- spec/websocket_subscription_spec.rb
|