ringcentral_sdk 0.1.3 → 0.1.4

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: 95ea214f77faebf0d968b06c655e01eb6f2438df
4
- data.tar.gz: 4f15d3dbe834d599bacb0ae0115d3972148ed496
3
+ metadata.gz: 04c144d9ef786c8473335c8b873781710226b6e1
4
+ data.tar.gz: dc92d1eb5545de304856d4cf1d26a09ef4d56cc5
5
5
  SHA512:
6
- metadata.gz: 0f145704fcda7ad16687237c0e7e096c0de9c690543e1fdbc28b7b65cf0f86db5fa905857495f7bbd41f6c208f15c2dca6a983ff910f0dd0a6949b8b22457a88
7
- data.tar.gz: 5a993b31c4c1e943fc54564411463eaee2e90288cf53039824ccdb4e2098ee2b8349e2eef68f8a75bad5f7243a87448447db462129802b6d3161faee73229791
6
+ metadata.gz: ac6630b7c503c5331077af606f2dd79b2879b8312a7587fead18da645daad460861eaed3b08836789832625654dab041cba70413d23ac210923c883514bf2549
7
+ data.tar.gz: 8ebc499d0de3211863ff2ec46fa7a4d2b03351e761e7f004b4a5d407c876f3fc3ad7e032d8d66720b10ad7139edfc918ca85b63b73faf4b4d84320e88fb7a0c5
data/CHANGELOG.md CHANGED
@@ -1,25 +1,27 @@
1
1
  CHANGELOG
2
2
  ---------
3
+ - **2015-09-14**: 0.1.4
4
+ - Add OAuth2 token reuse support
3
5
  - **2015-08-29**: 0.1.3
4
- - Add `platform.client` getter
6
+ - Add `attr_reader` for `platform.client`
5
7
  - **2015-05-31**: 0.1.2
6
8
  - Add Ruby 1.8.7 support
7
9
  - Add CI for Ruby 2.2.0 & 2.1.6: 2.2.2, 2.2.0, 2.1.6, 2.1.0, 2.0.0, 1.9.3, 1.8.7
8
10
  - **2015-05-31**: 0.1.1
9
11
  - Add Ruby 2.2.2 support
10
12
  - **2015-05-31**: 0.1.0
11
- - Add OAuth token refresh
12
- - Add OAuth2::AccessToken support
13
+ - Add OAuth2 token refresh
14
+ - Add `OAuth2::AccessToken` support
13
15
  - Add Code Climate hook
14
16
  - **2015-05-19**: 0.0.4
15
- - Request helpers are now subclasses
16
- - sdk.request() and platform.request() methods added to handle request helpers
17
- - Fax helper uses file mime-type in preference to generic octet-stream
18
- - Initial mkdocs and Read the Docs effort added
19
- - Travis CI and Coveralls hooks added
17
+ - Add `RingCentralSdk::Helpers::Request` as request helpers base class
18
+ - Add `sdk.request()` and `platform.request()` methods to handle request helpers
19
+ - Update fax helper to use file mime-type in preference to generic octet-stream
20
+ - Add mkdocs and Read the Docs documentation
21
+ - Add Travis CI and Coveralls hooks
20
22
  - **2015-05-14**: 0.0.3
21
23
  - First public release
22
24
  - **2015-03-08**: 0.0.2
23
25
  - Convert methods from camelCase to under_scores
24
26
  - **2015-03-07**: 0.0.1
25
- - Initial release
27
+ - Initial release
data/README.md CHANGED
@@ -122,6 +122,8 @@ platform.authorize("myUsername", nil, "myPassword")
122
122
  platform.authorize("myUsername", "myExtension", "myPassword")
