ringcentral_sdk 1.1.1 → 1.2.0

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
2
  SHA1:
3
- metadata.gz: 2154bcc7c5ab9744b0e8022fce9182ef79b367f4
4
- data.tar.gz: e905f7a5bf71557b364010abbab3d9ec3c9988b7
3
+ metadata.gz: ab1568adfa0b75e2499ca45a6ecfb8aab7fb8a9b
4
+ data.tar.gz: 12f9564a379c2360a97446a236768e111f7043d8
5
5
  SHA512:
6
- metadata.gz: ebf2f8089617611f8bd71ed3e1abf0d36a17f608c0e1e49b47299b641d1a60db1d6e2d869a87c74694c8e09257247c507196f31c1c653b41e21644bdf99f28f1
7
- data.tar.gz: f62ada05b0b567e60688090e3be51f41e1ce819b05c16f1bdacfa3f830c5ae7282dd55d6bad06128f34b20d019a2cf3fbb934f4dab0e9dd4201dadebd4ae3fdd
6
+ metadata.gz: 4a3589d87ec26898d95400919ca9a32bee0ef82458566ea8e4fcacb5933d61ed65405afba5672c19f84b5c6c16210792917de809be51b527656550b51134c587
7
+ data.tar.gz: 0dd57841c119378949b680aff89c28a70bf370eabbba26b4444ab16e3ea63a3e8ed2d35985540d4f6d038ef0fe1351e9402ecac437802897a0c30e1b7d5e9e47
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  CHANGELOG
2
2
  ---------
3
+ - **2016-04-23**: 1.2.0
4
+ - Additions
5
+ - Add `RingCentral::REST::Client` custom instance headers support
6
+ - Add `RingCentral::REST::Client` `attr_reader` for `app_config`
7
+ - Add docs for Answering Rules
8
+ - Updates
9
+ - Update Pubnub dependency to 3.8.0 from 3.7.3
10
+ - Removals
11
+ - Deprecate Ruby 1.9.3 due to `mime-types-data` (3.2016.0221) requiring Ruby >= 2.0
3
12
  - **2016-02-13**: 1.1.1
4
13
  - Additions
5
14
  - Add `client.send_request` hash support in addition to `Request::Base` object
data/Gemfile CHANGED
@@ -13,7 +13,7 @@ gem 'mime_builder'
13
13
  gem 'mocha'
14
14
  gem 'multi_json'
15
15
  gem 'oauth2'
16
- gem 'pubnub', '~> 3.7.3'
16
+ gem 'pubnub', '~> 3.8.0'
17
17
  gem 'rake'
18
18
  gem 'simplecov'
19
19
  gem 'test-unit'
data/Gemfile.lock CHANGED
@@ -1,18 +1,31 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- coveralls (0.8.10)
4
+ celluloid (0.17.3)
5
+ celluloid-essentials
6
+ celluloid-extras
7
+ celluloid-fsm
8
+ celluloid-pool
9
+ celluloid-supervision
10
+ timers (>= 4.1.1)
11
+ celluloid-essentials (0.20.5)
12
+ timers (>= 4.1.1)
13
+ celluloid-extras (0.20.5)
14
+ timers (>= 4.1.1)
15
+ celluloid-fsm (0.20.5)
16
+ timers (>= 4.1.1)
17
+ celluloid-pool (0.20.5)
18
+ timers (>= 4.1.1)
19
+ celluloid-supervision (0.20.5)
20
+ timers (>= 4.1.1)
21
+ coveralls (0.8.13)
5
22
  json (~> 1.8)
6
- rest-client (>= 1.6.8, < 2)
7
23
  simplecov (~> 0.11.0)
8
24
  term-ansicolor (~> 1.3)
9
25
  thor (~> 0.19.1)
10
26
  tins (~> 1.6.0)
11
27
  docile (1.1.5)
12
- domain_name (0.5.25)
13
- unf (>= 0.0.5, < 1.0.0)
14
28
  dotenv (2.1.0)
15
- eventmachine (1.0.9.1)
16
29
  faraday (0.9.2)
