ringcentral-sdk 0.8.2 → 0.9.6

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
- SHA1:
3
- metadata.gz: d48fd9aeb0ce08172f73e2922121f31713cbd626
4
- data.tar.gz: 5ae74b326aed1c61ba8a98745174a3a7d19eb2dc
2
+ SHA256:
3
+ metadata.gz: 1540372aa98b7028d885a28cc968a3348cf39c19611e2d86dbbcd67e115152bd
4
+ data.tar.gz: d6e4c9cbacec4d74422b2c692ac0f99e4213191e7ec47e43d5205776b1c60808
5
5
  SHA512:
6
- metadata.gz: d2cfe606abaa3f47c4b1b745f15eb1ce7bc2f00258ccf31aca1ab16210aba4de87488df119646eee6b6183bf19bf18ade336fd626e5125606eed2c716b4e260d
7
- data.tar.gz: e669a6ba874cf06b7190300fdeb6b23102d820801370644470619c8d1d73e1b6591370465e56eb3d54e958d4d887682952aee99bedc697ce25925cb9770cdef5
6
+ metadata.gz: accae1e8fa5df89849746124c4f5f51587b7c9d67c4bf8498d5c726bbc541719a2b2117aa278535271cba3ddc0602b76827140a6a2bc25fec3a4fae1613eecef
7
+ data.tar.gz: ba5d969dabb7b891f2b22597097388e2c7a08dff9262dcd209be7bdbaa9da49c35ce18b48502fb982889c4a7a138128e79c9e2c6ecdcebbcccb41c9cc5ca8676
data/README.md CHANGED
@@ -1,9 +1,17 @@
1
- # ringcentral-ruby
1
+ # RingCentral SDK for Ruby
2
2
 
