ringcentral_sdk 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ce21745b447bf882a9636dcfd3a4bcf8f62c011
4
- data.tar.gz: 8d3bbb5a2321d7b562b69b0ff03b2379c0432140
3
+ metadata.gz: 862737f88ab2fb10fb96c6f606b611bf74492107
4
+ data.tar.gz: 6d2fdc609db3b0f27b33e783989933bca33c25bc
5
5
  SHA512:
6
- metadata.gz: 1c5329a5af10c38274942c3cf502e15ebf77f609e0408a14abf95d74693892a9efe90594f05e2765d42f7be92775b94f65af30348350bcf9e35cb0ee44cdca5f
7
- data.tar.gz: 358783efa3adf397bc5edf845d04ad9cb3e464de876cebf8b2276a2f2c1204fc13280833f86a0e89e8ec7131db9b71a97a80ab98ee787b4356c8db98ce8eb5a5
6
+ metadata.gz: 8f458a48827b77691e2a35cb34e4bb587c4a756afe2849032d731be462d60816fe240265669e07ed24fe3d7e8da1f0b546051b954baf6abc60093e803a7f1e6e
7
+ data.tar.gz: 54d1f7f38b78b233dac0b41f39a5284970adbd0a6385f9b8ab30403ec917b31d41d327c5b6eaafee99875712e75e7fd4bae807a2933d02063fde890fd89ce8db
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ringcentral_sdk (2.0.0)
4
+ ringcentral_sdk (2.0.1)
5
5
  dotenv (~> 2.1, >= 2.1.0)
6
6
  faraday (~> 0, >= 0)
7
7
  faraday_middleware (~> 0, >= 0)
@@ -81,7 +81,7 @@ GEM
81
81
  faraday (~> 0.9, >= 0.9)
82
82
  faraday_middleware (~> 0, >= 0)
83
83
  faraday_middleware-request-retry (0.1.0)
84
- faraday (~> 0.9, >= 0.9)
84
+ faraday (~> 0, >= 0)
85
85
  faraday_middleware (~> 0, >= 0)
86
86
  hitimes (1.2.4)
87
87
  httpclient (2.8.3)
@@ -1,15 +1,9 @@
1
1
  # RingCentralSdk is a SDK for the RingCentral REST API
2
2
  module RingCentralSdk
3
- VERSION = '2.0.0'.freeze
3
+ VERSION = '2.0.1'.freeze
4
4
 
5
5
  RC_SERVER_PRODUCTION = 'https://platform.ringcentral.com'.freeze
6
6
  RC_SERVER_SANDBOX = 'https://platform.devtest.ringcentral.com'.freeze
7
7
 
8
8
  autoload :REST, 'ringcentral_sdk/rest'
9
-
10
- class << self
11
- def new(app_key, app_secret, server_url = RC_SERVER_SANDBOX, opts = {})
12
- RingCentralSdk::REST::Client.new(app_key, app_secret, server_url, opts)
13
- end
14
- end
15
9
  end
@@ -38,7 +38,6 @@ module RingCentralSdk
38
38
  yield config
39
39
  @config.inflate
40
40
 
41
- @logger = @config.logger
42
41
  @oauth2client = new_oauth2_client
43
42
 
44
43
  unless @config.username.to_s.empty?
@@ -18,7 +18,7 @@ module RingCentralSdk
18
18
  attr_reader :event_filters
19
19
 
20
20
  def initialize(client)
21
- @_client = client
21
+ @client = client
22
22
  @event_filters = []
23
23
  @_timeout = nil
24
24
  @_subscription = nil_subscription
@@ -69,11 +69,11 @@ module RingCentralSdk
69
69
  raise 'Events are undefined' unless @event_filters.is_a?(Array) && !@event_filters.empty?
70
70
 
71
71
  begin
72
- response = @_client.http.post do |req|
72
+ response = @client.http.post do |req|
73
73
  req.url 'subscription'
74
74
  req.headers['Content-Type'] = 'application/json'
75
75
  req.body = {
76
- eventFilters: @_client.create_urls(@event_filters),
76
+ eventFilters: @client.create_urls(@event_filters),
77
77
  deliveryMode: { transportType: 'PubNub' }
78
78
  }
79
79
  end
@@ -98,7 +98,7 @@ module RingCentralSdk
98
98
  _clear_timeout