17
30
  multipart-post (>= 1.2, < 3)
18
31
  faraday_middleware (0.10.0)
@@ -21,15 +34,16 @@ GEM
21
34
  faraday (~> 0.9, >= 0.9)
22
35
  faraday_middleware (~> 0, >= 0)
23
36
  hitimes (1.2.3)
24
- http-cookie (1.0.2)
25
- domain_name (~> 0.5)
37
+ httpclient (2.7.1)
26
38
  json (1.8.3)
27
- jsondoc (0.1.0)
28
- jwt (1.5.2)
39
+ jsondoc (0.1.2)
40
+ jwt (1.5.1)
29
41
  logger (1.2.8)
30
42
  metaclass (0.0.4)
31
43
  mime (0.4.3)
32
- mime-types (2.99)
44
+ mime-types (3.0)
45
+ mime-types-data (~> 3.2015)
46
+ mime-types-data (3.2016.0221)
33
47
  mime_builder (0.0.2)
34
48
  mime
35
49
  mime-types (>= 1.25)
@@ -38,41 +52,32 @@ GEM
38
52
  multi_json (1.11.2)
39
53
  multi_xml (0.5.5)
40
54
  multipart-post (2.0.0)
41
- net-http-persistent (2.9.4)
42
- netrc (0.11.0)
43
- oauth2 (1.0.0)
55
+ oauth2 (1.1.0)
44
56
  faraday (>= 0.8, < 0.10)
45
- jwt (~> 1.0)
57
+ jwt (~> 1.0, < 1.5.2)
46
58
  multi_json (~> 1.3)
47
59
  multi_xml (~> 0.5)
48
- rack (~> 1.2)
60
+ rack (>= 1.2, < 3)
49
61
  power_assert (0.2.7)
50
- pubnub (3.7.10)
51
- eventmachine (~> 1.0)
62
+ pubnub (3.8.0)
63
+ celluloid (~> 0.16)
64
+ httpclient (~> 2.6)
52
65
  json (~> 1.8)
53
- net-http-persistent (~> 2.9)
54
66
  rack (1.6.4)
55
- rake (10.5.0)
56
- rest-client (1.8.0)
57
- http-cookie (>= 1.0.2, < 2.0)
58
- mime-types (>= 1.16, < 3.0)
59
- netrc (~> 0.7)
60
- simplecov (0.11.1)
67
+ rake (11.1.1)
68
+ simplecov (0.11.2)
61
69
  docile (~> 1.1.0)
62
70
  json (~> 1.8)
63
71
  simplecov-html (~> 0.10.0)
64
72
  simplecov-html (0.10.0)
65
73
  term-ansicolor (1.3.2)
66
74
  tins (~> 1.0)
67
- test-unit (3.1.7)
75
+ test-unit (3.1.8)
68
76
  power_assert
69
77
  thor (0.19.1)
70
78
  timers (4.1.1)
71
79
  hitimes
72
80
  tins (1.6.0)
73
- unf (0.1.4)
74
- unf_ext
75
- unf_ext (0.0.7.1)
76
81
 
77
82
  PLATFORMS
78
83
  ruby
@@ -91,7 +96,7 @@ DEPENDENCIES
91
96
  mocha
92
97
  multi_json
93
98
  oauth2
94
- pubnub (~> 3.7.3)
99
+ pubnub (~> 3.8.0)
95
100
  rake
96
101
  simplecov
97
102
  test-unit
data/README.md CHANGED
@@ -38,6 +38,11 @@ RingCentral SDK for Ruby
38
38
 
39
39
  ## Overview
40
40
 