3
- [![Build Status](https://travis-ci.org/ringcentral/ringcentral-ruby.svg?branch=master)](https://travis-ci.org/ringcentral/ringcentral-ruby)
4
- [![Coverage Status](https://coveralls.io/repos/github/ringcentral/ringcentral-ruby/badge.svg?branch=master)](https://coveralls.io/github/ringcentral/ringcentral-ruby?branch=master)
3
+ [![Ruby](https://github.com/ringcentral/ringcentral-ruby/actions/workflows/ruby.yml/badge.svg)](https://github.com/ringcentral/ringcentral-ruby/actions/workflows/ruby.yml)
4
+ [![Twitter](https://img.shields.io/twitter/follow/ringcentraldevs.svg?style=social&label=follow)](https://twitter.com/RingCentralDevs)
5
5
 
6
- Ruby SDK for RingCentral.
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)__.
8
+
9
+ [API Reference](https://developer.ringcentral.com/api-docs/latest/index.html) and [APIs Explorer](https://developer.ringcentral.com/api-explorer/latest/index.html).
10
+
11
+
12
+ ## Getting help and support
13
+
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.
7
15
 
8
16
 
9
17
  ## Installation
@@ -13,6 +21,15 @@ gem install ringcentral-sdk
13
21
  ```
14
22
 
15
23
 
24
+ ### Name collision with `ringcentral` gem
25
+
26
+ 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.
27
+
28
+ 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.
29
+
30
+ The solution is `gem uninstall ringcentral`
31
+
32
+
16
33
  ## Documentation
17
34
 
18
35
  https://developer.ringcentral.com/api-docs/latest/index.html
@@ -23,28 +40,66 @@ https://developer.ringcentral.com/api-docs/latest/index.html
23
40
  ```ruby
24
41
  require 'ringcentral'
25
42
 
26
- rc = RingCentral.new(ENV['clientId'], ENV['clientSecret'], ENV['server'])
27
- rc.authorize(username: ENV['username'], extension: ENV['extension'], password: ENV['password'])
43
+ rc = RingCentral.new('clientID', 'clientSecret', 'serverURL')
44
+ rc.authorize(username: 'username', extension: 'extension', password: 'password')
28
45
 
29
46
  # get
30
47
  r = rc.get('/restapi/v1.0/account/~/extension/~')
31
48
  expect(r).not_to be_nil
32
- expect('101').to eq(JSON.parse(r.body)['extensionNumber'])
49
+ expect('101').to eq(r.body['extensionNumber'])
50
+ ```
51
+
52
+
53
+ ## How to specify query parameters
54
+
55
+ ### for get & delete
56
+
57
+ ```ruby
58
+ rc.get('/restapi/v1.0/account/~/extension', { hello: 'world' })
59
+ ```
60
+
61
+ ### for post, put & patch
62
+
63
+ ```ruby
64
+ rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: body, params: { hello: 'world' })
33
65
  ```
34
66
 
67
+ ### multi-value query parameter
68
+
69
+ ```ruby
70
+ rc.get('/restapi/v1.0/account/~/extension', { hello: ['world1', 'world2'] })
71
+ ```
72
+
73
+ Above will be translated to `/restapi/v1.0/account/~/extension?hello=world1&hello=world2`.
74
+
35
75
 
36
76
  ### Token Refresh
37
77
 
38
- Access token expires. You need to call `rc.refresh()` before it expores.
78
+ Access token expires. You need to call `rc.refresh()` before it expires.
39
79
  If you want the SDK to do auto refresh please `rc.auto_refresh = true` before authorization.
40
80
 
41
81
 
82
+ ### Load preexisting token
83
+
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.
87
+
88
+ 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
+
90
+ If you only have a string for the access token instead of for the whole object, you can set it like this:
91
+
92
+ ```ruby
93
+ rc.token = { access_token: 'the token string' }
94
+ ```
95
+
96
+
42
97
  ### Send SMS
43
98
 
44
99
  ```ruby
45
100
  r = rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
46
- to: [{phoneNumber: ENV['receiver']}],
47
- from: {phoneNumber: ENV['username']},
101
+ to: [{phoneNumber: ENV['RINGCENTRAL_RECEIVER']}],
102
+ from: {phoneNumber: ENV['RINGCENTRAL_USERNAME']},
48
103
  text: 'Hello world'
49
104
  })
50
105
  ```
@@ -54,7 +109,7 @@ r = rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
54
109
 
55
110
  ```ruby
56
111
  rc.post('/restapi/v1.0/account/~/extension/~/fax',
57
- payload: { to: [{ phoneNumber: ENV['receiver'] }] },
112
+ payload: { to: [{ phoneNumber: ENV['RINGCENTRAL_RECEIVER'] }] },
58
113
  files: [
59
114
  ['spec/test.txt', 'text/plain'],
60
115
  ['spec/test.png', 'image/png']
@@ -68,8 +123,8 @@ payload: { to: [{ phoneNumber: ENV['receiver'] }] },
68
123
  ```ruby
69
124
  r = rc.post('/restapi/v1.0/account/~/extension/~/sms',
70
125
  payload: {
71
- to: [{ phoneNumber: ENV['receiver'] }],
72
- from: { phoneNumber: ENV['username'] },
126
+ to: [{ phoneNumber: ENV['RINGCENTRAL_RECEIVER'] }],
127
+ from: { phoneNumber: ENV['RINGCENTRAL_USERNAME'] },
73
128
  text: 'hello world'
74
129
  },
75
130
  files: [
@@ -104,20 +159,25 @@ For more sample code, please refer to the [test cases](/spec).
104
159
 
105
160
  ## How to test
106
161
 
162
+ ```
163
+ bundle install --path vendor/bundle
164
+ ```
165
+
107
166
  Create `.env` file with the following content:
108
167
 
109
168
  ```
110
- production=false
111
- server=https://platform.devtest.ringcentral.com
112
- clientId=clientId
113
- clientSecret=clientSecret
114
- username=username
115
- extension=extension
116
- password=password
117
- receiver=number-to-receiver-sms
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=
118
176
  ```
119
177
 
120
- Run `rspec`
178
+ `RINGCENTRAL_RECEIVER` is a phone number to receive SMS, Fax..etc.
179
+
180
+ Run `bundle exec rspec`
121
181
 
122
182
 
123
183
  ## License
data/lib/ringcentral.rb CHANGED
@@ -3,6 +3,7 @@ require 'addressable/uri'
3
3
  require 'json'
4
4
  require 'concurrent'
5
5
  require 'faraday'
6
+ require 'faraday_middleware'
6
7
  require 'tmpdir'
7
8
 
8
9
  class RingCentral
@@ -14,19 +15,20 @@ class RingCentral
14
15
  'https://platform.ringcentral.com'
15
16
  end
16
17
 
17
- attr_reader :app_key, :app_secret, :server, :token
18
+ attr_reader :client_id, :client_secret, :server, :token
18
19
  attr_accessor :auto_refresh
19
20
 
20
- def initialize(app_key, app_secret, server)
21
- @app_key = app_key
22
- @app_secret = app_secret
21
+ def initialize(client_id, client_secret, server)
22
+ @client_id = client_id
23
+ @client_secret = client_secret
23
24
  @server = server
24
25
  @auto_refresh = false
25
26
  @token = nil
26
27
  @timer = nil
27
- @faraday = Faraday.new(url: server) do |faraday|
28
+ @faraday = Faraday.new(url: server, request: { params_encoder: Faraday::FlatParamsEncoder }) do |faraday|
28
29
  faraday.request :multipart
29
30
  faraday.request :url_encoded
31
+ faraday.response :json, content_type: /\bjson$/
30
32
  faraday.adapter Faraday.default_adapter
31
33
  end
32
34
  end
@@ -43,13 +45,21 @@ class RingCentral
43
45
  end
44
46
  end
45
47
 
46
- def authorize(username: nil, extension: nil, password: nil, auth_code: nil, redirect_uri: nil)
48
+ def authorize(username: nil, extension: nil, password: nil, auth_code: nil, redirect_uri: nil, jwt: nil, verifier: nil)
47
49
  if auth_code != nil
48
50
  payload = {
49
51
  grant_type: 'authorization_code',
50
52
  code: auth_code,
51
53
  redirect_uri: redirect_uri,
52
54
  }
55
+ if verifier != nil
56
+ payload["code_verifier"] = verifier
57
+ end
58
+ elsif jwt != nil
59
+ payload = {
60
+ grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
61
+ assertion: jwt
62
+ }
53
63
  else
54
64
  payload = {
55
65
  grant_type: 'password',
@@ -60,7 +70,7 @@ class RingCentral
60
70
  end
61
71
  self.token = nil
62
72
  r = self.post('/restapi/oauth/token', payload: payload)
63
- self.token = JSON.parse(r.body)
73
+ self.token = r.body
64
74
  end
65
75
 
66
76
  def refresh
@@ -71,7 +81,7 @@ class RingCentral
71
81
  }
72
82
  self.token = nil
73
83
  r = self.post('/restapi/oauth/token', payload: payload)
74
- self.token = JSON.parse(r.body)
84
+ self.token = r.body
75
85
  end
76
86
 
77
87
  def revoke
@@ -81,14 +91,18 @@ class RingCentral
81
91
  self.post('/restapi/oauth/revoke', payload: payload)
82
92
  end
83
93
 
84
- def authorize_uri(redirect_uri, state = '')
94
+ def authorize_uri(redirect_uri, state = '', challenge = nil, challenge_method = 'S256')
85
95
  uri = Addressable::URI.parse(@server) + '/restapi/oauth/authorize'
86
96
  uri.query_values = {
87
97
  response_type: 'code',
88
98
  state: state,
89
99
  redirect_uri: redirect_uri,
90
- client_id: @app_key
100
+ client_id: @client_id
91
101
  }
102
+ if challenge != nil
103
+ uri.query_values["code_challenge"] = challenge
104
+ uri.query_values["code_challenge_method"] = challenge_method
105
+ end
92
106
  uri.to_s
93
107
  end
94
108
 
@@ -150,7 +164,7 @@ class RingCentral
150
164
  private
151
165
 
152
166
  def basic_key
153
- Base64.encode64("#{@app_key}:#{@app_secret}").gsub(/\s/, '')
167
+ Base64.encode64("#{@client_id}:#{@client_secret}").gsub(/\s/, '')
154
168
  end
155
169
 
156
170
  def autorization_header
data/lib/subscription.rb CHANGED
@@ -2,6 +2,7 @@ require 'pubnub'
2
2
  require 'concurrent'
3
3
  require 'openssl'
4
4
  require 'base64'
5
+ require 'securerandom'
5
6
 
6
7
  class PubNub
7
8
  attr_accessor :events
@@ -47,8 +48,8 @@ class PubNub
47
48
 
48
49
  def subscribe
49
50
  r = @rc.post('/restapi/v1.0/subscription', payload: request_body)
50
- self.subscription = JSON.parse(r.body)
51
- @pubnub = Pubnub.new(subscribe_key: @subscription['deliveryMode']['subscriberKey'])
51
+ self.subscription = r.body
52
+ @pubnub = Pubnub.new(subscribe_key: @subscription['deliveryMode']['subscriberKey'], uuid: SecureRandom.uuid)
52
53
  @pubnub.add_listener(name: 'default', callback: @callback)
53
54
  @pubnub.subscribe(channels: @subscription['deliveryMode']['address'])
54
55
  end
@@ -56,7 +57,7 @@ class PubNub
56
57
  def refresh
57
58
  return if @subscription == nil
58
59
  r = @rc.put("/restapi/v1.0/subscription/#{@subscription['id']}", payload: request_body)
59
- self.subscription = JSON.parse(r.body)
60
+ self.subscription = r.body
60
61
  end
61
62
 
62
63
  def revoke
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'ringcentral-sdk'
3
- gem.version = '0.8.2'
3
+ gem.version = '0.9.6'
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,8 +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.5', '>= 2.5.2')
17
- gem.add_dependency('concurrent-ruby', '~> 1.0', '>= 1.0.2')
18
- gem.add_dependency('pubnub', '~> 4.0', '>= 4.0.27')
19
- gem.add_dependency('faraday', '~> 0.10', '>= 0.10.0')
16
+ gem.add_dependency('addressable', '~> 2.8', '>= 2.8.0')
17
+ gem.add_dependency('concurrent-ruby', '~> 1.1', '>= 1.1.9')
18
+ gem.add_dependency('pubnub', '~> 5.0', '>= 5.0.0')
19
+ gem.add_dependency('faraday', '~> 2.1', '>= 2.1.0')
20
+ gem.add_dependency('faraday_middleware', '~> 1.2.0', '>= 1.2.0')
20
21
  end
data/spec/fax_spec.rb CHANGED
@@ -5,17 +5,17 @@ RSpec.describe 'Fax' do
5
5
  describe 'send fax' do
6
6
  it 'should send a fax' do
7
7
  Dotenv.load
8
- rc = RingCentral.new(ENV['clientId'], ENV['clientSecret'], ENV['server'])
9
- rc.authorize(username: ENV['username'], extension: ENV['extension'], password: ENV['password'])
8
+ rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
9
+ rc.authorize(username: ENV['RINGCENTRAL_USERNAME'], extension: ENV['RINGCENTRAL_EXTENSION'], password: ENV['RINGCENTRAL_PASSWORD'])
10
10
  r = rc.post('/restapi/v1.0/account/~/extension/~/fax',
11
- payload: { to: [{ phoneNumber: ENV['receiver'] }] },
11
+ payload: { to: [{ phoneNumber: ENV['RINGCENTRAL_RECEIVER'] }] },
12
12
  files: [
13
13
  ['spec/test.txt', 'text/plain'],
14
14
  ['spec/test.png', 'image/png']
15
15
  ]
16
16
  )
17
17
  expect(r).not_to be_nil
18
- message = JSON.parse(r.body)
18
+ message = r.body
19
19
  expect('Fax').to eq(message['type'])
20
20
  end
21
21
  end
data/spec/mms_spec.rb CHANGED
@@ -5,13 +5,13 @@ RSpec.describe 'MMS' do
5
5
  describe 'send MMS' do
6
6
  it 'should send an MMS' do
7
7
  Dotenv.load
8
- rc = RingCentral.new(ENV['clientId'], ENV['clientSecret'], ENV['server'])
9
- rc.authorize(username: ENV['username'], extension: ENV['extension'], password: ENV['password'])
8
+ rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
9
+ rc.authorize(username: ENV['RINGCENTRAL_USERNAME'], extension: ENV['RINGCENTRAL_EXTENSION'], password: ENV['RINGCENTRAL_PASSWORD'])
10
10
 
11
11
  r = rc.post('/restapi/v1.0/account/~/extension/~/sms',
12
12
  payload: {
13
- to: [{ phoneNumber: ENV['receiver'] }],
14
- from: { phoneNumber: ENV['username'] },
13
+ to: [{ phoneNumber: ENV['RINGCENTRAL_RECEIVER'] }],
14
+ from: { phoneNumber: ENV['RINGCENTRAL_USERNAME'] },
15
15
  text: 'hello world'
16
16
  },
17
17
  files: [
@@ -19,7 +19,7 @@ RSpec.describe 'MMS' do
19
19
  ]
20
20
  )
21
21
  expect(r).not_to be_nil
22
- message = JSON.parse(r.body)
22
+ message = r.body
23
23
  expect('SMS').to eq(message['type'])
24
24
  end
25
25
  end
@@ -0,0 +1,22 @@
1
+ require 'dotenv'
2
+ require 'ringcentral'
3
+
4
+ RSpec.describe 'query params' do
5
+ describe 'single' do
6
+ it 'contain single query param' do
7
+ Dotenv.load
8
+ rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
9
+ rc.authorize(username: ENV['RINGCENTRAL_USERNAME'], extension: ENV['RINGCENTRAL_EXTENSION'], password: ENV['RINGCENTRAL_PASSWORD'])
10
+ r = rc.get('/restapi/v1.0/account/~/extension/~/address-book/contact', { phoneNumber: '666' })
11
+ expect(r).not_to be_nil
12
+ message = r.body
13
+ expect(message['uri']).to include('phoneNumber=666')
14
+
15
+ r = rc.get('/restapi/v1.0/account/~/extension/~/address-book/contact', { phoneNumber: ['666', '888'] })
16
+ expect(r).not_to be_nil
17
+ message = r.body
18
+ expect(message['uri']).to include('phoneNumber=666&phoneNumber=888')
19
+ rc.revoke()
20
+ end
21
+ end
22
+ end
@@ -8,25 +8,25 @@ RSpec.describe 'RingCentral' do
8
8
  end
9
9
 
10
10
  it 'test_initializer' do
11
- rc = RingCentral.new('app_key', 'app_secret', RingCentral.SANDBOX_SERVER)
12
- expect('app_key').to eq(rc.app_key)
13
- expect('app_secret').to eq(rc.app_secret)
11
+ rc = RingCentral.new('client_id', 'client_secret', RingCentral.SANDBOX_SERVER)
12
+ expect('client_id').to eq(rc.client_id)
13
+ expect('client_secret').to eq(rc.client_secret)
14
14
  expect('https://platform.devtest.ringcentral.com').to eq(rc.server)
15
15
  expect(false).to eq(rc.auto_refresh)
16
16
  end
17
17
 
18
18
  it 'test_authorize_uri' do
19
- rc = RingCentral.new('app_key', 'app_secret', RingCentral.SANDBOX_SERVER)
20
- expect(RingCentral.SANDBOX_SERVER + '/restapi/oauth/authorize?client_id=app_key&redirect_uri=https%3A%2F%2Fexample.com&response_type=code&state=mystate').to eq(rc.authorize_uri('https://example.com', 'mystate'))
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'))
21
21
  end
22
22
 
23
23
  it 'test_password_flow' do
24
24
  Dotenv.load
25
- rc = RingCentral.new(ENV['clientId'], ENV['clientSecret'], ENV['server'])
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(username: ENV['username'], extension: ENV['extension'], password: ENV['password'])
29
+ rc.authorize(username: ENV['RINGCENTRAL_USERNAME'], extension: ENV['RINGCENTRAL_EXTENSION'], password: ENV['RINGCENTRAL_PASSWORD'])
30
30
  expect(rc.token).not_to be_nil
31
31
 
32
32
  # refresh token
@@ -40,33 +40,33 @@ RSpec.describe 'RingCentral' do
40
40
 
41
41
  it 'test_http_methods' do
42
42
  Dotenv.load
43
- rc = RingCentral.new(ENV['clientId'], ENV['clientSecret'], ENV['server'])
44
- rc.authorize(username: ENV['username'], extension: ENV['extension'], password: ENV['password'])
43
+ rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
44
+ rc.authorize(username: ENV['RINGCENTRAL_USERNAME'], extension: ENV['RINGCENTRAL_EXTENSION'], password: ENV['RINGCENTRAL_PASSWORD'])
45
45
 
46
46
  # get
47
47
  r = rc.get('/restapi/v1.0/account/~/extension/~')
48
48
  expect(r).not_to be_nil
49
- expect('101').to eq(JSON.parse(r.body)['extensionNumber'])
49
+ expect('101').to eq(r.body['extensionNumber'])
50
50
 
51
51
  # post
52
52
  r = rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
53
- to: [{phoneNumber: ENV['receiver']}],
54
- from: {phoneNumber: ENV['username']},
53
+ to: [{phoneNumber: ENV['RINGCENTRAL_RECEIVER']}],
54
+ from: {phoneNumber: ENV['RINGCENTRAL_USERNAME']},
55
55
  text: 'Hello world'
56
56
  })
57
57
  expect(r).not_to be_nil
58
- message = JSON.parse(r.body)
58
+ message = r.body
59
59
  expect('SMS').to eq(message['type'])
60
60
  messageUrl = "/restapi/v1.0/account/~/extension/~/message-store/#{message['id']}"
61
61
 
62
62
  # put
63
63
  r = rc.put(messageUrl, payload: { readStatus: 'Unread' })
64
64
  expect(r).not_to be_nil
65
- message = JSON.parse(r.body)
65
+ message = r.body
66
66
  expect('Unread').to eq(message['readStatus'])
67
67
  r = rc.put(messageUrl, payload: { readStatus: 'Read' })
68
68
  expect(r).not_to be_nil
69
- message = JSON.parse(r.body)
69
+ message = r.body
70
70
  expect('Read').to eq(message['readStatus'])
71
71
 
72
72
  # todo: test patch
@@ -76,7 +76,7 @@ RSpec.describe 'RingCentral' do
76
76
  expect(r).not_to be_nil
77
77
  r = rc.get(messageUrl)
78
78
  expect(r).not_to be_nil
79
- message = JSON.parse(r.body)
79
+ message = r.body
80
80
  expect('Deleted').to eq(message['availability'])
81
81
  end
82
82
  end
@@ -4,8 +4,8 @@ require 'dotenv'
4
4
  require 'rspec'
5
5
 
6
6
  Dotenv.load
7
- $rc = RingCentral.new(ENV['clientId'], ENV['clientSecret'], ENV['server'])
8
- $rc.authorize(username: ENV['username'], extension: ENV['extension'], password: ENV['password'])
7
+ $rc = RingCentral.new(ENV['RINGCENTRAL_CLIENT_ID'], ENV['RINGCENTRAL_CLIENT_SECRET'], ENV['RINGCENTRAL_SERVER_URL'])
8
+ $rc.authorize(username: ENV['RINGCENTRAL_USERNAME'], extension: ENV['RINGCENTRAL_EXTENSION'], password: ENV['RINGCENTRAL_PASSWORD'])
9
9
 
10
10
  def createSubscription(callback)
11
11
  events = [
@@ -27,8 +27,8 @@ RSpec.describe 'Subscription' do
27
27
  })
28
28
 
29
29
  $rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
30
- to: [{phoneNumber: ENV['receiver']}],
31
- from: {phoneNumber: ENV['username']},
30
+ to: [{phoneNumber: ENV['RINGCENTRAL_RECEIVER']}],
31
+ from: {phoneNumber: ENV['RINGCENTRAL_USERNAME']},
32
32
  text: 'Hello world'
33
33
  })
34
34
  sleep(20)
@@ -45,8 +45,8 @@ RSpec.describe 'Subscription' do
45
45
  subscription.refresh()
46
46
 
47
47
  $rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
48
- to: [{phoneNumber: ENV['receiver']}],
49
- from: {phoneNumber: ENV['username']},
48
+ to: [{phoneNumber: ENV['RINGCENTRAL_RECEIVER']}],
49
+ from: {phoneNumber: ENV['RINGCENTRAL_USERNAME']},
50
50
  text: 'Hello world'
51
51
  })
52
52
  sleep(20)
@@ -63,8 +63,8 @@ RSpec.describe 'Subscription' do
63
63
  subscription.revoke()
64
64
 
65
65
  $rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
66
- to: [{phoneNumber: ENV['receiver']}],
67
- from: {phoneNumber: ENV['username']},
66
+ to: [{phoneNumber: ENV['RINGCENTRAL_RECEIVER']}],
67
+ from: {phoneNumber: ENV['RINGCENTRAL_USERNAME']},
68
68
  text: 'Hello world'
69
69
  })
70
70
  sleep(20)
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.8.2
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Liu
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-16 00:00:00.000000000 Z
11
+ date: 2022-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -16,80 +16,100 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.5'
19
+ version: '2.8'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 2.5.2
22
+ version: 2.8.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '2.5'
29
+ version: '2.8'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 2.5.2
32
+ version: 2.8.0
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.0'
39
+ version: '1.1'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 1.0.2
42
+ version: 1.1.9
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.0'
49
+ version: '1.1'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 1.0.2
52
+ version: 1.1.9
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: '4.0'
59
+ version: '5.0'
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 4.0.27
62
+ version: 5.0.0
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: '4.0'
69
+ version: '5.0'
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: 4.0.27
72
+ version: 5.0.0
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: '0.10'
79
+ version: '2.1'
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 0.10.0
82
+ version: 2.1.0
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: '0.10'
89
+ version: '2.1'
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: 0.10.0
92
+ version: 2.1.0
93
+ - !ruby/object:Gem::Dependency
94
+ name: faraday_middleware
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: 1.2.0
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 1.2.0
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 1.2.0
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 1.2.0
93
113
  description: Ruby SDK for you to access RingCentral platform API.
94
114
  email:
95
115
  - tyler.liu@ringcentral.com
@@ -103,6 +123,7 @@ files:
103
123
  - ringcentral-sdk.gemspec
104
124
  - spec/fax_spec.rb
105
125
  - spec/mms_spec.rb
126
+ - spec/query_params_spec.rb
106
127
  - spec/ringcentral_spec.rb
107
128
  - spec/spec_helper.rb
108
129
  - spec/subscription_spec.rb
@@ -110,7 +131,7 @@ homepage: https://github.com/ringcentral/ringcentral-ruby
110
131
  licenses:
111
132
  - MIT
112
133
  metadata: {}
113
- post_install_message:
134
+ post_install_message:
114
135
  rdoc_options: []
115
136
  require_paths:
116
137
  - lib
@@ -125,14 +146,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
146
  - !ruby/object:Gem::Version
126
147
  version: '0'
127
148
  requirements: []
128
- rubyforge_project:
129
- rubygems_version: 2.5.1
130
- signing_key:
149
+ rubygems_version: 3.2.3
150
+ signing_key:
131
151
  specification_version: 4
132
152
  summary: RingCentral Ruby SDK.
133
153
  test_files:
134
- - spec/spec_helper.rb
135
- - spec/ringcentral_spec.rb
136
- - spec/mms_spec.rb
137
154
  - spec/fax_spec.rb
155
+ - spec/mms_spec.rb
156
+ - spec/query_params_spec.rb
157
+ - spec/ringcentral_spec.rb
158
+ - spec/spec_helper.rb
138
159
  - spec/subscription_spec.rb