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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ecc70101c8a49551105f83e593be979fe25a2ab7
4
- data.tar.gz: 22981b9c0d649af8da86ef9de9d6f507fb82ceac
2
+ SHA256:
3
+ metadata.gz: 0def40f14858640a19c34e45ff4ff317dfaf49ad9982973caa3d11c837352b94
4
+ data.tar.gz: 838af02960f7b0f797d9d4c84df5f386d8c68f635e69d2256fe2e45147e4d48b
5
5
  SHA512:
6
- metadata.gz: 052b9067500e5b0d781b3b026ba4670496b27e7fdc3ec8ca532f92869350978104cc7535089d79c6588afac7e844ad03543087ee37b695382046ebcdb77f6610
7
- data.tar.gz: de0b01dff34151dba3ce24c4edc79cf6cf6103707d77b1a767808c79f5380dc1f433763a20df574f04689add934cce619ac80e8e7124e8eff72fe01ec7ebe25b
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
- [![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)
5
- [![Community](https://img.shields.io/badge/dynamic/json.svg?label=community&colorB=&suffix=%20users&query=$.approximate_people_count&uri=http%3A%2F%2Fapi.getsatisfaction.com%2Fcompanies%2F102909.json)](https://devcommunity.ringcentral.com/ringcentraldev)
3
+ [![Ruby](https://github.com/ringcentral/ringcentral-ruby/actions/workflows/ruby.yml/badge.svg)](https://github.com/ringcentral/ringcentral-ruby/actions/workflows/ruby.yml)
6
4
  [![Twitter](https://img.shields.io/twitter/follow/ringcentraldevs.svg?style=social&label=follow)](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, everyone is recommended to move to the REST 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
- Solution is `gem uninstall ringcentral`
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 'faraday_middleware'
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, :content_type => /\bjson$/
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'ringcentral-sdk'
3
- gem.version = '0.9.2'
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.6', '>= 2.6.0')
17
- gem.add_dependency('concurrent-ruby', '~> 1.1', '>= 1.1.5')
18
- gem.add_dependency('pubnub', '~> 4.1', '>= 4.1.2')
19
- gem.add_dependency('faraday', '~> 0.15', '>= 0.15.4')
20
- gem.add_dependency('faraday_middleware', '~> 0.13', '>= 0.13.1')
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.2
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: 2019-06-25 00:00:00.000000000 Z
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.6'
19
+ version: '2.8'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 2.6.0
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.6'
29
+ version: '2.8'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 2.6.0
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.5
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.5
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: '4.1'
59
+ version: '5.0'
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 4.1.2
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.1'
69
+ version: '5.0'
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: 4.1.2
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.15'
79
+ version: '2.3'
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 0.15.4
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: '0.15'
89
+ version: '2.3'
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: 0.15.4
92
+ version: 2.3.0
93
93
  - !ruby/object:Gem::Dependency
94
- name: faraday_middleware
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.13'
99
+ version: '1.0'
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: 0.13.1
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.13'
109
+ version: '1.0'
110
110
  - - ">="
111
111
  - !ruby/object:Gem::Version
112
- version: 0.13.1
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
- rubyforge_project:
149
- rubygems_version: 2.5.2.3
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
data/spec/spec_helper.rb DELETED
@@ -1,7 +0,0 @@
1
- RSpec.configure do |config|
2
- require 'simplecov'
3
- SimpleCov.start
4
-
5
- require 'coveralls'
6
- Coveralls.wear!
7
- end