41
+ ##### :warning: YOU MUST HAVE A RINGCENTRAL ACCOUNT TO USE THE API :warning:
42
+ ##### Get an account at: https://developers.ringcentral.com/login.html
43
+
44
+ www.ringcentral.com - RingCentral Complete Cloud Communications System.
45
+
41
46
  A library for using the [RingCentral REST API](https://developers.ringcentral.com). [Click here to read the full documentation](http://ringcentral-sdk-ruby.readthedocs.org/).
42
47
 
43
48
  ## Documentation
@@ -1,5 +1,5 @@
1
1
  module RingCentralSdk
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
 
4
4
  RC_SERVER_PRODUCTION = 'https://platform.ringcentral.com'
5
5
  RC_SERVER_SANDBOX = 'https://platform.devtest.ringcentral.com'
@@ -13,5 +13,6 @@ module RingCentralSdk::REST
13
13
  autoload :MessagesSMS, 'ringcentral_sdk/rest/messages'
14
14
  autoload :MessagesRetriever, 'ringcentral_sdk/rest/messages_retriever'
15
15
  autoload :Request, 'ringcentral_sdk/rest/request'
16
+ autoload :SimpleClient, 'ringcentral_sdk/rest/simple_client'
16
17
  autoload :Subscription, 'ringcentral_sdk/rest/subscription'
17
18
  end
@@ -6,7 +6,6 @@ require 'oauth2'
6
6
 
7
7
  module RingCentralSdk::REST
8
8
  class Client
9
-
10
9
  ACCESS_TOKEN_TTL = 600 # 10 minutes
11
10
  REFRESH_TOKEN_TTL = 36000 # 10 hours
12
11
  REFRESH_TOKEN_TTL_REMEMBER = 604800 # 1 week
@@ -17,6 +16,7 @@ module RingCentralSdk::REST
17
16
  REVOKE_ENDPOINT = '/restapi/oauth/revoke'
18
17
  API_VERSION = 'v1.0'
19
18
  URL_PREFIX = '/restapi'
19
+ DEFAULT_LANGUAGE = 'en-us'
20
20
 
21
21
  attr_reader :app_config
22
22
  attr_reader :http
@@ -25,21 +25,25 @@ module RingCentralSdk::REST
25
25
  attr_reader :user_agent
26
26
  attr_reader :messages
27
27
 
28
+ attr_reader :instance_headers
29
+
28
30
  def initialize(app_key='', app_secret='', server_url=RingCentralSdk::RC_SERVER_SANDBOX, opts={})
29
31
  init_attributes()
30
- app_config = RingCentralSdk::REST::ConfigApp.new(app_key, app_secret, server_url, opts)
31
- app_config(app_config)
32
+ self.app_config = RingCentralSdk::REST::ConfigApp.new(
33
+ app_key, app_secret, server_url, opts)
32
34
 
33
35
  if opts.key?(:username) && opts.key?(:password)
34
36
  extension = opts.key?(:extension) ? opts[:extension] : ''
35
37
  authorize_password(opts[:username], extension, opts[:password])
36
38
  end
37
39
 
38
- @messages = RingCentralSdk::REST::Messages.new(self)
40
+ @instance_headers = opts[:headers] || {}
41
+
42
+ @messages = RingCentralSdk::REST::Messages.new self
39
43
  end
40
44
 
41
- def app_config(app_config)
42
- @app_config = app_config
45
+ def app_config=(new_app_config)
46
+ @app_config = new_app_config
43
47
  @oauth2client = new_oauth2_client()
44
48
  end
45
49
 
@@ -93,53 +97,60 @@ module RingCentralSdk::REST
93
97
  return built_urls
94
98
  end
95
99
 
96
- def authorize_url(opts={})
100
+ def authorize_url(opts = {})
97
101
  @oauth2client.auth_code.authorize_url(_add_redirect_uri(opts))
98
102
  end
99
103
 
100
- def authorize_code(code, opts={})
104
+ def authorize_code(code, opts = {})
101
105
  token = @oauth2client.auth_code.get_token(code, _add_redirect_uri(opts))
102
106
  set_token(token)
103
107
  return token
104
108
  end
105
109
 
106
- def _add_redirect_uri(opts={})
110
+ def _add_redirect_uri(opts = {})
107
111
  if !opts.key?(:redirect_uri) && @app_config.redirect_url.to_s.length > 0
108
112
  opts[:redirect_uri] = @app_config.redirect_url.to_s
109
113
  end
110
114
  return opts
111
115
  end
112
116
 
113
- def authorize_password(username, extension='', password='', remember=false)
117
+ def authorize_password(username, extension = '', password = '', remember = false)
114
118
  token = @oauth2client.password.get_token(username, password, {
115
119
  extension: extension,
116
- headers: { 'Authorization' => 'Basic ' + get_api_key() } })
120
+ headers: {'Authorization' => 'Basic ' + get_api_key()}})
117
121
  set_token(token)
