ringcentral_sdk 0.1.1 → 0.1.2
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +101 -81
- data/VERSION.txt +1 -1
- data/lib/ringcentral_sdk/helpers/fax.rb +7 -2
- data/lib/ringcentral_sdk/platform/platform.rb +1 -9
- metadata +3 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b397469518faf248324c39e55e10d65ce93191e2
|
|
4
|
+
data.tar.gz: b33aad360bf66be021dbb2a3a175befa196f8aea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2275f8a557e7fbb962c563fc04ed4184d1f5e8f1cab7dbf19ad2205fffc753ffd5bde343881bb919b81f200c9abd8ec76e43bbfff2b7753abe96d16018e522d2
|
|
7
|
+
data.tar.gz: ca69cc1b1559f6582e5c2c60ea4b454e201573a9e7b05f29148286b815d4cdc4a83ab117854556f98c4d2ab2301c85d399da00f1f68c78686ba2d7cdbd825044
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -1,38 +1,71 @@
|
|
|
1
1
|
RingCentral SDK
|
|
2
2
|
===============
|
|
3
3
|
|
|
4
|
+
[](http://badge.fury.io/rb/ringcentral_sdk)
|
|
4
5
|
[](https://travis-ci.org/grokify/ringcentral-sdk-ruby)
|
|
5
6
|
[](https://codeclimate.com/github/grokify/ringcentral-sdk-ruby)
|
|
6
7
|
[](https://coveralls.io/r/grokify/ringcentral-sdk-ruby?branch=master)
|
|
7
|
-
[](http://ringcentral-sdk-ruby.readthedocs.org/)
|
|
9
|
+
[](http://www.rubydoc.info/gems/ringcentral_sdk/)
|
|
8
10
|
[](https://raw.githubusercontent.com/grokify/ringcentral-sdk-ruby/master/LICENSE.txt)
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
## Table of contents
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
1. [Overview](#overview)
|
|
15
|
+
1. [Included](#included)
|
|
16
|
+
2. [To Do](#to-do)
|
|
17
|
+
2. [Documentation](#documentation)
|
|
18
|
+
3. [Installation](#installation)
|
|
19
|
+
2. [Usage](#usage)
|
|
20
|
+
1. [Instantiation](#instantiation)
|
|
21
|
+
1. [Authorization](#authorization)
|
|
22
|
+
1. [API Requests](#api-requests)
|
|
23
|
+
1. [SMS Example](#sms-example)
|
|
24
|
+
2. [Fax Example](#fax-example)
|
|
25
|
+
5. [Change Log](#change-log)
|
|
26
|
+
6. [Links](#links)
|
|
27
|
+
7. [Contributions](#contributions)
|
|
28
|
+
8. [License](#license)
|
|
13
29
|
|
|
14
|
-
|
|
30
|
+
## Overview
|
|
31
|
+
|
|
32
|
+
This is an unofficial Ruby SDK for the RingCentral for Developers Platform REST API (https://developers.ringcentral.com).
|
|
33
|
+
|
|
34
|
+
The core SDK objects follow the general design of the [official RingCentral SDKs](https://github.com/ringcentral). Additional functionality is provided for ease of use including request helpers and generalized OAuth2 support.
|
|
15
35
|
|
|
16
36
|
This SDK is an early stage library and subject to breaking changes.
|
|
17
37
|
|
|
18
|
-
|
|
38
|
+
### Included
|
|
19
39
|
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
40
|
+
* OAuth2 authorization & token refresh via INTRIDEA OAuth2::AccessToken
|
|
41
|
+
* Generic API requests handled via Faraday client
|
|
42
|
+
* Fax request helper to create multipart/mixed messages
|
|
43
|
+
* Docs via [Read the Docs](http://ringcentral-sdk-ruby.readthedocs.org/) and [RubyDoc](http://www.rubydoc.info/gems/ringcentral_sdk/)
|
|
24
44
|
|
|
25
|
-
|
|
45
|
+
### To Do
|
|
26
46
|
|
|
27
47
|
The following items are still needed for this SDK. Contributions are most welcome.
|
|
28
48
|
|
|
29
49
|
* Subscriptions
|
|
30
50
|
* Mock tests
|
|
31
51
|
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
## Documentation
|
|
53
|
+
|
|
54
|
+
More documentation is available on [Read the Docs](http://ringcentral-sdk-ruby.readthedocs.org/)
|
|
55
|
+
and [RubyDoc](http://www.rubydoc.info/gems/ringcentral_sdk/). The documentation philosophy is to
|
|
56
|
+
use RubyDoc / YARD for brief documentation and code specific docs while using Read the Docs for
|
|
57
|
+
user guide / tutorial / FAQ style documentation.
|
|
58
|
+
|
|
59
|
+
In addition the documentation for this Ruby SDK, refer to the official RingCentral guides for
|
|
60
|
+
more information on individual API calls:
|
|
61
|
+
|
|
62
|
+
1. [API Developer and Reference Guide](https://developers.ringcentral.com/api-docs/latest/index.html) for information on specific APIs.
|
|
63
|
+
1. [API Explorer](http://ringcentral.github.io/api-explorer/)
|
|
64
|
+
1. [CTI Tutorial](http://ringcentral.github.io/cti-tutorial/)
|
|
34
65
|
|
|
35
|
-
##
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
### Via Bundler
|
|
36
69
|
|
|
37
70
|
Add this line to your application's Gemfile:
|
|
38
71
|
|
|
@@ -46,16 +79,19 @@ And then execute:
|
|
|
46
79
|
$ bundle
|
|
47
80
|
```
|
|
48
81
|
|
|
49
|
-
|
|
82
|
+
### Via RubyGems
|
|
50
83
|
|
|
51
84
|
```sh
|
|
52
85
|
$ gem install ringcentral_sdk
|
|
53
86
|
```
|
|
54
87
|
|
|
55
|
-
Usage
|
|
56
|
-
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
This provides a very basic guide to using the SDK. Please use the following resources for more information:
|
|
57
91
|
|
|
58
|
-
|
|
92
|
+
1. [API Developer and Reference Guide](https://developers.ringcentral.com/api-docs/latest/index.html)
|
|
93
|
+
|
|
94
|
+
### Instantiation
|
|
59
95
|
|
|
60
96
|
The RingCentral server URLs can be populated manually or via the included constants:
|
|
61
97
|
|
|
@@ -63,8 +99,6 @@ The RingCentral server URLs can be populated manually or via the included consta
|
|
|
63
99
|
* `RingCentralSdk::Sdk::RC_SERVER_SANDBOX`
|
|
64
100
|
|
|
65
101
|
```ruby
|
|
66
|
-
## Initialization ##
|
|
67
|
-
|
|
68
102
|
require 'ringcentral_sdk'
|
|
69
103
|
|
|
70
104
|
rcsdk = RingCentralSdk::Sdk.new(
|
|
@@ -75,7 +109,7 @@ rcsdk = RingCentralSdk::Sdk.new(
|
|
|
75
109
|
platform = rcsdk.platform
|
|
76
110
|
```
|
|
77
111
|
|
|
78
|
-
|
|
112
|
+
### Authorization
|
|
79
113
|
|
|
80
114
|
```ruby
|
|
81
115
|
# Initialize using user phone number without extension number
|
|
@@ -87,20 +121,21 @@ platform.authorize("myUsername", nil, "myPassword")
|
|
|
87
121
|
platform.authorize("myUsername", "myExtension", "myPassword")
|
|
88
122
|
```
|
|
89
123
|
|
|
90
|
-
|
|
124
|
+
### API Requests
|
|
91
125
|
|
|
92
|
-
Requests are made using the inclued Faraday client
|
|
126
|
+
Requests are made using the inclued Faraday client which you can
|
|
127
|
+
retrieve by calling `rcsdk.platform.client` or using it directly.
|
|
93
128
|
|
|
94
129
|
```ruby
|
|
95
130
|
client = rcsdk.platform.client
|
|
96
131
|
```
|
|
97
132
|
|
|
98
|
-
|
|
133
|
+
#### SMS Example
|
|
99
134
|
|
|
100
135
|
SMS and other requests can be easily sent directly without helpers.
|
|
101
136
|
|
|
102
137
|
```ruby
|
|
103
|
-
#
|
|
138
|
+
# SMS Example
|
|
104
139
|
|
|
105
140
|
response = client.post do |req|
|
|
106
141
|
req.url 'account/~/extension/~/sms'
|
|
@@ -113,35 +148,24 @@ response = client.post do |req|
|
|
|
113
148
|
end
|
|
114
149
|
```
|
|
115
150
|
|
|
116
|
-
|
|
151
|
+
#### Fax Example
|
|
117
152
|
|
|
118
|
-
|
|
153
|
+
Request helpers are subclasses of `RingCentralSdk::Helpers::Request` and provide standard methods
|
|
154
|
+
that can be called by the `.request()` method of the SDK and Platform objects. This enables the
|
|
155
|
+
requisite information for Faraday to be generated in a standard way.
|
|
119
156
|
|
|
120
|
-
|
|
157
|
+
To create your own request helpers, please take a look at the fax one shown below:
|
|
121
158
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
{ :account_id => '~', :extension_id => '~' }, # Can be nil or {} for defaults '~'
|
|
127
|
-
{
|
|
128
|
-
# phone numbers are in E.164 format with or without leading '+'
|
|
129
|
-
:to => [{ :phoneNumber => '+16505551212' }],
|
|
130
|
-
:coverPageText => 'RingCentral fax text demo using Ruby!'
|
|
131
|
-
},
|
|
132
|
-
:text => 'RingCentral Fax via Ruby!'
|
|
133
|
-
)
|
|
134
|
-
# send the fax using Faraday as shown below
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### 2) Fax Helper for File as Raw Bytes (e.g. PDF or TIFF)
|
|
138
|
-
|
|
139
|
-
Sending a file as a plain octet-stream is useful in production as it can decrease file size by 30%.
|
|
159
|
+
The fax helper is included to help create the `multipart/mixed` HTTP request. This consists of
|
|
160
|
+
instantiating a fax helper object and then executing a Faraday POST request. The helper can then
|
|
161
|
+
be used with the standard faraday client or helper `.request()` method that takes the request
|
|
162
|
+
helper object in its entirety.
|
|
140
163
|
|
|
141
164
|
```ruby
|
|
165
|
+
# Fax example using request helper
|
|
142
166
|
|
|
143
167
|
fax = RingCentralSdk::Helpers::CreateFaxRequest.new(
|
|
144
|
-
{
|
|
168
|
+
nil, # auto-inflates to [{:account_id => '~', :extension_id => '~'}]
|
|
145
169
|
{
|
|
146
170
|
# phone numbers are in E.164 format with or without leading '+'
|
|
147
171
|
:to => [{ :phoneNumber => '+16505551212' }],
|
|
@@ -149,30 +173,12 @@ fax = RingCentralSdk::Helpers::CreateFaxRequest.new(
|
|
|
149
173
|
},
|
|
150
174
|
:file_name => '/path/to/my_file.pdf'
|
|
151
175
|
)
|
|
152
|
-
# send the fax using Faraday as shown below
|
|
153
|
-
```
|
|
154
176
|
|
|
155
|
-
|
|
177
|
+
# sending request via request helper methods
|
|
178
|
+
response = sdk.request(fax)
|
|
179
|
+
response = sdk.platform.request(fax)
|
|
156
180
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
```ruby
|
|
160
|
-
fax = RingCentralSdk::Helpers::CreateFaxRequest.new(
|
|
161
|
-
{ :account_id => '~', :extension_id => '~' }, # Can be nil or {} for defaults '~'
|
|
162
|
-
{
|
|
163
|
-
# phone numbers are in E.164 format with or without leading '+'
|
|
164
|
-
:to => [{ :phoneNumber => '+16505551212' }],
|
|
165
|
-
:coverPageText => 'RingCentral fax TIFF base64 demo using Ruby!'
|
|
166
|
-
},
|
|
167
|
-
:file_name => '/path/to/my_file.tif',
|
|
168
|
-
:base64_encode => true
|
|
169
|
-
)
|
|
170
|
-
# send the fax using Faraday as shown below
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
### Sending the fax
|
|
174
|
-
|
|
175
|
-
```ruby
|
|
181
|
+
# sending request via standard Faraday client
|
|
176
182
|
response = client.post do |req|
|
|
177
183
|
req.url fax.url
|
|
178
184
|
req.headers['Content-Type'] = fax.content_type
|
|
@@ -180,14 +186,28 @@ response = client.post do |req|
|
|
|
180
186
|
end
|
|
181
187
|
```
|
|
182
188
|
|
|
183
|
-
Change Log
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
## Change Log
|
|
190
|
+
|
|
191
|
+
- **2015-05-31**: 0.1.1
|
|
192
|
+
- Add Ruby 2.2.2 support
|
|
193
|
+
- **2015-05-31**: 0.1.0
|
|
194
|
+
- Add OAuth token refresh
|
|
195
|
+
- Add OAuth2::AccessToken support
|
|
196
|
+
- Add Code Climate hook
|
|
197
|
+
- **2015-05-19**: 0.0.4
|
|
198
|
+
- Add RingCentralSdk::Helpers::Request as request helpers base class
|
|
199
|
+
- Add sdk.request() and platform.request() methods added to handle request helpers
|
|
200
|
+
- Fax helper uses file mime-type in preference to generic octet-stream
|
|
201
|
+
- Initial mkdocs and Read the Docs effort added
|
|
202
|
+
- Travis CI and Coveralls hooks added
|
|
203
|
+
- **2015-05-14**: 0.0.3
|
|
204
|
+
- First public release
|
|
205
|
+
- **2015-03-08**: 0.0.2
|
|
206
|
+
- Convert methods from camelCase to under_scores
|
|
207
|
+
- **2015-03-07**: 0.0.1
|
|
208
|
+
- Initial release
|
|
209
|
+
|
|
210
|
+
## Links
|
|
191
211
|
|
|
192
212
|
Project Repo
|
|
193
213
|
|
|
@@ -205,13 +225,13 @@ RingCentral Official SDKs
|
|
|
205
225
|
|
|
206
226
|
* https://github.com/ringcentral
|
|
207
227
|
|
|
208
|
-
|
|
209
|
-
|
|
228
|
+
## Contributions
|
|
229
|
+
|
|
230
|
+
Any reports of problems, comments or suggestions are most welcome.
|
|
210
231
|
|
|
211
|
-
|
|
232
|
+
Please report these on [Github](https://github.com/grokify/ringcentral-sdk-ruby)
|
|
212
233
|
|
|
213
|
-
License
|
|
214
|
-
=======
|
|
234
|
+
## License
|
|
215
235
|
|
|
216
236
|
RingCentral SDK is available under an MIT-style license. See {file:LICENSE.txt} for details.
|
|
217
237
|
|
data/VERSION.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.2
|
|
@@ -75,9 +75,14 @@ module RingCentralSdk::Helpers
|
|
|
75
75
|
raise "File \"#{file_name.to_s}\" does not exist or cannot be read"
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
+
file_bytes = RUBY_VERSION < '1.9' \
|
|
79
|
+
? File.open(file_name, 'rb') { |f| f.read } \
|
|
80
|
+
: File.open(file_name, 'rb:BINARY') { |f| f.read }
|
|
81
|
+
|
|
78
82
|
file_part = base64_encode \
|
|
79
|
-
? MIME::Text.new(Base64.encode64(
|
|
80
|
-
: MIME::Application.new(
|
|
83
|
+
? MIME::Text.new(Base64.encode64(file_bytes)) \
|
|
84
|
+
: MIME::Application.new(file_bytes)
|
|
85
|
+
|
|
81
86
|
file_part.headers.delete('Content-Id')
|
|
82
87
|
file_part.headers.set('Content-Type', get_file_content_type(file_name, content_type))
|
|
83
88
|
file_part.headers.set('Content-Disposition', get_attachment_content_disposition(file_name))
|
|
@@ -17,7 +17,6 @@ module RingCentralSdk::Platform
|
|
|
17
17
|
API_VERSION = 'v1.0'
|
|
18
18
|
URL_PREFIX = '/restapi'
|
|
19
19
|
|
|
20
|
-
attr_reader :client
|
|
21
20
|
attr_accessor :server_url
|
|
22
21
|
|
|
23
22
|
def initialize(app_key='', app_secret='', server_url=RingCentralSdk::Sdk::RC_SERVER_SANDBOX)
|
|
@@ -63,17 +62,10 @@ module RingCentralSdk::Platform
|
|
|
63
62
|
|
|
64
63
|
def get_api_key()
|
|
65
64
|
api_key = (@app_key.is_a?(String) && @app_secret.is_a?(String)) \
|
|
66
|
-
? Base64.
|
|
65
|
+
? Base64.encode64("#{@app_key}:#{@app_secret}").gsub(/[\s\t\r\n]/,'') : ''
|
|
67
66
|
return api_key
|
|
68
67
|
end
|
|
69
68
|
|
|
70
|
-
def get_auth_header()
|
|
71
|
-
if @_auth.token_type.is_a?(String) && @_auth.access_token.is_a?(String)
|
|
72
|
-
return @_auth.token_type + ' ' + @_auth.access_token
|
|
73
|
-
end
|
|
74
|
-
return ''
|
|
75
|
-
end
|
|
76
|
-
|
|
77
69
|
def request(helper=nil)
|
|
78
70
|
unless helper.is_a?(RingCentralSdk::Helpers::Request)
|
|
79
71
|
raise 'Request is not a RingCentralSdk::Helpers::Request'
|
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: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Wang
|
|
@@ -82,22 +82,16 @@ dependencies:
|
|
|
82
82
|
name: mime-types
|
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
|
84
84
|
requirements:
|
|
85
|
-
- - ~>
|
|
86
|
-
- !ruby/object:Gem::Version
|
|
87
|
-
version: '2.5'
|
|
88
85
|
- - '>='
|
|
89
86
|
- !ruby/object:Gem::Version
|
|
90
|
-
version: '
|
|
87
|
+
version: '1.25'
|
|
91
88
|
type: :runtime
|
|
92
89
|
prerelease: false
|
|
93
90
|
version_requirements: !ruby/object:Gem::Requirement
|
|
94
91
|
requirements:
|
|
95
|
-
- - ~>
|
|
96
|
-
- !ruby/object:Gem::Version
|
|
97
|
-
version: '2.5'
|
|
98
92
|
- - '>='
|
|
99
93
|
- !ruby/object:Gem::Version
|
|
100
|
-
version: '
|
|
94
|
+
version: '1.25'
|
|
101
95
|
- !ruby/object:Gem::Dependency
|
|
102
96
|
name: multi_json
|
|
103
97
|
requirement: !ruby/object:Gem::Requirement
|