ringcentral-sdk 1.0.0.pre.beta.4 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bb9f1c796f3fc2ac90aa28d1a33090d5e26fdc8445edb312fd9b1937add7add
4
- data.tar.gz: 394c158641dfe6d4f6301eec2527107eeb3909b6aff782b1af5224f700aca7ef
3
+ metadata.gz: d9b575bf77a4bc04e7ca425403bf054557e39b70e41033932b6c49d6dcf24287
4
+ data.tar.gz: a7c9fee67ff4cf89bd3b8d29aed7ead297d4808da24d5a6cb72c3ad6f06c6af0
5
5
  SHA512:
6
- metadata.gz: 6cc88ac631aca239ecb0a644d2f399e86cd055d11a50021adb0aab66d6a3bc30be7e03c448541fa5309cfed9b336ec1ef183348b3383c29f006357093bb9c24d
7
- data.tar.gz: 10a25f56bc1afbd4b3c04df79ccfecf9f7a1cd019023d6417b38b43f80fa829f651fea02a1fdf677f64c3ca8fa11457bd31d23d1f30d2bad190bfbd2958228d8
6
+ metadata.gz: 07de209ac88aa388efa1ccc3a758d3f353a5ea1e3baf22b44f1c81ae4500af70f6a16eb9a9e7b45f7386451a7773aa90196adb1e8961bf7fc976d6b1e9e08ebd
7
+ data.tar.gz: b3273ea3c2083f78b63f465fd76216f75f55937a51a1ad67498449e4666979ba6f6d42903ed7579be5f1db6420cedc8c440b3971785cee31c15b221800cb817b
data/README.md CHANGED
@@ -1,18 +1,42 @@
1
- # RingCentral SDK for Ruby
1
+ # Official RingCentral SDK for Ruby
2
2
 