118
122
  return token
119
123
  end
120
124
 
121
- def authorize_user(user, remember=false)
125
+ def authorize_user(user, remember = false)
122
126
  authorize_password(user.username, user.extension, user.password)
123
127
  end
124
128
 
125
129
  def set_token(token)
126
- if token.is_a?(Hash)
130
+ if token.is_a? Hash
127
131
  token = OAuth2::AccessToken::from_hash(@oauth2client, token)
128
132
  end
129
133
 
130
- unless token.is_a?(OAuth2::AccessToken)
134
+ unless token.is_a? OAuth2::AccessToken
131
135
  raise "Token is not a OAuth2::AccessToken"
132
136
  end
133
137
 
134
138
  @token = token
135
139
 
136
- @http = Faraday.new(:url => api_version_url()) do |conn|
140
+ @http = Faraday.new(url: api_version_url()) do |conn|
137
141
  conn.request :oauth2_refresh, @token
138
142
  conn.request :json
139
143
  conn.request :url_encoded
140
144
  conn.headers['User-Agent'] = @user_agent
141
- conn.headers['Rc-User-Agent'] = @user_agent
142
- conn.response :json, :content_type => /\bjson$/
145
+ if @instance_headers.is_a? Hash
146
+ @instance_headers.each do |k,v|
147
+ conn.headers[k] = v
148
+ end
149
+ end
150
+ conn.headers['RC-User-Agent'] = @user_agent
151
+ conn.headers['SDK-User-Agent'] = @user_agent
152
+ conn.response :json, content_type: /\bjson$/
153
+ conn.response :logger
143
154
  conn.adapter Faraday.default_adapter
144
155
  end
145
156
  end
@@ -154,7 +165,7 @@ module RingCentralSdk::REST
154
165
  def set_oauth2_client(client=nil)
155
166
  if client.nil?
156
167
  @oauth2client = new_oauth2_client()
157
- elsif client.is_a?(OAuth2::Client)
168
+ elsif client.is_a? OAuth2::Client
158
169
  @oauth2client = client
159
170
  else
160
171
  fail "client is not an OAuth2::Client"
@@ -163,7 +174,7 @@ module RingCentralSdk::REST
163
174
 
164
175
  def get_api_key()
165
176
  api_key = (@app_config.key.is_a?(String) && @app_config.secret.is_a?(String)) \
166
- ? Base64.encode64("#{@app_config.key}:#{@app_config.secret}").gsub(/[\s\t\r\n]/,'') : ''
177
+ ? Base64.encode64("#{@app_config.key}:#{@app_config.secret}").gsub(/\s/,'') : ''
167
178
  return api_key
168
179
  end
169
180
 
@@ -174,8 +185,10 @@ module RingCentralSdk::REST
174
185
  fail 'Request is not a RingCentralSdk::REST::Request::Base'
175
186
  end
176
187
 
188
+ method = request_sdk.method.to_s.downcase
189
+ method = 'get' if method.empty?
190
+
177
191
  res = nil
178
- method = request_sdk.method.downcase
179
192
 
180
193
  case method
181
194
  when 'delete'
@@ -187,7 +200,7 @@ module RingCentralSdk::REST
187
200
  when 'put'
188
201
  res = @http.put { |req| req = inflate_request(req, request_sdk) }
189
202
  else
190
- fail "#{method} not supported"
203
+ fail "method [#{method}] not supported"
191
204
  end
192
205
  return res
193
206
  end
@@ -74,6 +74,15 @@ module RingCentralSdk::REST
74
74
  @server_url = ENV['RC_APP_SERVER_URL']
75
75
  @redirect_url = ENV['RC_APP_REDIRECT_URL']