123
123
  ```
124
124
 
125
+ See [the authorization docs](http://ringcentral-sdk-ruby.readthedocs.org/en/latest/usage/authorization/Authorization/) for more info including token reuse.
126
+
125
127
  ### API Requests
126
128
 
127
129
  Requests are made using the inclued Faraday client which you can
@@ -189,27 +191,7 @@ end
189
191
 
190
192
  ## Change Log
191
193
 
192
- - **2015-05-31**: 0.1.2
193
- - Add Ruby 1.8.7 support
194
- - Add CI for Ruby 2.2.0 & 2.1.6: 2.2.2, 2.2.0, 2.1.6, 2.1.0, 2.0.0, 1.9.3, 1.8.7
195
- - **2015-05-31**: 0.1.1
196
- - Add Ruby 2.2.2 support
197
- - **2015-05-31**: 0.1.0
198
- - Add OAuth token refresh
199
- - Add OAuth2::AccessToken support
200
- - Add Code Climate hook
201
- - **2015-05-19**: 0.0.4
202
- - Add RingCentralSdk::Helpers::Request as request helpers base class
203
- - Add sdk.request() and platform.request() methods added to handle request helpers
204
- - Fax helper uses file mime-type in preference to generic octet-stream
205
- - Initial mkdocs and Read the Docs effort added
206
- - Travis CI and Coveralls hooks added
207
- - **2015-05-14**: 0.0.3
208
- - First public release
209
- - **2015-03-08**: 0.0.2
210
- - Convert methods from camelCase to under_scores
211
- - **2015-03-07**: 0.0.1
212
- - Initial release
194
+ See [CHANGELOG.md](CHANGELOG.md)
213
195
 
214
196
  ## Links
215
197
 
@@ -237,6 +219,6 @@ Please report these on [Github](https://github.com/grokify/ringcentral-sdk-ruby)
237
219
 
238
220
  ## License
239
221
 
240
- RingCentral SDK is available under an MIT-style license. See {file:LICENSE.txt} for details.
222
+ RingCentral SDK is available under an MIT-style license. See [LICENSE.txt](LICENSE.txt) for details.
241
223
 
242
224
  RingCentral SDK © 2015 by John Wang
data/VERSION.txt CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -19,16 +19,15 @@ module RingCentralSdk::Platform
19
19
 
20
20
  attr_accessor :server_url
21
21
 
22
- attr_reader :client
22
+ attr_reader :client
23
+ attr_reader :token
23
24
 
24
25
  def initialize(app_key='', app_secret='', server_url=RingCentralSdk::Sdk::RC_SERVER_SANDBOX)
25
-
26
26
  @app_key = app_key
27
27
  @app_secret = app_secret
28
28
  @server_url = server_url
29
29
  @token = nil
30
30
  @client = nil
31
-
32
31
  end
33
32
 
34
33
  def get_api_version_url()
@@ -36,17 +35,25 @@ module RingCentralSdk::Platform
36
35
  end
37
36
 
38
37
  def authorize(username='', extension='', password='', remember=false)
38
+ oauth2client = get_oauth2_client()
39
39
 
40
- oauth2 = OAuth2::Client.new(@app_key, @app_secret,
41
- :site => @server_url,
42
- :token_url => TOKEN_ENDPOINT)
43
-
44
- token = oauth2.password.get_token(username, password, {
40
+ token = oauth2client.password.get_token(username, password, {
45
41
  :extension => extension,
46
42
  :headers => { 'Authorization' => 'Basic ' + get_api_key() } })
47
43
 
48
44
  authorized(token)
45
+ end
49
46
 
47
+ def set_token(token=nil)
48
+ if token.is_a?(OAuth2::AccessToken)
49
+ authorized(token)
50
+ elsif token.is_a?(Hash)
51
+ oauth2client = get_oauth2_client()
52
+ oauth2token = OAuth2::AccessToken::from_hash(oauth2client, token)
53
+ authorized(oauth2token)
54
+ else
55
+ raise "Invalid Token"
56
+ end
50
57
  end
51
58
 
52
59
  def authorized(token=nil)
@@ -59,7 +66,12 @@ module RingCentralSdk::Platform
59
66
  conn.response :json, :content_type => 'application/json'
60
67
  conn.adapter Faraday.default_adapter
61
68
  end
69
+ end
62
70
 
71
+ def get_oauth2_client()
72
+ return OAuth2::Client.new(@app_key, @app_secret,
73
+ :site => @server_url,
74
+ :token_url => TOKEN_ENDPOINT)
63
75
  end
64
76
 
65
77
  def get_api_key()
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.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-29 00:00:00.000000000 Z
11
+ date: 2015-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday