ringcentral-sdk 0.9.7 → 0.9.9
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/README.md +7 -21
- data/lib/ringcentral.rb +69 -20
- data/lib/subscription.rb +2 -3
- data/ringcentral-sdk.gemspec +5 -5
- data/spec/fax_spec.rb +3 -1
- data/spec/mms_spec.rb +4 -2
- data/spec/query_params_spec.rb +2 -1
- data/spec/ringcentral_spec.rb +7 -5
- data/spec/subscription_spec.rb +10 -4
- metadata +17 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c82aa5b359e0d18f0096e856d81cebb7c00990208cc210a217d49d470ee19eb
|
|
4
|
+
data.tar.gz: 5a4f3973076393c86fa95ea47aa7b467c0b01abd3c46fcd819a5c976ab625717
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1cd78622b101fbf1ef52b717af4ea587fdf98517613d9de858f432c3954e89c4c8393a16f67a43bfa29fe938d2711970200133ad9fc7362307b214d0a807f094
|
|
7
|
+
data.tar.gz: 9a98212a1550ee2cd269d8b935fb25115f31f9ece0609498e6a5fa2efd701107da6e3ed58a48fb266e118934e85b8ded88860529f93c13142ea2d87cb315e94b
|
data/README.md
CHANGED
|
@@ -41,7 +41,7 @@ https://developer.ringcentral.com/api-docs/latest/index.html
|
|
|
41
41
|
require 'ringcentral'
|
|
42
42
|
|
|
43
43
|
rc = RingCentral.new('clientID', 'clientSecret', 'serverURL')
|
|
44
|
-
rc.authorize(
|
|
44
|
+
rc.authorize(jwt: 'jwt-token')
|
|
45
45
|
|
|
46
46
|
# get
|
|
47
47
|
r = rc.get('/restapi/v1.0/account/~/extension/~')
|
|
@@ -82,8 +82,7 @@ If you want the SDK to do auto refresh please `rc.auto_refresh = true` before au
|
|
|
82
82
|
### Load preexisting token
|
|
83
83
|
|
|
84
84
|
Let's say you already have a token. Then you can load it like this: `rc.token = your_token_object`.
|
|
85
|
-
|
|
86
|
-
The benifits of loading a preexisting token is you don't need to go through any authorization flow.
|
|
85
|
+
The benefit of loading a preexisting token is you don't need to go through any authorization flow.
|
|
87
86
|
|
|
88
87
|
If what you have is a JSON string instead of a Ruby object, you need to convert it first: `JSON.parse(your_token_string)`.
|
|
89
88
|
|
|
@@ -99,7 +98,7 @@ rc.token = { access_token: 'the token string' }
|
|
|
99
98
|
```ruby
|
|
100
99
|
r = rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
|
|
101
100
|
to: [{phoneNumber: ENV['RINGCENTRAL_RECEIVER']}],
|
|
102
|
-
from: {phoneNumber: ENV['
|
|
101
|
+
from: {phoneNumber: ENV['RINGCENTRAL_SENDER']},
|
|
103
102
|
text: 'Hello world'
|
|
104
103
|
})
|
|
105
104
|
```
|
|
@@ -124,7 +123,7 @@ payload: { to: [{ phoneNumber: ENV['RINGCENTRAL_RECEIVER'] }] },
|
|
|
124
123
|
r = rc.post('/restapi/v1.0/account/~/extension/~/sms',
|
|
125
124
|
payload: {
|
|
126
125
|
to: [{ phoneNumber: ENV['RINGCENTRAL_RECEIVER'] }],
|
|
127
|
-
from: { phoneNumber: ENV['
|
|
126
|
+
from: { phoneNumber: ENV['RINGCENTRAL_SENDER'] },
|
|
128
127
|
text: 'hello world'
|
|
129
128
|
},
|
|
130
129
|
files: [
|
|
@@ -154,7 +153,7 @@ createSubscription(lambda { |message|
|
|
|
154
153
|
```
|
|
155
154
|
|
|
156
155
|
|
|
157
|
-
For more sample
|
|
156
|
+
For more sample codes, please refer to the [test cases](/spec).
|
|
158
157
|
|
|
159
158
|
|
|
160
159
|
## How to test
|
|
@@ -163,17 +162,9 @@ For more sample code, please refer to the [test cases](/spec).
|
|
|
163
162
|
bundle install --path vendor/bundle
|
|
164
163
|
```
|
|
165
164
|
|
|
166
|
-
|
|
165
|
+
Rename `.env.sample` to `.env`.
|
|
167
166
|
|
|
168
|
-
|
|
169
|
-
RINGCENTRAL_SERVER_URL=https://platform.devtest.ringcentral.com
|
|
170
|
-
RINGCENTRAL_CLIENT_ID=
|
|
171
|
-
RINGCENTRAL_CLIENT_SECRET=
|
|
172
|
-
RINGCENTRAL_USERNAME=
|
|
173
|
-
RINGCENTRAL_EXTENSION=
|
|
174
|
-
RINGCENTRAL_PASSWORD=
|
|
175
|
-
RINGCENTRAL_RECEIVER=
|
|
176
|
-
```
|
|
167
|
+
Edit `.env` file to specify credentials.
|
|
177
168
|
|
|
178
169
|
`RINGCENTRAL_RECEIVER` is a phone number to receive SMS, Fax..etc.
|
|
179
170
|
|
|
@@ -183,8 +174,3 @@ Run `bundle exec rspec`
|
|
|
183
174
|
## License
|
|
184
175
|
|
|
185
176
|
MIT
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
## Todo
|
|
189
|
-
|
|
190
|
-
- Batch requests
|
data/lib/ringcentral.rb
CHANGED
|
@@ -16,13 +16,14 @@ class RingCentral
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
attr_reader :client_id, :client_secret, :server, :token
|
|
19
|
-
attr_accessor :auto_refresh
|
|
19
|
+
attr_accessor :auto_refresh, :debug_mode
|
|
20
20
|
|
|
21
|
-
def initialize(client_id, client_secret, server)
|
|
21
|
+
def initialize(client_id, client_secret, server, debug_mode = false)
|
|
22
22
|
@client_id = client_id
|
|
23
23
|
@client_secret = client_secret
|
|
24
24
|
@server = server
|
|
25
25
|
@auto_refresh = false
|
|
26
|
+
@debug_mode = debug_mode
|
|
26
27
|
@token = nil
|
|
27
28
|
@timer = nil
|
|
28
29
|
@faraday = Faraday.new(url: server, request: { params_encoder: Faraday::FlatParamsEncoder }) do |faraday|
|
|
@@ -91,31 +92,36 @@ class RingCentral
|
|
|
91
92
|
self.post('/restapi/oauth/revoke', payload: payload)
|
|
92
93
|
end
|
|
93
94
|
|
|
94
|
-
def authorize_uri(redirect_uri,
|
|
95
|
+
def authorize_uri(redirect_uri, hash = {})
|
|
96
|
+
hash[:response_type] = 'code'
|
|
97
|
+
hash[:redirect_uri] = redirect_uri
|
|
98
|
+
hash[:client_id] = @client_id
|
|
95
99
|
uri = Addressable::URI.parse(@server) + '/restapi/oauth/authorize'
|
|
96
|
-
uri.query_values =
|
|
97
|
-
response_type: 'code',
|
|
98
|
-
state: state,
|
|
99
|
-
redirect_uri: redirect_uri,
|
|
100
|
-
client_id: @client_id
|
|
101
|
-
}
|
|
102
|
-
if challenge != nil
|
|
103
|
-
uri.query_values["code_challenge"] = challenge
|
|
104
|
-
uri.query_values["code_challenge_method"] = challenge_method
|
|
105
|
-
end
|
|
100
|
+
uri.query_values = hash
|
|
106
101
|
uri.to_s
|
|
107
102
|
end
|
|
108
103
|
|
|
109
104
|
def get(endpoint, params = {})
|
|
110
|
-
@faraday.get do |req|
|
|
105
|
+
r = @faraday.get do |req|
|
|
111
106
|
req.url endpoint
|
|
112
107
|
req.params = params
|
|
113
108
|
req.headers = headers
|
|
114
109
|
end
|
|
110
|
+
if @debug_mode
|
|
111
|
+
puts r.status, r.body
|
|
112
|
+
end
|
|
113
|
+
if r.status >= 400
|
|
114
|
+
raise "HTTP status #{r.status}:
|
|
115
|
+
|
|
116
|
+
headers: #{r.headers}
|
|
117
|
+
|
|
118
|
+
body: #{r.body}"
|
|
119
|
+
end
|
|
120
|
+
return r
|
|
115
121
|
end
|
|
116
122
|
|
|
117
123
|
def post(endpoint, payload: nil, params: {}, files: nil)
|
|
118
|
-
@faraday.post do |req|
|
|
124
|
+
r = @faraday.post do |req|
|
|
119
125
|
req.url endpoint
|
|
120
126
|
req.params = params
|
|
121
127
|
if files != nil && files.size > 0 # send fax or MMS
|
|
@@ -133,32 +139,76 @@ class RingCentral
|
|
|
133
139
|
req.body = payload
|
|
134
140
|
end
|
|
135
141
|
end
|
|
142
|
+
if @debug_mode
|
|
143
|
+
puts r.status, r.body
|
|
144
|
+
end
|
|
145
|
+
if r.status >= 400
|
|
146
|
+
raise "HTTP status #{r.status}:
|
|
147
|
+
|
|
148
|
+
headers: #{r.headers}
|
|
149
|
+
|
|
150
|
+
body: #{r.body}"
|
|
151
|
+
end
|
|
152
|
+
return r
|
|
136
153
|
end
|
|
137
154
|
|
|
138
155
|
def put(endpoint, payload: nil, params: {}, files: nil)
|
|
139
|
-
@faraday.put do |req|
|
|
156
|
+
r = @faraday.put do |req|
|
|
140
157
|
req.url endpoint
|
|
141
158
|
req.params = params
|
|
142
159
|
req.headers = headers.merge({ 'Content-Type': 'application/json' })
|
|
143
160
|
req.body = payload.to_json
|
|
144
161
|
end
|
|
162
|
+
if @debug_mode
|
|
163
|
+
puts r.status, r.body
|
|
164
|
+
end
|
|
165
|
+
if r.status >= 400
|
|
166
|
+
raise "HTTP status #{r.status}:
|
|
167
|
+
|
|
168
|
+
headers: #{r.headers}
|
|
169
|
+
|
|
170
|
+
body: #{r.body}"
|
|
171
|
+
end
|
|
172
|
+
return r
|
|
145
173
|
end
|
|
146
174
|
|
|
147
175
|
def patch(endpoint, payload: nil, params: {}, files: nil)
|
|
148
|
-
@faraday.patch do |req|
|
|
176
|
+
r = @faraday.patch do |req|
|
|
149
177
|
req.url endpoint
|
|
150
178
|
req.params = params
|
|
151
179
|
req.headers = headers.merge({ 'Content-Type': 'application/json' })
|
|
152
180
|
req.body = payload.to_json
|
|
153
181
|
end
|
|
182
|
+
if @debug_mode
|
|
183
|
+
puts r.status, r.body
|
|
184
|
+
end
|
|
185
|
+
if r.status >= 400
|
|
186
|
+
raise "HTTP status #{r.status}:
|
|
187
|
+
|
|
188
|
+
headers: #{r.headers}
|
|
189
|
+
|
|
190
|
+
body: #{r.body}"
|
|
191
|
+
end
|
|
192
|
+
return r
|
|
154
193
|
end
|
|
155
194
|
|
|
156
195
|
def delete(endpoint, params = {})
|
|
157
|
-
@faraday.delete do |req|
|
|
196
|
+
r = @faraday.delete do |req|
|
|
158
197
|
req.url endpoint
|
|
159
198
|
req.params = params
|
|
160
199
|
req.headers = headers
|
|
161
200
|
end
|
|
201
|
+
if @debug_mode
|
|
202
|
+
puts r.status, r.body
|
|
203
|
+
end
|
|
204
|
+
if r.status >= 400
|
|
205
|
+
raise "HTTP status #{r.status}:
|
|
206
|
+
|
|
207
|
+
headers: #{r.headers}
|
|
208
|
+
|
|
209
|
+
body: #{r.body}"
|
|
210
|
+
end
|
|
211
|
+
return r
|
|
162
212
|
end
|
|
163
213
|
|
|
164
214
|
private
|
|
@@ -175,8 +225,7 @@ class RingCentral
|
|
|
175
225
|
user_agent_header = "ringcentral/ringcentral-ruby Ruby #{RUBY_VERSION} #{RUBY_PLATFORM}"
|
|
176
226
|
{
|
|
177
227
|
'Authorization': autorization_header,
|
|
178
|
-
'
|
|
179
|
-
'User-Agent': user_agent_header,
|
|
228
|
+
'X-User-Agent': user_agent_header,
|
|
180
229
|
}
|
|
181
230
|
end
|
|
182
231
|
end
|
data/lib/subscription.rb
CHANGED
|
@@ -2,7 +2,6 @@ require 'pubnub'
|
|
|
2
2
|
require 'concurrent'
|
|
3
3
|
require 'openssl'
|
|
4
4
|
require 'base64'
|
|
5
|
-
require 'securerandom'
|
|
6
5
|
|
|
7
6
|
class PubNub
|
|
8
7
|
attr_accessor :events
|
|
@@ -39,7 +38,7 @@ class PubNub
|
|
|
39
38
|
@timer = nil
|
|
40
39
|
end
|
|
41
40
|
if value != nil
|
|
42
|
-
@timer = Concurrent::TimerTask.new(execution_interval: value['expiresIn'] - 120
|
|
41
|
+
@timer = Concurrent::TimerTask.new(execution_interval: value['expiresIn'] - 120) do
|
|
43
42
|
self.refresh
|
|
44
43
|
end
|
|
45
44
|
@timer.execute
|
|
@@ -49,7 +48,7 @@ class PubNub
|
|
|
49
48
|
def subscribe
|
|
50
49
|
r = @rc.post('/restapi/v1.0/subscription', payload: request_body)
|
|
51
50
|
self.subscription = r.body
|
|
52
|
-
@pubnub = Pubnub.new(subscribe_key: @subscription['deliveryMode']['subscriberKey'],
|
|
51
|
+
@pubnub = Pubnub.new(subscribe_key: @subscription['deliveryMode']['subscriberKey'], user_id: @rc.token['owner_id'])
|
|
53
52
|
@pubnub.add_listener(name: 'default', callback: @callback)
|
|
54
53
|
@pubnub.subscribe(channels: @subscription['deliveryMode']['address'])
|
|
55
54
|
end
|
data/ringcentral-sdk.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |gem|
|
|
2
2
|
gem.name = 'ringcentral-sdk'
|
|
3
|
-
gem.version = '0.9.
|
|
3
|
+
gem.version = '0.9.9'
|
|
4
4
|
gem.authors = ['Tyler Liu']
|
|
5
5
|
gem.email = ['tyler.liu@ringcentral.com']
|
|
6
6
|
gem.description = 'Ruby SDK for you to access RingCentral platform API.'
|
|
@@ -13,9 +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.
|
|
17
|
-
gem.add_dependency('concurrent-ruby', '~> 1.
|
|
18
|
-
gem.add_dependency('pubnub', '~> 5.
|
|
19
|
-
gem.add_dependency('faraday', '~> 2.
|
|
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')
|
|
20
20
|
gem.add_dependency('faraday-multipart', '~> 1.0', '>= 1.0.4')
|
|
21
21
|
end
|
data/spec/fax_spec.rb
CHANGED
|
@@ -6,7 +6,7 @@ RSpec.describe 'Fax' do
|
|
|
6
6
|
it 'should send a fax' do
|
|
7
7
|
Dotenv.load
|
|
8
8
|
rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
|
|
9
|
-
rc.authorize(
|
|
9
|
+
rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
10
10
|
r = rc.post('/restapi/v1.0/account/~/extension/~/fax',
|
|
11
11
|
payload: { to: [{ phoneNumber: ENV['RINGCENTRAL_RECEIVER'] }] },
|
|
12
12
|
files: [
|
|
@@ -17,6 +17,8 @@ RSpec.describe 'Fax' do
|
|
|
17
17
|
expect(r).not_to be_nil
|
|
18
18
|
message = r.body
|
|
19
19
|
expect('Fax').to eq(message['type'])
|
|
20
|
+
|
|
21
|
+
rc.revoke()
|
|
20
22
|
end
|
|
21
23
|
end
|
|
22
24
|
end
|
data/spec/mms_spec.rb
CHANGED
|
@@ -6,12 +6,12 @@ RSpec.describe 'MMS' do
|
|
|
6
6
|
it 'should send an MMS' do
|
|
7
7
|
Dotenv.load
|
|
8
8
|
rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
|
|
9
|
-
rc.authorize(
|
|
9
|
+
rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
10
10
|
|
|
11
11
|
r = rc.post('/restapi/v1.0/account/~/extension/~/sms',
|
|
12
12
|
payload: {
|
|
13
13
|
to: [{ phoneNumber: ENV['RINGCENTRAL_RECEIVER'] }],
|
|
14
|
-
from: { phoneNumber: ENV['
|
|
14
|
+
from: { phoneNumber: ENV['RINGCENTRAL_SENDER'] },
|
|
15
15
|
text: 'hello world'
|
|
16
16
|
},
|
|
17
17
|
files: [
|
|
@@ -21,6 +21,8 @@ RSpec.describe 'MMS' do
|
|
|
21
21
|
expect(r).not_to be_nil
|
|
22
22
|
message = r.body
|
|
23
23
|
expect('SMS').to eq(message['type'])
|
|
24
|
+
|
|
25
|
+
rc.revoke()
|
|
24
26
|
end
|
|
25
27
|
end
|
|
26
28
|
end
|
data/spec/query_params_spec.rb
CHANGED
|
@@ -6,7 +6,7 @@ RSpec.describe 'query params' do
|
|
|
6
6
|
it 'contain single query param' do
|
|
7
7
|
Dotenv.load
|
|
8
8
|
rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
|
|
9
|
-
rc.authorize(
|
|
9
|
+
rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
10
10
|
r = rc.get('/restapi/v1.0/account/~/extension/~/address-book/contact', { phoneNumber: '666' })
|
|
11
11
|
expect(r).not_to be_nil
|
|
12
12
|
message = r.body
|
|
@@ -16,6 +16,7 @@ RSpec.describe 'query params' do
|
|
|
16
16
|
expect(r).not_to be_nil
|
|
17
17
|
message = r.body
|
|
18
18
|
expect(message['uri']).to include('phoneNumber=666&phoneNumber=888')
|
|
19
|
+
|
|
19
20
|
rc.revoke()
|
|
20
21
|
end
|
|
21
22
|
end
|
data/spec/ringcentral_spec.rb
CHANGED
|
@@ -17,16 +17,16 @@ RSpec.describe 'RingCentral' do
|
|
|
17
17
|
|
|
18
18
|
it 'test_authorize_uri' do
|
|
19
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', 'mystate'))
|
|
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'}))
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
it '
|
|
23
|
+
it 'test_jwt_flow' do
|
|
24
24
|
Dotenv.load
|
|
25
25
|
rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
|
|
26
26
|
expect(rc.token).to be_nil
|
|
27
27
|
|
|
28
28
|
# create token
|
|
29
|
-
rc.authorize(
|
|
29
|
+
rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
30
30
|
expect(rc.token).not_to be_nil
|
|
31
31
|
|
|
32
32
|
# refresh token
|
|
@@ -41,7 +41,7 @@ RSpec.describe 'RingCentral' do
|
|
|
41
41
|
it 'test_http_methods' do
|
|
42
42
|
Dotenv.load
|
|
43
43
|
rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
|
|
44
|
-
rc.authorize(
|
|
44
|
+
rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
45
45
|
|
|
46
46
|
# get
|
|
47
47
|
r = rc.get('/restapi/v1.0/account/~/extension/~')
|
|
@@ -51,7 +51,7 @@ RSpec.describe 'RingCentral' do
|
|
|
51
51
|
# post
|
|
52
52
|
r = rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
|
|
53
53
|
to: [{phoneNumber: ENV['RINGCENTRAL_RECEIVER']}],
|
|
54
|
-
from: {phoneNumber: ENV['
|
|
54
|
+
from: {phoneNumber: ENV['RINGCENTRAL_SENDER']},
|
|
55
55
|
text: 'Hello world'
|
|
56
56
|
})
|
|
57
57
|
expect(r).not_to be_nil
|
|
@@ -78,6 +78,8 @@ RSpec.describe 'RingCentral' do
|
|
|
78
78
|
expect(r).not_to be_nil
|
|
79
79
|
message = r.body
|
|
80
80
|
expect('Deleted').to eq(message['availability'])
|
|
81
|
+
|
|
82
|
+
rc.revoke()
|
|
81
83
|
end
|
|
82
84
|
end
|
|
83
85
|
end
|
data/spec/subscription_spec.rb
CHANGED
|
@@ -5,7 +5,7 @@ require 'rspec'
|
|
|
5
5
|
|
|
6
6
|
Dotenv.load
|
|
7
7
|
$rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
|
|
10
10
|
def createSubscription(callback)
|
|
11
11
|
events = [
|
|
@@ -21,6 +21,7 @@ end
|
|
|
21
21
|
RSpec.describe 'Subscription' do
|
|
22
22
|
describe 'subscription' do
|
|
23
23
|
it 'receives message notification' do
|
|
24
|
+
$rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
24
25
|
count = 0
|
|
25
26
|
createSubscription(lambda { |message|
|
|
26
27
|
count += 1
|
|
@@ -28,15 +29,17 @@ RSpec.describe 'Subscription' do
|
|
|
28
29
|
|
|
29
30
|
$rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
|
|
30
31
|
to: [{phoneNumber: ENV['RINGCENTRAL_RECEIVER']}],
|
|
31
|
-
from: {phoneNumber: ENV['
|
|
32
|
+
from: {phoneNumber: ENV['RINGCENTRAL_SENDER']},
|
|
32
33
|
text: 'Hello world'
|
|
33
34
|
})
|
|
34
35
|
sleep(20)
|
|
35
36
|
|
|
36
37
|
expect(count).to be > 0
|
|
38
|
+
$rc.revoke()
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
it 'refresh' do
|
|
42
|
+
$rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
40
43
|
count = 0
|
|
41
44
|
subscription = createSubscription(lambda { |message|
|
|
42
45
|
count += 1
|
|
@@ -46,15 +49,17 @@ RSpec.describe 'Subscription' do
|
|
|
46
49
|
|
|
47
50
|
$rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
|
|
48
51
|
to: [{phoneNumber: ENV['RINGCENTRAL_RECEIVER']}],
|
|
49
|
-
from: {phoneNumber: ENV['
|
|
52
|
+
from: {phoneNumber: ENV['RINGCENTRAL_SENDER']},
|
|
50
53
|
text: 'Hello world'
|
|
51
54
|
})
|
|
52
55
|
sleep(20)
|
|
53
56
|
|
|
54
57
|
expect(count).to be > 0
|
|
58
|
+
$rc.revoke()
|
|
55
59
|
end
|
|
56
60
|
|
|
57
61
|
it 'revoke' do
|
|
62
|
+
$rc.authorize(jwt: ENV['RINGCENTRAL_JWT_TOKEN'])
|
|
58
63
|
count = 0
|
|
59
64
|
subscription = createSubscription(lambda { |message|
|
|
60
65
|
count += 1
|
|
@@ -64,12 +69,13 @@ RSpec.describe 'Subscription' do
|
|
|
64
69
|
|
|
65
70
|
$rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
|
|
66
71
|
to: [{phoneNumber: ENV['RINGCENTRAL_RECEIVER']}],
|
|
67
|
-
from: {phoneNumber: ENV['
|
|
72
|
+
from: {phoneNumber: ENV['RINGCENTRAL_SENDER']},
|
|
68
73
|
text: 'Hello world'
|
|
69
74
|
})
|
|
70
75
|
sleep(20)
|
|
71
76
|
|
|
72
77
|
expect(count).to eq(0)
|
|
78
|
+
$rc.revoke()
|
|
73
79
|
end
|
|
74
80
|
end
|
|
75
81
|
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: 0.9.
|
|
4
|
+
version: 0.9.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tyler Liu
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-05-05 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.
|
|
22
|
+
version: 2.8.4
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,67 +29,67 @@ dependencies:
|
|
|
29
29
|
version: '2.8'
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 2.8.
|
|
32
|
+
version: 2.8.4
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: concurrent-ruby
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '1.
|
|
39
|
+
version: '1.2'
|
|
40
40
|
- - ">="
|
|
41
41
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: 1.
|
|
42
|
+
version: 1.2.2
|
|
43
43
|
type: :runtime
|
|
44
44
|
prerelease: false
|
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
|
46
46
|
requirements:
|
|
47
47
|
- - "~>"
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
|
-
version: '1.
|
|
49
|
+
version: '1.2'
|
|
50
50
|
- - ">="
|
|
51
51
|
- !ruby/object:Gem::Version
|
|
52
|
-
version: 1.
|
|
52
|
+
version: 1.2.2
|
|
53
53
|
- !ruby/object:Gem::Dependency
|
|
54
54
|
name: pubnub
|
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
|
56
56
|
requirements:
|
|
57
57
|
- - "~>"
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: '5.
|
|
59
|
+
version: '5.2'
|
|
60
60
|
- - ">="
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: 5.
|
|
62
|
+
version: 5.2.2
|
|
63
63
|
type: :runtime
|
|
64
64
|
prerelease: false
|
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
66
|
requirements:
|
|
67
67
|
- - "~>"
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: '5.
|
|
69
|
+
version: '5.2'
|
|
70
70
|
- - ">="
|
|
71
71
|
- !ruby/object:Gem::Version
|
|
72
|
-
version: 5.
|
|
72
|
+
version: 5.2.2
|
|
73
73
|
- !ruby/object:Gem::Dependency
|
|
74
74
|
name: faraday
|
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
|
76
76
|
requirements:
|
|
77
77
|
- - "~>"
|
|
78
78
|
- !ruby/object:Gem::Version
|
|
79
|
-
version: '2.
|
|
79
|
+
version: '2.7'
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 2.
|
|
82
|
+
version: 2.7.4
|
|
83
83
|
type: :runtime
|
|
84
84
|
prerelease: false
|
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '2.
|
|
89
|
+
version: '2.7'
|
|
90
90
|
- - ">="
|
|
91
91
|
- !ruby/object:Gem::Version
|
|
92
|
-
version: 2.
|
|
92
|
+
version: 2.7.4
|
|
93
93
|
- !ruby/object:Gem::Dependency
|
|
94
94
|
name: faraday-multipart
|
|
95
95
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
145
145
|
- !ruby/object:Gem::Version
|
|
146
146
|
version: '0'
|
|
147
147
|
requirements: []
|
|
148
|
-
rubygems_version: 3.
|
|
148
|
+
rubygems_version: 3.4.10
|
|
149
149
|
signing_key:
|
|
150
150
|
specification_version: 4
|
|
151
151
|
summary: RingCentral Ruby SDK.
|