76
76
  end
77
+
78
+ def to_hash
79
+ {
80
+ key: @key,
81
+ secret: @secret,
82
+ server_url: @server_url,
83
+ redirect_url: @redirect_url
84
+ }
85
+ end
77
86
  end
78
87
  end
79
88
 
@@ -23,7 +23,7 @@ module RingCentralSdk::REST
23
23
  end
24
24
 
25
25
  def nil_subscription()
26
- subscription = {
26
+ subscription = {
27
27
  'eventFilters' => [],
28
28
  'expirationTime' => '', # 2014-03-12T19:54:35.613Z
29
29
  'expiresIn' => 0,
@@ -90,9 +90,8 @@ module RingCentralSdk::REST
90
90
  reset()
91
91
  changed
92
92
  notify_observers(e)
93
- raise 'Subscribe HTTP Request Error'
93
+ raise 'Subscribe HTTP Request Error: ' + e.to_s
94
94
  end
95
-
96
95
  end
97
96
 
98
97
  def renew(events = nil)
@@ -134,9 +133,8 @@ module RingCentralSdk::REST
134
133
  end
135
134
 
136
135
  begin
137
- url = 'subscription/' + @_subscription['id'].to_s
138
136
  response = @_client.http.delete do |req|
139
- req.url = 'subscription' + @_subscription['id']
137
+ req.url 'subscription/' + @_subscription['id'].to_s
140
138
  end
141
139
  reset()
142
140
  changed
data/mkdocs.yml CHANGED
@@ -22,6 +22,9 @@ pages:
22
22
  - ['usage/voice/Click-To-Call.md', 'Voice', 'Click-To-Call']
23
23
  - ['usage/messages/Call-Recordings.md', 'Voice', 'Call Recordings']
24
24
 
25
+ ## Answering Rules:
26
+ - ['usage/answering-rules/Answering-Rules-Call-Forwarding.md', 'Answering Rules', 'Call Forwarding']
27
+
25
28
  ## Call Queues:
26
29
  - ['usage/callqueues/Member-Status.md', 'Call Queues', 'Member Status']
27
30
 
data/pubnub.log ADDED
@@ -0,0 +1,5 @@
1
+ # Logfile created on 2016-03-21 00:44:14 -0700 by logger.rb/1.2.8
2
+ I, [2016-03-21T00:44:14.724379 #4232] INFO -- Pubnub::Client: Created new Pubnub::Client instance. Version: 3.8.0
3
+ I, [2016-03-21T00:44:47.460102 #4234] INFO -- Pubnub::Client: Created new Pubnub::Client instance. Version: 3.8.0
4
+ I, [2016-03-21T00:45:55.441057 #4236] INFO -- Pubnub::Client: Created new Pubnub::Client instance. Version: 3.8.0
5
+ I, [2016-03-21T00:46:05.912837 #4238] INFO -- Pubnub::Client: Created new Pubnub::Client instance. Version: 3.8.0
@@ -7,7 +7,7 @@ version = $1
7
7
  Gem::Specification.new do |s|
8
8
  s.name = 'ringcentral_sdk'
9
9
  s.version = version
10
- s.date = '2016-02-13'
10
+ s.date = '2016-04-23'
11
11
  s.summary = 'RingCentral SDK - Ruby SDK for the RingCentral Connect Platform API'
12
12
  s.description = 'A Ruby SDK for the RingCentral Connect Platform API'
13
13
  s.authors = ['John Wang']
@@ -28,6 +28,6 @@ Gem::Specification.new do |s|
28
28
  s.add_dependency 'mime_builder', '~> 0'
29
29
  s.add_dependency 'multi_json', '~> 1.3'
30
30
  s.add_dependency 'oauth2', '~> 1.0', '>= 1.0.0'
31
- s.add_dependency 'pubnub', '~> 3.7', '>= 3.7.3'
31
+ s.add_dependency 'pubnub', '~> 3.8', '>= 3.8.0'
32
32
  s.add_dependency 'timers', '~> 4.1'
33
33
  end
data/test/test_client.rb CHANGED
@@ -16,6 +16,19 @@ class RingCentralSdkPlatformTest < Test::Unit::TestCase
16
16
  assert_equal "bXlfYXBwX2tleTpteV9hcHBfc2VjcmV0", @rcsdk.send(:get_api_key)
17
17
  end
18
18
 
19
+ def test_config
20
+ redirect_url = 'http://localhost:4567/oauth'
21
+ client = RingCentralSdk.new(
22
+ 'my_app_key',
23
+ 'my_app_secret',
24
+ RingCentralSdk::RC_SERVER_SANDBOX,
25
+ {
26
+ redirect_url: redirect_url
27
+ }
28
+ )
29
+ assert_equal redirect_url, client.app_config.redirect_url
30
+ end
31
+
19
32
  def test_set_client
20
33
  rcsdk = new_client()
21
34
  assert_equal true, rcsdk.oauth2client.is_a?(OAuth2::Client)
@@ -183,7 +196,7 @@ class RingCentralSdkPlatformTest < Test::Unit::TestCase
183
196
 
184
197
  client.oauth2client.password.stubs(:get_token).returns(stub_token)
185
198
 
186
- token = client.authorize('my_test_username', 'my_test_extension', 'my_test_password')
199
+ client.authorize('my_test_username', 'my_test_extension', 'my_test_password')
187
200
 
188
201
  #@rcsdk.client.stubs(:post).returns(Faraday::Response.new)
189
202
  Faraday::Connection.any_instance.stubs(:post).returns(Faraday::Response.new)
@@ -263,7 +276,7 @@ class RingCentralSdkPlatformTest < Test::Unit::TestCase
263
276
 
264
277
  client.oauth2client.password.stubs(:get_token).returns(stub_token)
265
278
 
266
- token = client.authorize('my_test_username', 'my_test_extension', 'my_test_password')
279
+ client.authorize('my_test_username', 'my_test_extension', 'my_test_password')
267
280
 
268
281
  res = client.messages.sms.create(
269
282
  from: '+16505551212',
data/test/test_setup.rb CHANGED
@@ -13,7 +13,7 @@ class RingCentralSdkTest < Test::Unit::TestCase
13
13
  assert_equal 'RingCentralSdk::REST::Client', @rcsdk.class.name
14
14
 
15
15
  assert_raise do
16
- @rcsdk.request(nil)
16
+ @rcsdk.send_request(nil)
17
17
  end
18
18
 
19
19
  rcsdk = RingCentralSdk.new(
@@ -195,7 +195,7 @@ class RingCentralSdkSubscriptionTest < Test::Unit::TestCase
195
195
 
196
196
  def test_pubnub
197
197
  sub = @rcsdk.create_subscription()
198
- pub = sub.new_pubnub()
198
+ pub = sub.new_pubnub('test', false, '')
199
199
 
200
200
  assert_equal 'Pubnub::Client', pub.class.name
201
201
  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: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-13 00:00:00.000000000 Z
11
+ date: 2016-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -192,20 +192,20 @@ dependencies:
192
192
  requirements:
193
193
  - - "~>"
194
194
  - !ruby/object:Gem::Version
195
- version: '3.7'
195
+ version: '3.8'
196
196
  - - ">="
197
197
  - !ruby/object:Gem::Version
198
- version: 3.7.3
198
+ version: 3.8.0
199
199
  type: :runtime
200
200
  prerelease: false
201
201
  version_requirements: !ruby/object:Gem::Requirement
202
202
  requirements:
203
203
  - - "~>"
204
204
  - !ruby/object:Gem::Version
205
- version: '3.7'
205
+ version: '3.8'
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
- version: 3.7.3
208
+ version: 3.8.0
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: timers
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -252,6 +252,7 @@ files:
252
252
  - lib/ringcentral_sdk/rest/simple_client.rb
253
253
  - lib/ringcentral_sdk/rest/subscription.rb
254
254
  - mkdocs.yml
255
+ - pubnub.log
255
256
  - ringcentral_sdk.gemspec
256
257
  - test/test_base.rb
257
258
  - test/test_client.rb