ringcentral-sdk 0.4.0 → 0.5.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/README.md +0 -1
- data/lib/ringcentral.rb +22 -6
- data/ringcentral-sdk.gemspec +1 -1
- data/spec/fax_spec.rb +5 -2
- data/spec/mms_spec.rb +26 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 974a83a81aeb7fc4ebe89f092e37bd2f5263d476
|
4
|
+
data.tar.gz: 42dd0d044334332b3d460b0d119601885b4be65a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2497fce973fec489e9c6146412c57597a38829d84e3e456d9182f1fa18d9e46757672f0f1f8607f4f8b4b5df0ff260014fccc9244d9ec62feb78f77e326e633b
|
7
|
+
data.tar.gz: ba66d11760095aea93a724ad3582cc4a2c6a74412c3c1da163a892af7af7e3713de9d3771cc4059371c765671d4ffd92fd4f22543e1434930b6d17527649f750
|
data/README.md
CHANGED
data/lib/ringcentral.rb
CHANGED
@@ -4,6 +4,17 @@ require 'subscription'
|
|
4
4
|
require 'json'
|
5
5
|
require 'concurrent'
|
6
6
|
require 'faraday'
|
7
|
+
require 'tmpdir'
|
8
|
+
|
9
|
+
class MockResponse
|
10
|
+
def initialize(body)
|
11
|
+
@body = body
|
12
|
+
end
|
13
|
+
|
14
|
+
def body
|
15
|
+
@body
|
16
|
+
end
|
17
|
+
end
|
7
18
|
|
8
19
|
class RingCentral
|
9
20
|
def self.SANDBOX_SERVER
|
@@ -101,15 +112,20 @@ class RingCentral
|
|
101
112
|
end
|
102
113
|
|
103
114
|
def post(endpoint, payload: nil, params: {}, files: nil)
|
115
|
+
if files != nil && files.size > 0 # send fax
|
116
|
+
cmd = %{curl --header "Accept: application/json" --header "Authorization: Bearer #{@token['access_token']}"}
|
117
|
+
File.write("#{Dir.tmpdir()}/request.json", JSON.generate(payload))
|
118
|
+
cmd += %{ -F "request=@#{Dir.tmpdir()}/request.json;type=application/json"}
|
119
|
+
files.each do |file|
|
120
|
+
cmd += %{ -F "attachment=@#{file}"}
|
121
|
+
end
|
122
|
+
cmd += %{ "#{Addressable::URI.parse(@server) + endpoint}"}
|
123
|
+
return MockResponse.new(`#{cmd}`)
|
124
|
+
end
|
104
125
|
@faraday.post do |req|
|
105
126
|
req.url endpoint
|
106
127
|
req.params = params
|
107
|
-
if
|
108
|
-
req.headers = headers
|
109
|
-
req.body = (payload || {}).merge({
|
110
|
-
attachment: Faraday::UploadIO.new(files[0][:path], files[0][:content_type])
|
111
|
-
})
|
112
|
-
elsif payload != nil && @token != nil
|
128
|
+
if payload != nil && @token != nil
|
113
129
|
req.headers = headers.merge({ 'Content-Type': 'application/json' })
|
114
130
|
req.body = payload.to_json
|
115
131
|
else
|
data/ringcentral-sdk.gemspec
CHANGED
data/spec/fax_spec.rb
CHANGED
@@ -9,8 +9,11 @@ RSpec.describe 'Fax' do
|
|
9
9
|
rc.authorize(username: ENV['username'], extension: ENV['extension'], password: ENV['password'])
|
10
10
|
|
11
11
|
r = rc.post('/restapi/v1.0/account/~/extension/~/fax',
|
12
|
-
payload: { to: ENV['receiver'] },
|
13
|
-
files:[
|
12
|
+
payload: { to: [{ phoneNumber: ENV['receiver'] }] },
|
13
|
+
files: [
|
14
|
+
'spec/test.txt;type=text/plain',
|
15
|
+
'spec/test.png;type=image/png'
|
16
|
+
]
|
14
17
|
)
|
15
18
|
expect(r).not_to be_nil
|
16
19
|
message = JSON.parse(r.body)
|
data/spec/mms_spec.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'dotenv'
|
2
|
+
require 'ringcentral'
|
3
|
+
|
4
|
+
RSpec.describe 'MMS' do
|
5
|
+
describe 'send MMS' do
|
6
|
+
it 'should send an MMS' do
|
7
|
+
Dotenv.load
|
8
|
+
rc = RingCentral.new(ENV['appKey'], ENV['appSecret'], ENV['server'])
|
9
|
+
rc.authorize(username: ENV['username'], extension: ENV['extension'], password: ENV['password'])
|
10
|
+
|
11
|
+
r = rc.post('/restapi/v1.0/account/~/extension/~/sms',
|
12
|
+
payload: {
|
13
|
+
to: [{ phoneNumber: ENV['receiver'] }],
|
14
|
+
from: { phoneNumber: ENV['username'] },
|
15
|
+
text: 'hello world'
|
16
|
+
},
|
17
|
+
files: [
|
18
|
+
'spec/test.png;type=image/png'
|
19
|
+
]
|
20
|
+
)
|
21
|
+
expect(r).not_to be_nil
|
22
|
+
message = JSON.parse(r.body)
|
23
|
+
expect('SMS').to eq(message['type'])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
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: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Liu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/subscription.rb
|
103
103
|
- ringcentral-sdk.gemspec
|
104
104
|
- spec/fax_spec.rb
|
105
|
+
- spec/mms_spec.rb
|
105
106
|
- spec/ringcentral_spec.rb
|
106
107
|
- spec/spec_helper.rb
|
107
108
|
- spec/subscription_spec.rb
|
@@ -131,6 +132,7 @@ specification_version: 4
|
|
131
132
|
summary: RingCentral Ruby SDK.
|
132
133
|
test_files:
|
133
134
|
- spec/fax_spec.rb
|
135
|
+
- spec/mms_spec.rb
|
134
136
|
- spec/ringcentral_spec.rb
|
135
137
|
- spec/spec_helper.rb
|
136
138
|
- spec/subscription_spec.rb
|