ringcentral_sdk 2.0.3 → 2.1.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +24 -25
- data/LICENSE.md +1 -1
- data/README.md +23 -10
- data/lib/ringcentral_sdk.rb +1 -1
- data/lib/ringcentral_sdk/rest/messages.rb +39 -14
- data/lib/ringcentral_sdk/rest/request.rb +2 -0
- data/lib/ringcentral_sdk/rest/request/base_multipart.rb +94 -0
- data/lib/ringcentral_sdk/rest/request/fax.rb +7 -97
- data/lib/ringcentral_sdk/rest/request/inflator/contact_info.rb +10 -0
- data/lib/ringcentral_sdk/rest/request/sms.rb +25 -0
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 83d46bb9ba9b0eed4874438f1532291460c09ea9
|
|
4
|
+
data.tar.gz: 48825a7449dc3675fa5898ac8526433e8e1c10c8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0a87654d4ce18fcae34692bba5da3823889cbb03c0e481fb338a93c3f22d9813ee4ad2f5a8399ab14650230003ad09eb41296415fe0364e9b94d09d6b2b61c6b
|
|
7
|
+
data.tar.gz: 7e2104f2d664a74fe4ce36db59c26ef92a773cce28c174052fe1a9ff1451ef4b89151d4310d1f7eada45b01136500b547f31eb016088994700dfad04bc1ecfc7
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
ringcentral_sdk (2.0
|
|
4
|
+
ringcentral_sdk (2.1.0)
|
|
5
5
|
dotenv (~> 2.1, >= 2.1.0)
|
|
6
6
|
faraday (~> 0, >= 0)
|
|
7
7
|
faraday_middleware (~> 0, >= 0)
|
|
@@ -36,28 +36,28 @@ GEM
|
|
|
36
36
|
timers (>= 4.1.1)
|
|
37
37
|
celluloid-supervision (0.20.6)
|
|
38
38
|
timers (>= 4.1.1)
|
|
39
|
-
concurrent-ruby (1.0.
|
|
40
|
-
coveralls (0.8.
|
|
39
|
+
concurrent-ruby (1.0.5)
|
|
40
|
+
coveralls (0.8.20)
|
|
41
41
|
json (>= 1.8, < 3)
|
|
42
|
-
simplecov (~> 0.
|
|
42
|
+
simplecov (~> 0.14.1)
|
|
43
43
|
term-ansicolor (~> 1.3)
|
|
44
|
-
thor (~> 0.19.
|
|
44
|
+
thor (~> 0.19.4)
|
|
45
45
|
tins (~> 1.6)
|
|
46
46
|
docile (1.1.5)
|
|
47
|
-
dotenv (2.
|
|
48
|
-
dry-configurable (0.
|
|
47
|
+
dotenv (2.2.0)
|
|
48
|
+
dry-configurable (0.6.2)
|
|
49
49
|
concurrent-ruby (~> 1.0)
|
|
50
50
|
dry-container (0.6.0)
|
|
51
51
|
concurrent-ruby (~> 1.0)
|
|
52
52
|
dry-configurable (~> 0.1, >= 0.1.3)
|
|
53
|
-
dry-core (0.2.
|
|
53
|
+
dry-core (0.2.4)
|
|
54
54
|
concurrent-ruby (~> 1.0)
|
|
55
55
|
dry-equalizer (0.2.0)
|
|
56
|
-
dry-logic (0.4.
|
|
56
|
+
dry-logic (0.4.1)
|
|
57
57
|
dry-container (~> 0.2, >= 0.2.6)
|
|
58
|
-
dry-core (~> 0.
|
|
58
|
+
dry-core (~> 0.2)
|
|
59
59
|
dry-equalizer (~> 0.2)
|
|
60
|
-
dry-types (0.9.
|
|
60
|
+
dry-types (0.9.4)
|
|
61
61
|
concurrent-ruby (~> 1.0)
|
|
62
62
|
dry-configurable (~> 0.1)
|
|
63
63
|
dry-container (~> 0.3)
|
|
@@ -65,28 +65,27 @@ GEM
|
|
|
65
65
|
dry-equalizer (~> 0.2)
|
|
66
66
|
dry-logic (~> 0.4, >= 0.4.0)
|
|
67
67
|
inflecto (~> 0.0.0, >= 0.0.2)
|
|
68
|
-
dry-validation (0.10.
|
|
68
|
+
dry-validation (0.10.5)
|
|
69
69
|
concurrent-ruby (~> 1.0)
|
|
70
70
|
dry-configurable (~> 0.1, >= 0.1.3)
|
|
71
|
-
dry-container (~> 0.2, >= 0.2.8)
|
|
72
71
|
dry-core (~> 0.2, >= 0.2.1)
|
|
73
72
|
dry-equalizer (~> 0.2)
|
|
74
73
|
dry-logic (~> 0.4, >= 0.4.0)
|
|
75
74
|
dry-types (~> 0.9, >= 0.9.0)
|
|
76
|
-
faraday (0.
|
|
75
|
+
faraday (0.11.0)
|
|
77
76
|
multipart-post (>= 1.2, < 3)
|
|
78
|
-
faraday_middleware (0.
|
|
77
|
+
faraday_middleware (0.11.0.1)
|
|
79
78
|
faraday (>= 0.7.4, < 1.0)
|
|
80
79
|
faraday_middleware-oauth2_refresh (0.0.3)
|
|
81
80
|
faraday (~> 0.9, >= 0.9)
|
|
82
81
|
faraday_middleware (~> 0, >= 0)
|
|
83
|
-
faraday_middleware-request-retry (0.
|
|
82
|
+
faraday_middleware-request-retry (0.2.0)
|
|
84
83
|
faraday (~> 0, >= 0)
|
|
85
84
|
faraday_middleware (~> 0, >= 0)
|
|
86
85
|
hitimes (1.2.4)
|
|
87
86
|
httpclient (2.8.3)
|
|
88
87
|
inflecto (0.0.2)
|
|
89
|
-
json (2.0.
|
|
88
|
+
json (2.0.3)
|
|
90
89
|
jsondoc (0.1.3)
|
|
91
90
|
jwt (1.5.6)
|
|
92
91
|
logger (1.2.8)
|
|
@@ -104,33 +103,33 @@ GEM
|
|
|
104
103
|
multi_json (1.12.1)
|
|
105
104
|
multi_xml (0.6.0)
|
|
106
105
|
multipart-post (2.0.0)
|
|
107
|
-
oauth2 (1.
|
|
108
|
-
faraday (>= 0.8, < 0.
|
|
106
|
+
oauth2 (1.3.1)
|
|
107
|
+
faraday (>= 0.8, < 0.12)
|
|
109
108
|
jwt (~> 1.0)
|
|
110
109
|
multi_json (~> 1.3)
|
|
111
110
|
multi_xml (~> 0.5)
|
|
112
111
|
rack (>= 1.2, < 3)
|
|
113
|
-
power_assert (0.
|
|
114
|
-
pubnub (4.0.
|
|
112
|
+
power_assert (1.0.1)
|
|
113
|
+
pubnub (4.0.19)
|
|
115
114
|
celluloid (~> 0.17)
|
|
116
115
|
dry-validation (~> 0.10)
|
|
117
116
|
httpclient (~> 2.8)
|
|
118
117
|
json (>= 1.8, < 3)
|
|
119
118
|
rack (2.0.1)
|
|
120
119
|
rake (12.0.0)
|
|
121
|
-
simplecov (0.
|
|
120
|
+
simplecov (0.14.1)
|
|
122
121
|
docile (~> 1.1.0)
|
|
123
122
|
json (>= 1.8, < 3)
|
|
124
123
|
simplecov-html (~> 0.10.0)
|
|
125
124
|
simplecov-html (0.10.0)
|
|
126
|
-
term-ansicolor (1.
|
|
125
|
+
term-ansicolor (1.5.0)
|
|
127
126
|
tins (~> 1.0)
|
|
128
127
|
test-unit (3.2.3)
|
|
129
128
|
power_assert
|
|
130
129
|
thor (0.19.4)
|
|
131
130
|
timers (4.1.2)
|
|
132
131
|
hitimes
|
|
133
|
-
tins (1.13.
|
|
132
|
+
tins (1.13.2)
|
|
134
133
|
|
|
135
134
|
PLATFORMS
|
|
136
135
|
ruby
|
|
@@ -145,4 +144,4 @@ DEPENDENCIES
|
|
|
145
144
|
test-unit (~> 3)
|
|
146
145
|
|
|
147
146
|
BUNDLED WITH
|
|
148
|
-
1.13.
|
|
147
|
+
1.13.7
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
|
@@ -24,8 +24,8 @@ RingCentral SDK for Ruby
|
|
|
24
24
|
1. [Synopsis](#synopsis)
|
|
25
25
|
1. [API Requests](#api-requests)
|
|
26
26
|
1. [Generic HTTP Requests](#generic-http-requests)
|
|
27
|
-
2. [SMS
|
|
28
|
-
3. [Fax
|
|
27
|
+
2. [SMS and MMS Examples](#sms-and-mms-examples)
|
|
28
|
+
3. [Fax Examples](#fax-examples)
|
|
29
29
|
1. [Advanced Use Cases](#advanced-use-cases)
|
|
30
30
|
5. [Supported Ruby Versions](#supported-ruby-versions)
|
|
31
31
|
6. [Releases](#releases)
|
|
@@ -130,7 +130,9 @@ This is useful to access many API endpoints which do not have custom wrappers an
|
|
|
130
130
|
http = client.http
|
|
131
131
|
```
|
|
132
132
|
|
|
133
|
-
#### SMS
|
|
133
|
+
#### SMS and MMS Examples
|
|
134
|
+
|
|
135
|
+
SMS:
|
|
134
136
|
|
|
135
137
|
```ruby
|
|
136
138
|
client.messages.sms.create(
|
|
@@ -140,7 +142,18 @@ client.messages.sms.create(
|
|
|
140
142
|
)
|
|
141
143
|
```
|
|
142
144
|
|
|
143
|
-
|
|
145
|
+
MMS with media file:
|
|
146
|
+
|
|
147
|
+
```ruby
|
|
148
|
+
client.messages.sms.create(
|
|
149
|
+
from: '+16505551212',
|
|
150
|
+
to: '+14155551212',
|
|
151
|
+
text: 'Hi there!',
|
|
152
|
+
media: '/filepath/to/file.ext'
|
|
153
|
+
)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### Fax Examples
|
|
144
157
|
|
|
145
158
|
Fax files:
|
|
146
159
|
|
|
@@ -170,20 +183,20 @@ To make subscriptions with RingCentral, use the SDK object to create subscriptio
|
|
|
170
183
|
# Create an observer object
|
|
171
184
|
class MyObserver
|
|
172
185
|
def update(message)
|
|
173
|
-
puts
|
|
186
|
+
puts 'Subscription Message Received'
|
|
174
187
|
puts JSON.dump(message)
|
|
175
188
|
end
|
|
176
189
|
end
|
|
177
190
|
|
|
178
191
|
# Create an observable subscription and add your observer
|
|
179
|
-
sub = client.create_subscription
|
|
180
|
-
sub.add_observer
|
|
192
|
+
sub = client.create_subscription
|
|
193
|
+
sub.add_observer MyObserver.new
|
|
181
194
|
|
|
182
195
|
# Subscribe to an arbitrary number of event filters
|
|
183
|
-
sub.subscribe
|
|
196
|
+
sub.subscribe ['/restapi/v1.0/account/~/extension/~/presence']
|
|
184
197
|
|
|
185
198
|
# End the subscription
|
|
186
|
-
sub.destroy
|
|
199
|
+
sub.destroy
|
|
187
200
|
```
|
|
188
201
|
|
|
189
202
|
### Advanced Use Cases
|
|
@@ -238,7 +251,7 @@ RingCentral Official SDKs
|
|
|
238
251
|
|
|
239
252
|
RingCentral SDK is available under an MIT-style license. See [LICENSE.md](LICENSE.md) for details.
|
|
240
253
|
|
|
241
|
-
RingCentral SDK © 2015-
|
|
254
|
+
RingCentral SDK © 2015-2017 by John Wang
|
|
242
255
|
|
|
243
256
|
[gem-version-svg]: https://badge.fury.io/rb/ringcentral_sdk.svg
|
|
244
257
|
[gem-version-link]: http://badge.fury.io/rb/ringcentral_sdk
|
data/lib/ringcentral_sdk.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# RingCentralSdk is a SDK for the RingCentral REST API
|
|
2
2
|
module RingCentralSdk
|
|
3
|
-
VERSION = '2.0
|
|
3
|
+
VERSION = '2.1.0'.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,8 +7,8 @@ module RingCentralSdk
|
|
|
7
7
|
|
|
8
8
|
def initialize(client)
|
|
9
9
|
@client = client
|
|
10
|
-
@sms = RingCentralSdk::REST::MessagesSMS.new
|
|
11
|
-
@fax = RingCentralSdk::REST::MessagesFax.new
|
|
10
|
+
@sms = RingCentralSdk::REST::MessagesSMS.new client
|
|
11
|
+
@fax = RingCentralSdk::REST::MessagesFax.new client
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
end
|
|
@@ -16,23 +16,27 @@ end
|
|
|
16
16
|
|
|
17
17
|
module RingCentralSdk
|
|
18
18
|
module REST
|
|
19
|
-
# MessagesSMS provides a helper for SMS messages
|
|
19
|
+
# MessagesSMS provides a helper for SMS and MMS messages
|
|
20
20
|
class MessagesSMS
|
|
21
21
|
def initialize(client)
|
|
22
22
|
@client = client
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def create(opts)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
req = RingCentralSdk::REST::Request::SMS.new
|
|
27
|
+
req.add_metadata({
|
|
28
|
+
to: opts[:to],
|
|
29
|
+
from: opts[:from],
|
|
30
|
+
text: opts[:text]
|
|
31
|
+
})
|
|
32
|
+
if opts.key? :media
|
|
33
|
+
if opts[:media].is_a? String
|
|
34
|
+
req.add_file opts[:media]
|
|
35
|
+
elsif opts[:media].is_a? Array
|
|
36
|
+
req.add_files opts[:media]
|
|
37
|
+
end
|
|
34
38
|
end
|
|
35
|
-
|
|
39
|
+
@client.send_request req
|
|
36
40
|
end
|
|
37
41
|
end
|
|
38
42
|
end
|
|
@@ -47,8 +51,29 @@ module RingCentralSdk
|
|
|
47
51
|
end
|
|
48
52
|
|
|
49
53
|
def create(opts)
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
req = RingCentralSdk::REST::Request::Fax.new
|
|
55
|
+
meta = {}
|
|
56
|
+
|
|
57
|
+
skip = {text: 1, files: 1}
|
|
58
|
+
|
|
59
|
+
opts.each do |k,v|
|
|
60
|
+
meta[k] = v unless skip.key? k
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
req.add_metadata meta
|
|
64
|
+
|
|
65
|
+
if opts.key? :text
|
|
66
|
+
req.add_text opts[:text]
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
if opts.key? :files
|
|
70
|
+
if opts[:files].is_a? String
|
|
71
|
+
req.add_file opts[:files]
|
|
72
|
+
elsif opts[:files].is_a? Array
|
|
73
|
+
req.add_files opts[:files]
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
@client.send_request req
|
|
52
77
|
end
|
|
53
78
|
end
|
|
54
79
|
end
|
|
@@ -3,9 +3,11 @@ module RingCentralSdk
|
|
|
3
3
|
# Request is the module namespace for various API request helpers.
|
|
4
4
|
module Request
|
|
5
5
|
autoload :Base, 'ringcentral_sdk/rest/request/base'
|
|
6
|
+
autoload :BaseMultipart, 'ringcentral_sdk/rest/request/base_multipart'
|
|
6
7
|
autoload :Fax, 'ringcentral_sdk/rest/request/fax'
|
|
7
8
|
autoload :Inflator, 'ringcentral_sdk/rest/request/inflator'
|
|
8
9
|
autoload :Simple, 'ringcentral_sdk/rest/request/simple'
|
|
10
|
+
autoload :SMS, 'ringcentral_sdk/rest/request/sms'
|
|
9
11
|
end
|
|
10
12
|
end
|
|
11
13
|
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
require 'base64'
|
|
2
|
+
require 'mime'
|
|
3
|
+
require 'mime/types'
|
|
4
|
+
require 'mime_builder'
|
|
5
|
+
require 'multi_json'
|
|
6
|
+
|
|
7
|
+
module RingCentralSdk
|
|
8
|
+
module REST
|
|
9
|
+
module Request
|
|
10
|
+
# BaseMultipart is a base reqwuest helper class for multipart/mixed messages
|
|
11
|
+
class BaseMultipart < RingCentralSdk::REST::Request::Base
|
|
12
|
+
CONTENT_ID_HEADER = 'Content-Id'.freeze
|
|
13
|
+
DEFAULT_METHOD = 'post'.freeze
|
|
14
|
+
DEFAULT_ID = '~'.freeze
|
|
15
|
+
DEFAULT_BASE64_ENCODE = true
|
|
16
|
+
DEFAULT_CONTENT_ID_DISABLE = true
|
|
17
|
+
|
|
18
|
+
attr_accessor :method
|
|
19
|
+
attr_accessor :mime_part_params
|
|
20
|
+
|
|
21
|
+
attr_reader :mime
|
|
22
|
+
attr_reader :account_id
|
|
23
|
+
attr_reader :extension_id
|
|
24
|
+
|
|
25
|
+
def initialize(opts = {})
|
|
26
|
+
@mime = MIME::Multipart::Mixed.new
|
|
27
|
+
@mime.headers.delete CONTENT_ID_HEADER
|
|
28
|
+
|
|
29
|
+
@method = opts[:method] ||= DEFAULT_METHOD
|
|
30
|
+
|
|
31
|
+
@mime_part_params = {
|
|
32
|
+
base64_encode: opts[:base64_encode] ||= DEFAULT_BASE64_ENCODE,
|
|
33
|
+
content_id_disable: opts[:content_id_disable] ||= DEFAULT_CONTENT_ID_DISABLE
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
path_params(opts)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def path_params(opts = {})
|
|
40
|
+
@account_id = opts[:account_id] ||= opts[:accountId] ||= DEFAULT_ID
|
|
41
|
+
@extension_id = opts[:extension_id] ||= opts[:extensionId] ||= DEFAULT_ID
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def add_metadata(data, opts = {})
|
|
45
|
+
if data.is_a? MIME::Media
|
|
46
|
+
@mime.add data
|
|
47
|
+
else
|
|
48
|
+
@mime.add MIMEBuilder::JSON.new(
|
|
49
|
+
data,
|
|
50
|
+
@mime_part_params.merge(opts)
|
|
51
|
+
).mime
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def add_text(text = nil, opts = {})
|
|
56
|
+
return if text.nil? || text.to_s.empty?
|
|
57
|
+
@mime.add MIMEBuilder::Text.new(
|
|
58
|
+
text,
|
|
59
|
+
@mime_part_params.merge(opts)
|
|
60
|
+
).mime
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def add_file(file_path_or_part, opts = {})
|
|
64
|
+
if file_path_or_part.is_a? MIME::Media
|
|
65
|
+
@mime.add file_path_or_part
|
|
66
|
+
else
|
|
67
|
+
@mime.add MIMEBuilder::Filepath.new(
|
|
68
|
+
file_path_or_part,
|
|
69
|
+
@mime_part_params.merge(opts).merge({is_attachment: true})
|
|
70
|
+
).mime
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def add_files(files = [], opts = {})
|
|
75
|
+
files.each do |f|
|
|
76
|
+
add_file f, opts
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def url
|
|
81
|
+
"account/#{@account_id}/extension/#{@extension_id}/sms"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def content_type
|
|
85
|
+
@mime.headers.get('Content-Type').to_s
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def body
|
|
89
|
+
@mime.body.to_s
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -1,111 +1,21 @@
|
|
|
1
|
-
require 'base64'
|
|
2
|
-
require 'mime'
|
|
3
|
-
require 'mime/types'
|
|
4
|
-
require 'mime_builder'
|
|
5
|
-
require 'multi_json'
|
|
6
|
-
|
|
7
1
|
module RingCentralSdk
|
|
8
2
|
module REST
|
|
9
3
|
module Request
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def initialize(opts = {})
|
|
18
|
-
@metadata_part_encode_base64 = true
|
|
19
|
-
|
|
20
|
-
@msg = MIME::Multipart::Mixed.new
|
|
21
|
-
@msg.headers.delete('Content-Id')
|
|
22
|
-
|
|
23
|
-
add_path(opts)
|
|
24
|
-
add_part_meta(opts)
|
|
25
|
-
add_part_text(opts[:text])
|
|
26
|
-
add_parts(opts[:files])
|
|
27
|
-
add_parts(opts[:parts])
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def add_path(opts = {})
|
|
31
|
-
@account_id = opts[:accountId] ||= '~'
|
|
32
|
-
@extension_id = opts[:extensionId] ||= '~'
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def add_part_meta(opts = {})
|
|
36
|
-
meta = create_metadata opts
|
|
37
|
-
@msg.add MIMEBuilder::JSON.new(meta).mime
|
|
38
|
-
true
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def create_metadata(opts = {})
|
|
42
|
-
meta = {}
|
|
43
|
-
return meta unless opts.is_a?(Hash)
|
|
44
|
-
|
|
45
|
-
inf = RingCentralSdk::REST::Request::Inflator::ContactInfo.new
|
|
46
|
-
meta[:to] = inf.inflate_to_array opts[:to]
|
|
47
|
-
|
|
48
|
-
processed = {
|
|
49
|
-
accountId: 1,
|
|
50
|
-
extensionId: 1,
|
|
51
|
-
to: 1,
|
|
52
|
-
text: 1,
|
|
53
|
-
files: 1,
|
|
54
|
-
parts: 1
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
opts.each do |k, v|
|
|
58
|
-
meta[k] = v unless processed.key? k
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
meta
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def add_part_text(text = nil, opts = {})
|
|
65
|
-
return if text.nil? || text.to_s.empty?
|
|
66
|
-
opts[:content_id_disable] = true
|
|
67
|
-
text_part = MIMEBuilder::Text.new text, opts
|
|
68
|
-
@msg.add text_part.mime
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def add_parts(parts = [])
|
|
72
|
-
return if parts.nil?
|
|
73
|
-
unless parts.is_a? Array
|
|
74
|
-
raise 'invalid parameter[0]. needs to be an array'
|
|
75
|
-
end
|
|
76
|
-
parts.each do |part|
|
|
77
|
-
if part.is_a? MIME::Media
|
|
78
|
-
@msg.add part
|
|
79
|
-
elsif part.is_a?(String)
|
|
80
|
-
file_part = MIMEBuilder::Filepath.new part
|
|
81
|
-
@msg.add file_part.mime
|
|
82
|
-
elsif part.is_a? Hash
|
|
83
|
-
part[:content_id_disable] = true
|
|
84
|
-
part[:is_attachment] = true
|
|
85
|
-
if part.key? :filename
|
|
86
|
-
@msg.add MIMEBuilder::Filepath.new(part[:filename], part).mime
|
|
87
|
-
elsif part.key? :text
|
|
88
|
-
@msg.add MIMEBuilder::Text.new(part[:text], part).mime
|
|
89
|
-
end
|
|
4
|
+
class Fax < RingCentralSdk::REST::Request::BaseMultipart
|
|
5
|
+
def add_metadata data, opts = {}
|
|
6
|
+
if data.is_a? Hash
|
|
7
|
+
inf = RingCentralSdk::REST::Request::Inflator::ContactInfo.new
|
|
8
|
+
if data.key? :to
|
|
9
|
+
data[:to] = inf.inflate_to_array data[:to]
|
|
90
10
|
end
|
|
91
11
|
end
|
|
92
|
-
end
|
|
93
12
|
|
|
94
|
-
|
|
95
|
-
'post'
|
|
13
|
+
super data, opts
|
|
96
14
|
end
|
|
97
15
|
|
|
98
16
|
def url
|
|
99
17
|
"account/#{@account_id}/extension/#{@extension_id}/fax"
|
|
100
18
|
end
|
|
101
|
-
|
|
102
|
-
def content_type
|
|
103
|
-
@msg.headers.get('Content-Type').to_s
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def body
|
|
107
|
-
@msg.body.to_s
|
|
108
|
-
end
|
|
109
19
|
end
|
|
110
20
|
end
|
|
111
21
|
end
|
|
@@ -15,6 +15,16 @@ module RingCentralSdk
|
|
|
15
15
|
end
|
|
16
16
|
contacts
|
|
17
17
|
end
|
|
18
|
+
|
|
19
|
+
def inflate_to_object(any = nil)
|
|
20
|
+
contact = {}
|
|
21
|
+
if any.is_a?(Hash)
|
|
22
|
+
contact = any
|
|
23
|
+
elsif any.is_a?(String) || any.is_a?(Integer)
|
|
24
|
+
contact = { phoneNumber: any }
|
|
25
|
+
end
|
|
26
|
+
contact
|
|
27
|
+
end
|
|
18
28
|
end
|
|
19
29
|
end
|
|
20
30
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module RingCentralSdk
|
|
2
|
+
module REST
|
|
3
|
+
module Request
|
|
4
|
+
class SMS < RingCentralSdk::REST::Request::BaseMultipart
|
|
5
|
+
def add_metadata data, opts = {}
|
|
6
|
+
if data.is_a? Hash
|
|
7
|
+
inf = RingCentralSdk::REST::Request::Inflator::ContactInfo.new
|
|
8
|
+
if data.key? :to
|
|
9
|
+
data[:to] = inf.inflate_to_array data[:to]
|
|
10
|
+
end
|
|
11
|
+
if data.key? :from
|
|
12
|
+
data[:from] = inf.inflate_to_object data[:from]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
super data, opts
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def url
|
|
20
|
+
"account/#{@account_id}/extension/#{@extension_id}/sms"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
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: 2.0
|
|
4
|
+
version: 2.1.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:
|
|
11
|
+
date: 2017-04-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: dotenv
|
|
@@ -349,10 +349,12 @@ files:
|
|
|
349
349
|
- lib/ringcentral_sdk/rest/messages_retriever.rb
|
|
350
350
|
- lib/ringcentral_sdk/rest/request.rb
|
|
351
351
|
- lib/ringcentral_sdk/rest/request/base.rb
|
|
352
|
+
- lib/ringcentral_sdk/rest/request/base_multipart.rb
|
|
352
353
|
- lib/ringcentral_sdk/rest/request/fax.rb
|
|
353
354
|
- lib/ringcentral_sdk/rest/request/inflator.rb
|
|
354
355
|
- lib/ringcentral_sdk/rest/request/inflator/contact_info.rb
|
|
355
356
|
- lib/ringcentral_sdk/rest/request/simple.rb
|
|
357
|
+
- lib/ringcentral_sdk/rest/request/sms.rb
|
|
356
358
|
- lib/ringcentral_sdk/rest/simple_client.rb
|
|
357
359
|
- lib/ringcentral_sdk/rest/subscription.rb
|
|
358
360
|
- test/test_base.rb
|
|
@@ -384,7 +386,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
384
386
|
version: '0'
|
|
385
387
|
requirements: []
|
|
386
388
|
rubyforge_project:
|
|
387
|
-
rubygems_version: 2.
|
|
389
|
+
rubygems_version: 2.6.8
|
|
388
390
|
signing_key:
|
|
389
391
|
specification_version: 4
|
|
390
392
|
summary: RingCentral SDK - Ruby SDK for the RingCentral Connect Platform API
|