3
- [![Ruby](https://github.com/ringcentral/ringcentral-ruby/actions/workflows/ruby.yml/badge.svg)](https://github.com/ringcentral/ringcentral-ruby/actions/workflows/ruby.yml)
3
+ [![Reference](https://img.shields.io/badge/rubydoc-reference-blue?logo=ruby)](https://ringcentral.github.io/ringcentral-ruby/)
4
4
  [![Twitter](https://img.shields.io/twitter/follow/ringcentraldevs.svg?style=social&label=follow)](https://twitter.com/RingCentralDevs)
5
5
 
6
- __[RingCentral Developers](https://developer.ringcentral.com/api-products)__ is a cloud communications platform which can be accessed via more than 70 APIs. The platform's main capabilities include technologies that enable:
7
- __[Voice](https://developer.ringcentral.com/api-products/voice), [SMS/MMS](https://developer.ringcentral.com/api-products/sms), [Fax](https://developer.ringcentral.com/api-products/fax), [Glip Team Messaging](https://developer.ringcentral.com/api-products/team-messaging), [Data and Configurations](https://developer.ringcentral.com/api-products/configuration)__.
6
+ **[RingCentral Developers](https://developer.ringcentral.com/api-products)** is
7
+ a cloud communications platform which can be accessed via more than 70 APIs. The
8
+ platform's main capabilities include technologies that enable:
9
+ **[Voice](https://developer.ringcentral.com/api-products/voice),
10
+ [SMS/MMS](https://developer.ringcentral.com/api-products/sms),
11
+ [Fax](https://developer.ringcentral.com/api-products/fax),
12
+ [Glip Team Messaging](https://developer.ringcentral.com/api-products/team-messaging),
13
+ [Data and Configurations](https://developer.ringcentral.com/api-products/configuration)**.
8
14
 
9
- [API Reference](https://developer.ringcentral.com/api-docs/latest/index.html) and [APIs Explorer](https://developer.ringcentral.com/api-explorer/latest/index.html).
15
+ ## Additional resources
10
16
 
17
+ - [RingCentral API Reference](https://developer.ringcentral.com/api-docs/latest/index.html) -
18
+ an interactive reference for the RingCentral API that allows developers to
19
+ make API calls with no code.
20
+ - [Document](https://ringcentral.github.io/ringcentral-ruby/) - an interactive
21
+ reference for the SDK code documentation.
11
22
 
12
23
  ## Getting help and support
13
24
 
14
- If you are having difficulty using this SDK, or working with the RingCentral API, please visit our [developer community forums](https://community.ringcentral.com/spaces/144/) for help and to get quick answers to your questions. If you wish to contact the RingCentral Developer Support team directly, please [submit a help ticket](https://developers.ringcentral.com/support/create-case) from our developer website.
25
+ If you are having difficulty using this SDK, or working with the RingCentral
26
+ API, please visit our
27
+ [developer community forums](https://community.ringcentral.com/spaces/144/) for
28
+ help and to get quick answers to your questions. If you wish to contact the
29
+ RingCentral Developer Support team directly, please
30
+ [submit a help ticket](https://developers.ringcentral.com/support/create-case)
31
+ from our developer website.
15
32
 
33
+ ## Official VS. Community maintained SDKs
34
+
35
+ This is the **official** RingCentral SDK for the Ruby programming language.
36
+ While there are other Ruby SDKs for RingCentral, those are maintained by the
37
+ community. We’re including this clarification to help avoid confusion, as some
38
+ SDKs have similar names. That said, we truly appreciate and welcome community
39
+ contributions and alternative SDKs.
16
40
 
17
41
  ## Installation
18
42
 
@@ -20,23 +44,27 @@ If you are having difficulty using this SDK, or working with the RingCentral API
20
44
  gem install ringcentral-sdk
21
45
  ```
22
46
 
23
- If for some reason `eventmachine` failed to install, please check [this](https://stackoverflow.com/a/31516586/862862).
47
+ If for some reason `eventmachine` failed to install, please check
48
+ [this](https://stackoverflow.com/a/31516586/862862).
24
49
 
50
+ There is a gem with a similar name "ringcentral_sdk". That gem is not maintained
51
+ by us.
25
52
 
26
53
  ### Name collision with `ringcentral` gem
27
54
 
28
- The `ringcentral` gem is using RingCentral's legacy API which was End-of-Lifed in 2018. Everyone is recommended to move to the REST API.
55
+ The `ringcentral` gem is using RingCentral's legacy API which was End-of-Lifed
56
+ in 2018. Everyone is recommended to move to the REST API.
29
57
 
30
- If you have both the `ringcentral` and `ringcentral-sdk` gems installed, you will run into a collision error when attempting to initialize the `ringcentral-sdk` RingCentral SDK.
58
+ If you have both the `ringcentral` and `ringcentral-sdk` gems installed, you
59
+ will run into a collision error when attempting to initialize the
60
+ `ringcentral-sdk` RingCentral SDK.
31
61
 
32
62
  The solution is `gem uninstall ringcentral`
33
63
 
34
-
35
64
  ## Documentation
36
65
 
37
66
  https://developer.ringcentral.com/api-docs/latest/index.html
38
67
 
39
-
40
68
  ## Usage
41
69
 
42
70
  ```ruby
@@ -51,6 +79,9 @@ expect(r).not_to be_nil
51
79
  expect('101').to eq(r.body['extensionNumber'])
52
80
  ```
53
81
 
82
+ ## Samples
83
+
84
+ For more code samples, please refer to the test cases in `spec` folder.
54
85
 
55
86
  ## How to specify query parameters
56
87
 
@@ -72,29 +103,31 @@ rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: body, params: { hell
72
103
  rc.get('/restapi/v1.0/account/~/extension', { hello: ['world1', 'world2'] })
73
104
  ```
74
105
 
75
- Above will be translated to `/restapi/v1.0/account/~/extension?hello=world1&hello=world2`.
76
-
106
+ Above will be translated to
107
+ `/restapi/v1.0/account/~/extension?hello=world1&hello=world2`.
77
108
 
78
109
  ### Token Refresh
79
110
 
80
- Access token expires. You need to call `rc.refresh()` before it expires.
81
- If you want the SDK to do auto refresh please `rc.auto_refresh = true` before authorization.
82
-
111
+ Access token expires. You need to call `rc.refresh()` before it expires. If you
112
+ want the SDK to do auto refresh please `rc.auto_refresh = true` before
113
+ authorization.
83
114
 
84
- ### Load preexisting token
115
+ ### Load pre-existing token
85
116
 
86
- Let's say you already have a token. Then you can load it like this: `rc.token = your_token_object`.
87
- The benefit of loading a preexisting token is you don't need to go through any authorization flow.
117
+ Let's say you already have a token. Then you can load it like this:
118
+ `rc.token = your_token_object`. The benefit of loading a preexisting token is
119
+ you don't need to go through any authorization flow.
88
120
 
89
- If what you have is a JSON string instead of a Ruby object, you need to convert it first: `JSON.parse(your_token_string)`.
121
+ If what you have is a JSON string instead of a Ruby object, you need to convert
122
+ it first: `JSON.parse(your_token_string)`.
90
123
 
91
- If you only have a string for the access token instead of for the whole object, you can set it like this:
124
+ If you only have a string for the access token instead of for the whole object,
125
+ you can set it like this:
92
126
 
93
127
  ```ruby
94
128
  rc.token = { access_token: 'the token string' }
95
129
  ```
96
130
 
97
-
98
131
  ### Send SMS
99
132
 
100
133
  ```ruby
@@ -105,7 +138,6 @@ r = rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
105
138
  })
106
139
  ```
107
140
 
108
-
109
141
  ### Send fax
110
142
 
111
143
  ```ruby
@@ -118,7 +150,6 @@ payload: { to: [{ phoneNumber: ENV['RINGCENTRAL_RECEIVER'] }] },
118
150
  )
119
151
  ```
120
152
 
121
-
122
153
  ### Send MMS
123
154
 
124
155
  ```ruby
@@ -134,7 +165,6 @@ r = rc.post('/restapi/v1.0/account/~/extension/~/sms',
134
165
  )
135
166
  ```
136
167
 
137
-
138
168
  ## Subscriptions
139
169
 
140
170
  ### WebSocket Subscriptions
@@ -153,10 +183,13 @@ subscription.subscribe()
153
183
 
154
184
  There are two main cases that a subscription will be terminated:
155
185
 
156
- - Absolute time out. The maximum time for a subscription to run is 24 hours. After that, the websocket connection will be closed by the server.
157
- - Network issue. It could be your local network issue or the server's network issue. In either case, your websocket connection will be closed
186
+ - Absolute time out. The maximum time for a subscription to run is 24 hours.
187
+ After that, the websocket connection will be closed by the server.
188
+ - Network issue. It could be your local network issue or the server's network
189
+ issue. In either case, your websocket connection will be closed
158
190
 
159
- In order to keep a subscription running 24 * 7, you need to re-subscribe when the connection is closed.
191
+ In order to keep a subscription running 24 * 7, you need to re-subscribe when
192
+ the connection is closed.
160
193
 
161
194
  ```ruby
162
195
  subscription.on_ws_closed = lambda { |event|
@@ -165,26 +198,10 @@ subscription.on_ws_closed = lambda { |event|
165
198
  }
166
199
  ```
167
200
 
168
- ### (deprecated) PubNub Subscriptions
169
-
170
- ```ruby
171
- events = [
172
- '/restapi/v1.0/account/~/extension/~/message-store',
173
- ]
174
- subscription = PubNub.new(rc, events, lambda { |message|
175
- puts message
176
- })
177
- subscription.subscribe()
178
- ```
179
-
180
-
181
- For more sample codes, please refer to the [test cases](/spec).
182
-
183
-
184
201
  ## How to test
185
202
 
186
203
  ```
187
- bundle install --path vendor/bundle
204
+ bundle install
188
205
  ```
189
206
 
190
207
  Rename `.env.sample` to `.env`.
@@ -195,7 +212,6 @@ Edit `.env` file to specify credentials.
195
212
 
196
213
  Run `bundle exec rspec`
197
214
 
198
-
199
215
  ## License
200
216
 
201
217
  MIT
data/lib/ringcentral.rb CHANGED
@@ -4,13 +4,8 @@ require 'json'
4
4
  require 'concurrent'
5
5
  require 'faraday'
6
6
  require 'faraday/multipart'
7
- require 'tmpdir'
8
7
 
9
8
  class RingCentral
10
- def self.SANDBOX_SERVER
11
- 'https://platform.devtest.ringcentral.com'
12
- end
13
-
14
9
  def self.PRODUCTION_SERVER
15
10
  'https://platform.ringcentral.com'
16
11
  end
@@ -18,7 +13,7 @@ class RingCentral
18
13
  attr_reader :client_id, :client_secret, :server, :token
19
14
  attr_accessor :auto_refresh, :debug_mode
20
15
 
21
- def initialize(client_id, client_secret, server, debug_mode = false)
16
+ def initialize(client_id, client_secret, server = self.PRODUCTION_SERVER, debug_mode = false)
22
17
  @client_id = client_id
23
18
  @client_secret = client_secret
24
19
  @server = server
data/lib/subscription.rb CHANGED
@@ -1,7 +1,4 @@
1
- require 'pubnub'
2
1
  require 'concurrent'
3
- require 'openssl'
4
- require 'base64'
5
2
  require 'faye/websocket'
6
3
  require 'securerandom'
7
4
  require 'eventmachine'
@@ -67,79 +64,3 @@ class WS
67
64
  @t.kill
68
65
  end
69
66
  end
70
-
71
- class PubNub
72
- attr_accessor :events
73
-
74
- def initialize(ringcentral, events, message_callback, status_callback = nil, presence_callback = nil)
75
- warn('PubNub is deprecated. Use WS (WebSocket) instead.')
76
- @rc = ringcentral
77
- @events = events
78
- @callback = Pubnub::SubscribeCallback.new(
79
- message: lambda { |envelope|
80
- message = envelope.result[:data][:message]
81
- cipher = OpenSSL::Cipher::AES.new(128, :ECB)
82
- cipher.decrypt
83
- cipher.key = Base64.decode64(@subscription['deliveryMode']['encryptionKey'])
84
- ciphertext = Base64.decode64(message)
85
- plaintext = cipher.update(ciphertext) + cipher.final
86
- message_callback.call(JSON.parse(plaintext))
87
- },
88
- presence: lambda { |envelope|
89
- presence_callback != nil && presence_callback.call(envelope)
90
- },
91
- status: lambda { |envelope|
92
- status_callback != nil && status_callback.call(envelope)
93
- }
94
- )
95
- @subscription = nil
96
- @timer = nil
97
- @pubnub = nil
98
- end
99
-
100
- def subscription=(value)
101
- @subscription = value
102
- if @timer != nil
103
- @timer.shutdown
104
- @timer = nil
105
- end
106
- if value != nil
107
- @timer = Concurrent::TimerTask.new(execution_interval: value['expiresIn'] - 120) do
108
- self.refresh
109
- end
110
- @timer.execute
111
- end
112
- end
113
-
114
- def subscribe
115
- r = @rc.post('/restapi/v1.0/subscription', payload: request_body)
116
- self.subscription = r.body
117
- @pubnub = Pubnub.new(subscribe_key: @subscription['deliveryMode']['subscriberKey'], user_id: @rc.token['owner_id'])
118
- @pubnub.add_listener(name: 'default', callback: @callback)
119
- @pubnub.subscribe(channels: @subscription['deliveryMode']['address'])
120
- end
121
-
122
- def refresh
123
- return if @subscription == nil
124
- r = @rc.put("/restapi/v1.0/subscription/#{@subscription['id']}", payload: request_body)
125
- self.subscription = r.body
126
- end
127
-
128
- def revoke
129
- return if @subscription == nil
130
- @pubnub.unsubscribe(channel: @subscription['deliveryMode']['address'])
131
- @pubnub.remove_listener(name: 'default')
132
- @pubnub = nil
133
- @rc.delete("/restapi/v1.0/subscription/#{@subscription['id']}")
134
- self.subscription = nil
135
- end
136
-
137
- private
138
-
139
- def request_body
140
- {
141
- 'deliveryMode': { 'transportType': 'PubNub', 'encryption': true },
142
- 'eventFilters': @events
143
- }
144
- end
145
- end
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'ringcentral-sdk'
3
- gem.version = '1.0.0-beta.4'
3
+ gem.version = '1.1.0'
4
4
  gem.authors = ['Tyler Liu']
5
5
  gem.email = ['tyler.liu@ringcentral.com']
6
- gem.description = 'Ruby SDK for you to access RingCentral platform API.'
7
- gem.summary = 'RingCentral Ruby SDK.'
6
+ gem.description = 'Ruby SDK for you to access RingCentral platform APIs. 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.'
7
+ gem.summary = 'The official RingCentral Ruby SDK.'
8
8
  gem.homepage = 'https://github.com/ringcentral/ringcentral-ruby'
9
9
  gem.license = 'MIT'
10
10
 
@@ -13,10 +13,9 @@ Gem::Specification.new do |gem|
13
13
  gem.files += Dir['lib/**/*.rb']
14
14
  gem.test_files = Dir['spec/**/*.rb']
15
15
 
16
- gem.add_dependency('addressable', '~> 2.8', '>= 2.8.4')
17
- gem.add_dependency('concurrent-ruby', '~> 1.2', '>= 1.2.2')
18
- gem.add_dependency('pubnub', '~> 5.2', '>= 5.2.2')
19
- gem.add_dependency('faraday', '~> 2.7', '>= 2.7.4')
16
+ gem.add_dependency('addressable', '~> 2.8', '>= 2.8.6')
17
+ gem.add_dependency('concurrent-ruby', '~> 1.2', '>= 1.2.3')
18
+ gem.add_dependency('faraday', '~> 2.9', '>= 2.9.0')
20
19
  gem.add_dependency('faraday-multipart', '~> 1.0', '>= 1.0.4')
21
- gem.add_dependency('faye-websocket', '~> 0.11', '>= 0.11.2')
20
+ gem.add_dependency('faye-websocket', '~> 0.11', '>= 0.11.3')
22
21
  end
data/spec/fax_spec.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'dotenv'
2
2
  require 'ringcentral'
3
+ require "simplecov"
4
+ SimpleCov.start
3
5
 
4
6
  RSpec.describe 'Fax' do
5
7
  describe 'send fax' do
data/spec/mms_spec.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'dotenv'
2
2
  require 'ringcentral'
3
+ require "simplecov"
4
+ SimpleCov.start
3
5
 
4
6
  RSpec.describe 'MMS' do
5
7
  describe 'send MMS' do
@@ -8,20 +10,19 @@ RSpec.describe 'MMS' do
8
10
  rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
9
11
  rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
10
12
 
11
- # comment out because sandbox doesn't support mms any more.
12
- # r = rc.post('/restapi/v1.0/account/~/extension/~/sms',
13
- # payload: {
14
- # to: [{ phoneNumber: ENV['RINGCENTRAL_RECEIVER'] }],
15
- # from: { phoneNumber: ENV['RINGCENTRAL_SENDER'] },
16
- # text: 'hello world'
17
- # },
18
- # files: [
19
- # ['spec/test.png', 'image/png']
20
- # ]
21
- # )
22
- # expect(r).not_to be_nil
23
- # message = r.body
24
- # expect('SMS').to eq(message['type'])
13
+ r = rc.post('/restapi/v1.0/account/~/extension/~/sms',
14
+ payload: {
15
+ to: [{ phoneNumber: ENV['RINGCENTRAL_RECEIVER'] }],
16
+ from: { phoneNumber: ENV['RINGCENTRAL_SENDER'] },
17
+ text: 'hello world'
18
+ },
19
+ files: [
20
+ ['spec/test.png', 'image/png']
21
+ ]
22
+ )
23
+ expect(r).not_to be_nil
24
+ message = r.body
25
+ expect('SMS').to eq(message['type'])
25
26
 
26
27
  rc.revoke()
27
28
  end
@@ -1,5 +1,7 @@
1
1
  require 'dotenv'
2
2
  require 'ringcentral'
3
+ require "simplecov"
4
+ SimpleCov.start
3
5
 
4
6
  RSpec.describe 'query params' do
5
7
  describe 'single' do
@@ -1,23 +1,24 @@
1
1
  require 'ringcentral'
2
+ require "simplecov"
3
+ SimpleCov.start
2
4
 
3
5
  RSpec.describe 'RingCentral' do
4
6
  describe 'ringcentral' do
5
7
  it 'test_class_variables' do
6
- expect('https://platform.devtest.ringcentral.com').to eq(RingCentral.SANDBOX_SERVER)
7
8
  expect('https://platform.ringcentral.com').to eq(RingCentral.PRODUCTION_SERVER)
8
9
  end
9
10
 
10
11
  it 'test_initializer' do
11
- rc = RingCentral.new('client_id', 'client_secret', RingCentral.SANDBOX_SERVER)
12
+ rc = RingCentral.new('client_id', 'client_secret', RingCentral.PRODUCTION_SERVER)
12
13
  expect('client_id').to eq(rc.client_id)
13
14
  expect('client_secret').to eq(rc.client_secret)
14
- expect('https://platform.devtest.ringcentral.com').to eq(rc.server)
15
+ expect('https://platform.ringcentral.com').to eq(rc.server)
15
16
  expect(false).to eq(rc.auto_refresh)
16
17
  end
17
18
 
18
19
  it 'test_authorize_uri' do
19
- rc = RingCentral.new('client_id', 'client_secret', RingCentral.SANDBOX_SERVER)
20
- expect(RingCentral.SANDBOX_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'}))
20
+ rc = RingCentral.new('client_id', 'client_secret', RingCentral.PRODUCTION_SERVER)
21
+ 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'}))
21
22
  end
22
23
 
23
24
  it 'test_jwt_flow' do
@@ -46,7 +47,7 @@ RSpec.describe 'RingCentral' do
46
47
  # get
47
48
  r = rc.get('/restapi/v1.0/account/~/extension/~')
48
49
  expect(r).not_to be_nil
49
- expect('101').to eq(r.body['extensionNumber'])
50
+ expect(r.body['extensionNumber']).not_to be_nil
50
51
 
51
52
  # post
52
53
  r = rc.post('/restapi/v1.0/account/~/extension/~/company-pager', payload: {
@@ -72,13 +73,12 @@ RSpec.describe 'RingCentral' do
72
73
  # todo: test patch
73
74
 
74
75
  # delete
75
- # todo: delete "availability" is broken, because of sandbox env
76
- # r = rc.delete(messageUrl)
77
- # expect(r).not_to be_nil
78
- # r = rc.get(messageUrl)
79
- # expect(r).not_to be_nil
80
- # message = r.body
81
- # expect('Deleted').to eq(message['availability'])
76
+ r = rc.delete(messageUrl)
77
+ expect(r).not_to be_nil
78
+ r = rc.get(messageUrl)
79
+ expect(r).not_to be_nil
80
+ message = r.body
81
+ expect('Deleted').to eq(message['availability'])
82
82
 
83
83
  rc.revoke()
84
84
  end
@@ -2,6 +2,8 @@ require 'ringcentral'
2
2
  require 'subscription'
3
3
  require 'dotenv'
4
4
  require 'rspec'
5
+ require "simplecov"
6
+ SimpleCov.start
5
7
 
6
8
  Dotenv.load
7
9
  $rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
@@ -34,17 +36,17 @@ RSpec.describe 'WebSocket Subscription' do
34
36
  from: {extensionId: $rc.token['owner_id']},
35
37
  text: 'Hello world'
36
38
  })
37
- sleep(20)
39
+ sleep(10)
38
40
  expect(count).to be > 0
39
41
 
40
42
  # sleep for some time and see if the websocket is still alive
41
- sleep(60)
43
+ sleep(20)
42
44
  $rc.post('/restapi/v1.0/account/~/extension/~/company-pager', payload: {
43
45
  to: [{extensionId: $rc.token['owner_id']}],
44
46
  from: {extensionId: $rc.token['owner_id']},
45
47
  text: 'Hello world'
46
48
  })
47
- sleep(20)
49
+ sleep(10)
48
50
  expect(count).to be > 1
49
51
 
50
52
  sub.revoke()
@@ -65,7 +67,7 @@ RSpec.describe 'WebSocket Subscription' do
65
67
  from: {extensionId: $rc.token['owner_id']},
66
68
  text: 'Hello world'
67
69
  })
68
- sleep(20)
70
+ sleep(10)
69
71
 
70
72
  expect(count).to eq(0)
71
73
  $rc.revoke()
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.0.0.pre.beta.4
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Liu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-11 00:00:00.000000000 Z
11
+ date: 2025-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '2.8'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 2.8.4
22
+ version: 2.8.6
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '2.8'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 2.8.4
32
+ version: 2.8.6
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: concurrent-ruby
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '1.2'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 1.2.2
42
+ version: 1.2.3
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,47 +49,27 @@ dependencies:
49
49
  version: '1.2'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 1.2.2
53
- - !ruby/object:Gem::Dependency
54
- name: pubnub
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '5.2'
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 5.2.2
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '5.2'
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 5.2.2
52
+ version: 1.2.3
73
53
  - !ruby/object:Gem::Dependency
74
54
  name: faraday
75
55
  requirement: !ruby/object:Gem::Requirement
76
56
  requirements:
77
57
  - - "~>"
78
58
  - !ruby/object:Gem::Version
79
- version: '2.7'
59
+ version: '2.9'
80
60
  - - ">="
81
61
  - !ruby/object:Gem::Version
82
- version: 2.7.4
62
+ version: 2.9.0
83
63
  type: :runtime
84
64
  prerelease: false
85
65
  version_requirements: !ruby/object:Gem::Requirement
86
66
  requirements:
87
67
  - - "~>"
88
68
  - !ruby/object:Gem::Version
89
- version: '2.7'
69
+ version: '2.9'
90
70
  - - ">="
91
71
  - !ruby/object:Gem::Version
92
- version: 2.7.4
72
+ version: 2.9.0
93
73
  - !ruby/object:Gem::Dependency
94
74
  name: faraday-multipart
95
75
  requirement: !ruby/object:Gem::Requirement
@@ -119,7 +99,7 @@ dependencies:
119
99
  version: '0.11'
120
100
  - - ">="
121
101
  - !ruby/object:Gem::Version
122
- version: 0.11.2
102
+ version: 0.11.3
123
103
  type: :runtime
124
104
  prerelease: false
125
105
  version_requirements: !ruby/object:Gem::Requirement
@@ -129,8 +109,12 @@ dependencies:
129
109
  version: '0.11'
130
110
  - - ">="
131
111
  - !ruby/object:Gem::Version
132
- version: 0.11.2
133
- description: Ruby SDK for you to access RingCentral platform API.
112
+ version: 0.11.3
113
+ description: Ruby SDK for you to access RingCentral platform APIs. This is the **official**
114
+ RingCentral SDK for the Ruby programming language. While there are other Ruby SDKs
115
+ for RingCentral, those are maintained by the community. We're including this clarification
116
+ to help avoid confusion, as some SDKs have similar names. That said, we truly appreciate
117
+ and welcome community contributions and alternative SDKs.
134
118
  email:
135
119
  - tyler.liu@ringcentral.com
136
120
  executables: []
@@ -143,7 +127,6 @@ files:
143
127
  - ringcentral-sdk.gemspec
144
128
  - spec/fax_spec.rb
145
129
  - spec/mms_spec.rb
146
- - spec/pubnub_subscription_spec.rb
147
130
  - spec/query_params_spec.rb
148
131
  - spec/ringcentral_spec.rb
149
132
  - spec/websocket_subscription_spec.rb
@@ -162,18 +145,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
145
  version: '0'
163
146
  required_rubygems_version: !ruby/object:Gem::Requirement
164
147
  requirements:
165
- - - ">"
148
+ - - ">="
166
149
  - !ruby/object:Gem::Version
167
- version: 1.3.1
150
+ version: '0'
168
151
  requirements: []
169
152
  rubygems_version: 3.4.10
170
153
  signing_key:
171
154
  specification_version: 4
172
- summary: RingCentral Ruby SDK.
155
+ summary: The official RingCentral Ruby SDK.
173
156
  test_files:
174
157
  - spec/fax_spec.rb
175
158
  - spec/mms_spec.rb
176
- - spec/pubnub_subscription_spec.rb
177
159
  - spec/query_params_spec.rb
178
160
  - spec/ringcentral_spec.rb
179
161
  - spec/websocket_subscription_spec.rb
@@ -1,80 +0,0 @@
1
- require 'ringcentral'
2
- require 'subscription'
3
- require 'dotenv'
4
- require 'rspec'
5
-
6
- Dotenv.load
7
- $rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
8
-
9
- RSpec.describe 'PubNub Subscription' do
10
- def createSubscription(callback)
11
- events = [
12
- '/restapi/v1.0/account/~/extension/~/message-store?type=Pager',
13
- ]
14
- subscription = PubNub.new($rc, events, lambda { |message|
15
- callback.call(message)
16
- })
17
- subscription.subscribe()
18
- return subscription
19
- end
20
-
21
- describe 'PubNub Subscription' do
22
- it 'receives message notification' do
23
- $rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
24
- count = 0
25
- createSubscription(lambda { |message|
26
- count += 1
27
- })
28
-
29
- $rc.post('/restapi/v1.0/account/~/extension/~/company-pager', payload: {
30
- to: [{extensionId: $rc.token['owner_id']}],
31
- from: {extensionId: $rc.token['owner_id']},
32
- text: 'Hello world'
33
- })
34
- sleep(20)
35
-
36
- expect(count).to be > 0
37
- $rc.revoke()
38
- end
39
-
40
- it 'refresh' do
41
- $rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
42
- count = 0
43
- subscription = createSubscription(lambda { |message|
44
- count += 1
45
- })
46
-
47
- subscription.refresh()
48
-
49
- $rc.post('/restapi/v1.0/account/~/extension/~/company-pager', payload: {
50
- to: [{extensionId: $rc.token['owner_id']}],
51
- from: {extensionId: $rc.token['owner_id']},
52
- text: 'Hello world'
53
- })
54
- sleep(20)
55
-
56
- expect(count).to be > 0
57
- $rc.revoke()
58
- end
59
-
60
- it 'revoke' do
61
- $rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
62
- count = 0
63
- subscription = createSubscription(lambda { |message|
64
- count += 1
65
- })
66
-
67
- subscription.revoke()
68
-
69
- $rc.post('/restapi/v1.0/account/~/extension/~/company-pager', payload: {
70
- to: [{extensionId: $rc.token['owner_id']}],
71
- from: {extensionId: $rc.token['owner_id']},
72
- text: 'Hello world'
73
- })
74
- sleep(20)
75
-
76
- expect(count).to eq(0)
77
- $rc.revoke()
78
- end
79
- end
80
- end