99
99
 
100
100
  begin
101
- response = @_client.http.post do |req|
101
+ response = @client.http.post do |req|
102
102
  req.url uri_join(@_subscription['uri'], 'renew')
103
103
  req.headers['Content-Type'] = 'application/json'
104
104
  end
@@ -109,7 +109,7 @@ module RingCentralSdk
109
109
 
110
110
  return response
111
111
  rescue StandardError => e
112
- @client.logger.warn "RingCentralSdk::REST::Subscription: RENEW_ERROR #{e}"
112
+ @client.config.logger.warn "RingCentralSdk::REST::Subscription: RENEW_ERROR #{e}"
113
113
  reset
114
114
  changed
115
115
  notify_observers e
@@ -121,7 +121,7 @@ module RingCentralSdk
121
121
  raise 'Subscription is not alive' unless alive?
122
122
 
123
123
  begin
124
- response = @_client.http.delete do |req|
124
+ response = @client.http.delete do |req|
125
125
  req.url 'subscription/' + @_subscription['id'].to_s
126
126
  end
127
127
  reset
@@ -179,19 +179,19 @@ module RingCentralSdk
179
179
 
180
180
  callback = Pubnub::SubscribeCallback.new(
181
181
  message: ->(envelope) {
182
- @_client.logger.debug "MESSAGE: #{envelope.result[:data]}"
182
+ @client.config.logger.debug "MESSAGE: #{envelope.result[:data]}"
183
183
  _notify envelope.result[:data][:message]
184
184
  changed
185
185
  },
186
186
  presence: ->(envelope) {
187
- @_client.logger.info "PRESENCE: #{envelope.result[:data]}"
187
+ @client.config.logger.info "PRESENCE: #{envelope.result[:data]}"
188
188
  },
189
189
  status: lambda do |envelope|
190
- @_client.logger.info "\n\n\n#{envelope.status}\n\n\n"
190
+ @client.config.logger.info "\n\n\n#{envelope.status}\n\n\n"
191
191
  if envelope.error?
192
- @_client.logger.info "ERROR! #{envelope.status[:category]}"
192
+ @client.config.logger.info "ERROR! #{envelope.status[:category]}"
193
193
  elsif envelope.status[:last_timetoken] == 0 # Connected!
194
- @_client.logger.info('CONNECTED!')
194
+ @client.config.logger.info('CONNECTED!')
195
195
  end
196
196
  end
197
197
  )
@@ -201,12 +201,12 @@ module RingCentralSdk
201
201
  @_pubnub.subscribe(
202
202
  channels: @_subscription['deliveryMode']['address']
203
203
  )
204
- @_client.logger.debug('SUBSCRIBED')
204
+ @client.config.logger.debug('SUBSCRIBED')
205
205
  end
206
206
 
207
207
  def _notify(message)
208
208
  count = count_observers
209
- @_client.logger.debug("RingCentralSdk::REST::Subscription NOTIFYING '#{count}' observers")
209
+ @client.config.logger.debug("RingCentralSdk::REST::Subscription NOTIFYING '#{count}' observers")
210
210
 
211
211
  message = _decrypt message
212
212
  changed
@@ -10,3 +10,57 @@ RingCentralSdk::REST::Client.new do |config|
10
10
  config.app_secret = 'my_app_secret'
11
11
  config.server_url = RingCentralSdk::RC_SERVER_SANDBOX
12
12
  end
