ringcentral-sdk 0.9.2 → 0.9.7
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 +5 -5
- data/README.md +40 -7
- data/lib/ringcentral.rb +17 -5
- data/lib/subscription.rb +2 -1
- data/ringcentral-sdk.gemspec +6 -6
- data/spec/query_params_spec.rb +22 -0
- metadata +29 -30
- data/spec/spec_helper.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0def40f14858640a19c34e45ff4ff317dfaf49ad9982973caa3d11c837352b94
|
4
|
+
data.tar.gz: 838af02960f7b0f797d9d4c84df5f386d8c68f635e69d2256fe2e45147e4d48b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 649477f3d68de34a1211b6ea467bcf220fa1e8d17931fa96eb9f752dd0314878a4d3ba5843a6039644441d1abcea4f2c8616ab646c7a0e713c639e657a8ca1e2
|
7
|
+
data.tar.gz: 5abfbfb09b56b5f8f0dc913e39a56d36bcc48d4cd3affdaeab64428049b2918ae4de79f1f6e0ebf4f01a53a012ff8c03247dbb29e67b82cb4bac70da19ae3742
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# RingCentral SDK for Ruby
|
2
2
|
|
3
|
-
[](https://coveralls.io/github/ringcentral/ringcentral-ruby?branch=master)
|
5
|
-
[](https://devcommunity.ringcentral.com/ringcentraldev)
|
3
|
+
[](https://github.com/ringcentral/ringcentral-ruby/actions/workflows/ruby.yml)
|
6
4
|
[](https://twitter.com/RingCentralDevs)
|
7
5
|
|
8
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:
|
@@ -10,6 +8,12 @@ __[Voice](https://developer.ringcentral.com/api-products/voice), [SMS/MMS](https
|
|
10
8
|
|
11
9
|
[API Reference](https://developer.ringcentral.com/api-docs/latest/index.html) and [APIs Explorer](https://developer.ringcentral.com/api-explorer/latest/index.html).
|
12
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.
|
15
|
+
|
16
|
+
|
13
17
|
## Installation
|
14
18
|
|
15
19
|
```
|
@@ -19,11 +23,11 @@ gem install ringcentral-sdk
|
|
19
23
|
|
20
24
|
### Name collision with `ringcentral` gem
|
21
25
|
|
22
|
-
The ringcentral gem is using RingCentral's legacy API
|
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.
|
23
27
|
|
24
|
-
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.
|
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.
|
25
29
|
|
26
|
-
|
30
|
+
The solution is `gem uninstall ringcentral`
|
27
31
|
|
28
32
|
|
29
33
|
## Documentation
|
@@ -46,6 +50,29 @@ expect('101').to eq(r.body['extensionNumber'])
|
|
46
50
|
```
|
47
51
|
|
48
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' })
|
65
|
+
```
|
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
|
+
|
75
|
+
|
49
76
|
### Token Refresh
|
50
77
|
|
51
78
|
Access token expires. You need to call `rc.refresh()` before it expires.
|
@@ -58,7 +85,13 @@ Let's say you already have a token. Then you can load it like this: `rc.token =
|
|
58
85
|
|
59
86
|
The benifits of loading a preexisting token is you don't need to go through any authorization flow.
|
60
87
|
|
61
|
-
If what you have is a string instead of a Ruby object, you need to convert it first: `JSON.parse(your_token_string)`.
|
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
|
+
```
|
62
95
|
|
63
96
|
|
64
97
|
### Send SMS
|
data/lib/ringcentral.rb
CHANGED
@@ -3,7 +3,7 @@ require 'addressable/uri'
|
|
3
3
|
require 'json'
|
4
4
|
require 'concurrent'
|
5
5
|
require 'faraday'
|
6
|
-
require '
|
6
|
+
require 'faraday/multipart'
|
7
7
|
require 'tmpdir'
|
8
8
|
|
9
9
|
class RingCentral
|
@@ -25,10 +25,10 @@ class RingCentral
|
|
25
25
|
@auto_refresh = false
|
26
26
|
@token = nil
|
27
27
|
@timer = nil
|
28
|
-
@faraday = Faraday.new(url: server) do |faraday|
|
28
|
+
@faraday = Faraday.new(url: server, request: { params_encoder: Faraday::FlatParamsEncoder }) do |faraday|
|
29
29
|
faraday.request :multipart
|
30
30
|
faraday.request :url_encoded
|
31
|
-
faraday.response :json, :
|
31
|
+
faraday.response :json, content_type: /\bjson$/
|
32
32
|
faraday.adapter Faraday.default_adapter
|
33
33
|
end
|
34
34
|
end
|
@@ -45,13 +45,21 @@ class RingCentral
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
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)
|
49
49
|
if auth_code != nil
|
50
50
|
payload = {
|
51
51
|
grant_type: 'authorization_code',
|
52
52
|
code: auth_code,
|
53
53
|
redirect_uri: redirect_uri,
|
54
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
|
+
}
|
55
63
|
else
|
56
64
|
payload = {
|
57
65
|
grant_type: 'password',
|
@@ -83,7 +91,7 @@ class RingCentral
|
|
83
91
|
self.post('/restapi/oauth/revoke', payload: payload)
|
84
92
|
end
|
85
93
|
|
86
|
-
def authorize_uri(redirect_uri, state = '')
|
94
|
+
def authorize_uri(redirect_uri, state = '', challenge = nil, challenge_method = 'S256')
|
87
95
|
uri = Addressable::URI.parse(@server) + '/restapi/oauth/authorize'
|
88
96
|
uri.query_values = {
|
89
97
|
response_type: 'code',
|
@@ -91,6 +99,10 @@ class RingCentral
|
|
91
99
|
redirect_uri: redirect_uri,
|
92
100
|
client_id: @client_id
|
93
101
|
}
|
102
|
+
if challenge != nil
|
103
|
+
uri.query_values["code_challenge"] = challenge
|
104
|
+
uri.query_values["code_challenge_method"] = challenge_method
|
105
|
+
end
|
94
106
|
uri.to_s
|
95
107
|
end
|
96
108
|
|
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
|
@@ -48,7 +49,7 @@ class PubNub
|
|
48
49
|
def subscribe
|
49
50
|
r = @rc.post('/restapi/v1.0/subscription', payload: request_body)
|
50
51
|
self.subscription = r.body
|
51
|
-
@pubnub = Pubnub.new(subscribe_key: @subscription['deliveryMode']['subscriberKey'])
|
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
|
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.7'
|
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.
|
17
|
-
gem.add_dependency('concurrent-ruby', '~> 1.1', '>= 1.1.
|
18
|
-
gem.add_dependency('pubnub', '~>
|
19
|
-
gem.add_dependency('faraday', '~>
|
20
|
-
gem.add_dependency('
|
16
|
+
gem.add_dependency('addressable', '~> 2.8', '>= 2.8.0')
|
17
|
+
gem.add_dependency('concurrent-ruby', '~> 1.1', '>= 1.1.10')
|
18
|
+
gem.add_dependency('pubnub', '~> 5.0', '>= 5.0.0')
|
19
|
+
gem.add_dependency('faraday', '~> 2.3', '>= 2.3.0')
|
20
|
+
gem.add_dependency('faraday-multipart', '~> 1.0', '>= 1.0.4')
|
21
21
|
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
|
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.7
|
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:
|
11
|
+
date: 2022-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.8'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 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.
|
29
|
+
version: '2.8'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 2.
|
32
|
+
version: 2.8.0
|
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.1'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 1.1.
|
42
|
+
version: 1.1.10
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,67 +49,67 @@ dependencies:
|
|
49
49
|
version: '1.1'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 1.1.
|
52
|
+
version: 1.1.10
|
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: '
|
59
|
+
version: '5.0'
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
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: '
|
69
|
+
version: '5.0'
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
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: '
|
79
|
+
version: '2.3'
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 2.3.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: '
|
89
|
+
version: '2.3'
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
92
|
+
version: 2.3.0
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
|
-
name:
|
94
|
+
name: faraday-multipart
|
95
95
|
requirement: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
97
|
- - "~>"
|
98
98
|
- !ruby/object:Gem::Version
|
99
|
-
version: '0
|
99
|
+
version: '1.0'
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 0.
|
102
|
+
version: 1.0.4
|
103
103
|
type: :runtime
|
104
104
|
prerelease: false
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '0
|
109
|
+
version: '1.0'
|
110
110
|
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: 0.
|
112
|
+
version: 1.0.4
|
113
113
|
description: Ruby SDK for you to access RingCentral platform API.
|
114
114
|
email:
|
115
115
|
- tyler.liu@ringcentral.com
|
@@ -123,14 +123,14 @@ files:
|
|
123
123
|
- ringcentral-sdk.gemspec
|
124
124
|
- spec/fax_spec.rb
|
125
125
|
- spec/mms_spec.rb
|
126
|
+
- spec/query_params_spec.rb
|
126
127
|
- spec/ringcentral_spec.rb
|
127
|
-
- spec/spec_helper.rb
|
128
128
|
- spec/subscription_spec.rb
|
129
129
|
homepage: https://github.com/ringcentral/ringcentral-ruby
|
130
130
|
licenses:
|
131
131
|
- MIT
|
132
132
|
metadata: {}
|
133
|
-
post_install_message:
|
133
|
+
post_install_message:
|
134
134
|
rdoc_options: []
|
135
135
|
require_paths:
|
136
136
|
- lib
|
@@ -145,14 +145,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
|
-
|
149
|
-
|
150
|
-
signing_key:
|
148
|
+
rubygems_version: 3.2.3
|
149
|
+
signing_key:
|
151
150
|
specification_version: 4
|
152
151
|
summary: RingCentral Ruby SDK.
|
153
152
|
test_files:
|
154
|
-
- spec/spec_helper.rb
|
155
|
-
- spec/ringcentral_spec.rb
|
156
|
-
- spec/mms_spec.rb
|
157
153
|
- spec/fax_spec.rb
|
154
|
+
- spec/mms_spec.rb
|
155
|
+
- spec/query_params_spec.rb
|
156
|
+
- spec/ringcentral_spec.rb
|
158
157
|
- spec/subscription_spec.rb
|