13
+
14
+ module RingCentralSdk
15
+ module Test
16
+ class ClientUtil
17
+ def new_client_with_auth
18
+ client = new_client
19
+ client.set_oauth2_client
20
+
21
+ stub_token_hash = data_auth_token_with_refresh
22
+ stub_token = OAuth2::AccessToken.from_hash(client.oauth2client, stub_token_hash)
23
+
24
+ client.oauth2client.password.stubs(:get_token).returns(stub_token)
25
+
26
+ client.authorize('my_test_username', 'my_test_extension', 'my_test_password')
27
+ end
28
+
29
+ def client_stub_auth(client)
30
+ client.set_oauth2_client
31
+
32
+ stub_token_hash = data_auth_token_with_refresh
33
+ stub_token = OAuth2::AccessToken.from_hash(client.oauth2client, stub_token_hash)
34
+
35
+ client.oauth2client.password.stubs(:get_token).returns(stub_token)
36
+
37
+ client.authorize('my_test_username', 'my_test_extension', 'my_test_password')
38
+ client
39
+ end
40
+
41
+ def data_auth_token_with_refresh
42
+ json = '{
43
+ "access_token": "my_test_access_token_with_refresh",
44
+ "token_type": "bearer",
45
+ "expires_in": 3599,
46
+ "refresh_token": "my_test_refresh_token",
47
+ "refresh_token_expires_in": 604799,
48
+ "scope": "ReadCallLog DirectRingOut EditCallLog ReadAccounts Contacts EditExtensions ReadContacts SMS EditPresence RingOut EditCustomData ReadPresence EditPaymentInfo Interoperability Accounts NumberLookup InternalMessages ReadCallRecording EditAccounts Faxes EditReportingSettings ReadClientInfo EditMessages VoipCalling ReadMessages",
49
+ "owner_id": "1234567890"
50
+ }'
51
+ JSON.parse(json, symbolize_names: true)
52
+ end
53
+
54
+ def data_auth_token_without_refresh
55
+ json = '{
56
+ "access_token": "my_test_access_token_without_refresh",
57
+ "token_type": "bearer",
58
+ "expires_in": 3599,
59
+ "scope": "ReadCallLog DirectRingOut EditCallLog ReadAccounts Contacts EditExtensions ReadContacts SMS EditPresence RingOut EditCustomData ReadPresence EditPaymentInfo Interoperability Accounts NumberLookup InternalMessages ReadCallRecording EditAccounts Faxes EditReportingSettings ReadClientInfo EditMessages VoipCalling ReadMessages",
60
+ "owner_id": "1234567890"
61
+ }'
62
+ JSON.parse(json, symbolize_names: true)
63
+ end
64
+ end
65
+ end
66
+ end
@@ -9,7 +9,7 @@ class RingCentralSdkRESTEventTest < Test::Unit::TestCase
9
9
 
10
10
  assert_equal '11112222-3333-4444-5555-666677778888', event.doc.getAttr('uuid')
11
11
  assert_equal 1, event.new_sms_count
12
- assert_equal -1, event.new_fax_count
12
+ assert_equal (-1), event.new_fax_count
13
13
  end
14
14
 
15
15
  def test_new_fax_count
@@ -18,7 +18,7 @@ class RingCentralSdkRESTEventTest < Test::Unit::TestCase
18
18
  event = RingCentralSdk::REST::Event.new data
19
19
 
20
20
  assert_equal '11112222-3333-4444-5555-666677778888', event.doc.getAttr('uuid')
21
- assert_equal -1, event.new_sms_count
21
+ assert_equal (-1), event.new_sms_count
22
22
  assert_equal 1, event.new_fax_count
23
23
  end
24
24
 
@@ -12,17 +12,6 @@ class RingCentralSdkRESTExtensionPresenceTest < Test::Unit::TestCase
12
12
  def test_department_calls_enable
13
13
  presence = RingCentralSdk::REST::ExtensionPresence.new(111_111)
14
14
 
15
- new_statuses = {
16
- enable: {
17
- 'DoNotAcceptAnyCalls' => 'TakeDepartmentCallsOnly',
18
- 'DoNotAcceptDepartmentCalls' => 'TakeAllCalls'
19
- },
20
- disable: {
21
- 'TakeAllCalls' => 'DoNotAcceptDepartmentCalls',
22
- 'TakeDepartmentCallsOnly' => 'DoNotAcceptAnyCalls'
23
- }
24
- }
25
-
26
15
  cur_status = 'TakeAllCalls'
27
16
  assert_equal \
28
17
  'DoNotAcceptDepartmentCalls', \
@@ -81,8 +81,7 @@ class RingCentralSdkSubscriptionTest < Test::Unit::TestCase
81
81
  stub_token = OAuth2::AccessToken.from_hash(rcsdk.oauth2client, stub_token_hash)
82
82
 
83
83
  rcsdk.oauth2client.password.stubs(:get_token).returns(stub_token)
84
-
85
- token = rcsdk.authorize('my_test_username', 'my_test_extension', 'my_test_password')
84
+ rcsdk.authorize('my_test_username', 'my_test_extension', 'my_test_password')
86
85
  rcsdk
87
86
  end
88
87
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ringcentral_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wang