zoom_rb 0.11.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +55 -0
- data/Gemfile.lock +6 -6
- data/README.md +0 -4
- data/lib/zoom/actions/account.rb +18 -51
- data/lib/zoom/actions/billing.rb +30 -27
- data/lib/zoom/actions/dashboard.rb +11 -22
- data/lib/zoom/actions/groups.rb +11 -9
- data/lib/zoom/actions/im/chat.rb +11 -24
- data/lib/zoom/actions/meeting.rb +34 -67
- data/lib/zoom/actions/phone.rb +5 -17
- data/lib/zoom/actions/recording.rb +8 -26
- data/lib/zoom/actions/report.rb +10 -20
- data/lib/zoom/actions/roles.rb +11 -28
- data/lib/zoom/actions/sip_audio.rb +16 -57
- data/lib/zoom/actions/token.rb +21 -24
- data/lib/zoom/actions/user.rb +65 -123
- data/lib/zoom/actions/webinar.rb +37 -77
- data/lib/zoom/actions.rb +68 -0
- data/lib/zoom/client.rb +10 -4
- data/lib/zoom/clients/oauth.rb +9 -3
- data/lib/zoom/utils.rb +10 -7
- data/lib/zoom/version.rb +1 -1
- data/lib/zoom_rb.rb +1 -0
- data/spec/fixtures/error/admin_cannot_activated.json +4 -0
- data/spec/fixtures/error/group_not_exist.json +4 -0
- data/spec/fixtures/error/not_found_administrator.json +4 -0
- data/spec/fixtures/groups/create.json +5 -0
- data/spec/fixtures/groups/update.json +0 -0
- data/spec/fixtures/token/revoke_token.json +3 -0
- data/spec/fixtures/user/update_email.json +0 -0
- data/spec/fixtures/user/update_status.json +0 -0
- data/spec/lib/zoom/actions/groups/create_spec.rb +96 -1
- data/spec/lib/zoom/actions/groups/update_spec.rb +59 -0
- data/spec/lib/zoom/actions/meeting/create_spec.rb +1 -1
- data/spec/lib/zoom/actions/token/access_token_spec.rb +34 -8
- data/spec/lib/zoom/actions/token/data_compliance_spec.rb +6 -1
- data/spec/lib/zoom/actions/token/refresh_token_spec.rb +33 -8
- data/spec/lib/zoom/actions/token/revoke_token_spec.rb +52 -0
- data/spec/lib/zoom/actions/user/create_spec.rb +18 -46
- data/spec/lib/zoom/actions/user/update_email_spec.rb +59 -0
- data/spec/lib/zoom/actions/user/update_status_spec.rb +59 -0
- data/spec/lib/zoom/actions_spec.rb +117 -0
- data/spec/lib/zoom/utils_spec.rb +1 -1
- metadata +33 -6
data/lib/zoom/client.rb
CHANGED
@@ -35,14 +35,20 @@ module Zoom
|
|
35
35
|
|
36
36
|
def oauth_request_headers
|
37
37
|
{
|
38
|
-
'Authorization' => "Basic #{auth_token}"
|
39
|
-
|
38
|
+
'Authorization' => "Basic #{auth_token}",
|
39
|
+
'Accept' => 'application/json',
|
40
|
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
41
|
+
}
|
40
42
|
end
|
41
43
|
|
42
|
-
def
|
44
|
+
def bearer_authorization_header
|
43
45
|
{
|
44
46
|
'Authorization' => "Bearer #{access_token}"
|
45
|
-
}
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def request_headers
|
51
|
+
bearer_authorization_header.merge(headers)
|
46
52
|
end
|
47
53
|
|
48
54
|
def auth_token
|
data/lib/zoom/clients/oauth.rb
CHANGED
@@ -13,7 +13,7 @@ module Zoom
|
|
13
13
|
# Returns (access_token, refresh_token)
|
14
14
|
#
|
15
15
|
def initialize(config)
|
16
|
-
Zoom::Params.new(config).permit( %i[auth_token auth_code redirect_uri access_token refresh_token timeout])
|
16
|
+
Zoom::Params.new(config).permit( %i[auth_token auth_code redirect_uri access_token refresh_token timeout code_verifier])
|
17
17
|
Zoom::Params.new(config).require_one_of(%i[access_token refresh_token auth_code])
|
18
18
|
if (config.keys & [:auth_code, :redirect_uri]).any?
|
19
19
|
Zoom::Params.new(config).require( %i[auth_code redirect_uri])
|
@@ -28,13 +28,19 @@ module Zoom
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def refresh
|
31
|
-
response = refresh_tokens(refresh_token: @refresh_token)
|
31
|
+
response = refresh_tokens(grant_type: 'refresh_token', refresh_token: @refresh_token)
|
32
32
|
set_tokens(response)
|
33
33
|
response
|
34
34
|
end
|
35
35
|
|
36
36
|
def oauth
|
37
|
-
response = access_tokens(
|
37
|
+
response = access_tokens(
|
38
|
+
grant_type: 'authorization_code',
|
39
|
+
auth_code: @auth_code,
|
40
|
+
redirect_uri: @redirect_uri,
|
41
|
+
code_verifier: @code_verifier
|
42
|
+
)
|
43
|
+
|
38
44
|
set_tokens(response)
|
39
45
|
response
|
40
46
|
end
|
data/lib/zoom/utils.rb
CHANGED
@@ -32,7 +32,8 @@ module Zoom
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def extract_options!(array)
|
35
|
-
array.last.is_a?(::Hash) ? array.pop : {}
|
35
|
+
params = array.last.is_a?(::Hash) ? array.pop : {}
|
36
|
+
process_datetime_params!(params)
|
36
37
|
end
|
37
38
|
|
38
39
|
def validate_password(password)
|
@@ -40,14 +41,16 @@ module Zoom
|
|
40
41
|
raise(Error , 'Invalid Password') unless password[password_regex].nil?
|
41
42
|
end
|
42
43
|
|
43
|
-
def process_datetime_params!(params
|
44
|
-
params
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
def process_datetime_params!(params)
|
45
|
+
params.each do |key, value|
|
46
|
+
case key
|
47
|
+
when Symbol, String
|
48
|
+
params[key] = value.is_a?(Time) ? value.strftime('%FT%TZ') : value
|
49
|
+
when Hash
|
50
|
+
process_datetime_params!(params[key])
|
48
51
|
end
|
49
52
|
end
|
50
|
-
|
53
|
+
params
|
51
54
|
end
|
52
55
|
end
|
53
56
|
end
|
data/lib/zoom/version.rb
CHANGED
data/lib/zoom_rb.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
@@ -1,3 +1,98 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'spec_helper'
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Zoom::Actions::Groups do
|
6
|
+
let(:zc) { zoom_client }
|
7
|
+
let(:args) { { name: 'Zoom Group Name' } }
|
8
|
+
let(:response) { zc.group_create(args) }
|
9
|
+
|
10
|
+
describe '#group_create action' do
|
11
|
+
context 'with 201 response' do
|
12
|
+
before :each do
|
13
|
+
stub_request(
|
14
|
+
:post,
|
15
|
+
zoom_url("/groups")
|
16
|
+
).to_return(
|
17
|
+
status: 201,
|
18
|
+
body: json_response('groups','create'),
|
19
|
+
headers: { 'Content-Type' => 'application/json' }
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns a hash' do
|
24
|
+
expect(response).to be_kind_of(Hash)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns the set params' do
|
28
|
+
expect(response['name']).to eq(args[:name])
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns 'start_url' and 'join_url'" do
|
32
|
+
expect(response['name']).to_not be_nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'with 409 response' do
|
37
|
+
before :each do
|
38
|
+
stub_request(
|
39
|
+
:post,
|
40
|
+
zoom_url("/groups")
|
41
|
+
).to_return(status: 409,
|
42
|
+
body: '{ "code": 409, "message": "Group name Zoom Group Name is already in use." }',
|
43
|
+
headers: { 'Content-Type' => 'application/json' })
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'raises an error' do
|
47
|
+
expect { response }.to raise_error(Zoom::Error)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'with 429 response' do
|
52
|
+
before :each do
|
53
|
+
stub_request(
|
54
|
+
:post,
|
55
|
+
zoom_url("/groups")
|
56
|
+
).to_return(status: 429,
|
57
|
+
body: '{ "code": 429, "message": "You have exceeded the daily rate limit (1) of Create a Group API request for this account. This limit resets at GMT 00:00:00." }',
|
58
|
+
headers: { 'Content-Type' => 'application/json' })
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'raises an error' do
|
62
|
+
expect { response }.to raise_error(Zoom::Error)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'with 300 response' do
|
67
|
+
before :each do
|
68
|
+
stub_request(
|
69
|
+
:post,
|
70
|
+
zoom_url("/groups")
|
71
|
+
).to_return(status: 300,
|
72
|
+
body: '{ "code": 300, "message": "Missing field: name." }',
|
73
|
+
headers: { 'Content-Type' => 'application/json' })
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'raises an error' do
|
77
|
+
expect { response }.to raise_error(Zoom::Error)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'with 404 response' do
|
82
|
+
before :each do
|
83
|
+
stub_request(
|
84
|
+
:post,
|
85
|
+
zoom_url("/groups")
|
86
|
+
).to_return(
|
87
|
+
status: 404,
|
88
|
+
body: json_response('error', 'group_not_exist'),
|
89
|
+
headers: { 'Content-Type' => 'application/json' }
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'raises an error' do
|
94
|
+
expect { response }.to raise_error(Zoom::Error)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Zoom::Actions::Groups do
|
6
|
+
let(:zc) { zoom_client }
|
7
|
+
let(:args) { { group_id: '555' } }
|
8
|
+
|
9
|
+
describe '#group_update' do
|
10
|
+
context 'with a valid response' do
|
11
|
+
before :each do
|
12
|
+
stub_request(
|
13
|
+
:patch,
|
14
|
+
zoom_url("/groups/#{args[:group_id]}")
|
15
|
+
).to_return(status: 204,
|
16
|
+
body: json_response('groups', 'update'),
|
17
|
+
headers: { 'Content-Type' => 'application/json' })
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'requires id param' do
|
21
|
+
expect { zc.group_update(filter_key(args, :group_id)) }.to raise_error(Zoom::ParameterMissing, [:group_id].to_s)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns the http status code as a number' do
|
25
|
+
expect(zc.group_update(args)).to eql(204)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with a 404 response' do
|
30
|
+
before :each do
|
31
|
+
stub_request(
|
32
|
+
:patch,
|
33
|
+
zoom_url("/groups/#{args[:group_id]}")
|
34
|
+
).to_return(status: 404,
|
35
|
+
body: json_response('error', 'group_not_exist'),
|
36
|
+
headers: { 'Content-Type' => 'application/json' })
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'raises an error' do
|
40
|
+
expect { zc.group_update(args) }.to raise_error(Zoom::Error)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'with 409 response' do
|
45
|
+
before :each do
|
46
|
+
stub_request(
|
47
|
+
:patch,
|
48
|
+
zoom_url("/groups/#{args[:group_id]}")
|
49
|
+
).to_return(status: 409,
|
50
|
+
body: '{ "code": 409, "message": "Group name Zoom Group Name is already in use." }',
|
51
|
+
headers: { 'Content-Type' => 'application/json' })
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'raises an error' do
|
55
|
+
expect { zc.group_update(args) }.to raise_error(Zoom::Error)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Zoom::Actions::Meeting do
|
6
6
|
let(:zc) { zoom_client }
|
7
|
-
let(:args) { { topic: 'Zoom Meeting Topic', start_time: '2020-05-05T21:00:00Z', timezone: 'America/New_York', duration: 30, type: 2, user_id: 'r55v2FgSTVmDmVot18DX3A' } }
|
7
|
+
let(:args) { { topic: 'Zoom Meeting Topic', start_time: '2020-05-05T21:00:00Z', timezone: 'America/New_York', duration: 30, type: 2, user_id: 'r55v2FgSTVmDmVot18DX3A', template_id: 'template_id' } }
|
8
8
|
let(:response) { zc.meeting_create(args) }
|
9
9
|
|
10
10
|
describe '#meeting_create action' do
|
@@ -4,23 +4,49 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Zoom::Actions::Token do
|
6
6
|
let(:zc) { oauth_client }
|
7
|
-
let(:args) { { auth_code: 'xxx', redirect_uri: 'http://localhost:3000' } }
|
7
|
+
let(:args) { { grant_type: 'authorization_code', auth_code: 'xxx', redirect_uri: 'http://localhost:3000', code_verifier: 'xxx' } }
|
8
|
+
let(:body) { { grant_type: 'authorization_code', redirect_uri: 'http://localhost:3000', code_verifier: 'xxx', code: 'xxx' } }
|
8
9
|
|
9
10
|
describe '#access_tokens action' do
|
11
|
+
let(:path) { '/oauth/token' }
|
12
|
+
|
13
|
+
let(:params) do
|
14
|
+
{
|
15
|
+
base_uri: 'https://zoom.us/',
|
16
|
+
body: URI.encode_www_form(body.to_a),
|
17
|
+
headers: {
|
18
|
+
'Accept'=>'application/json',
|
19
|
+
'Authorization'=>'Basic eHh4Onh4eA==',
|
20
|
+
'Content-Type'=>'application/x-www-form-urlencoded'
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
10
25
|
before :each do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
26
|
+
Zoom.configure do |config|
|
27
|
+
config.api_key = 'xxx'
|
28
|
+
config.api_secret = 'xxx'
|
29
|
+
end
|
30
|
+
|
31
|
+
allow(Zoom::Utils).to receive(:parse_response).and_return(code: 200)
|
32
|
+
allow(Zoom::Client::OAuth).to(
|
33
|
+
receive(:post).with(path, params)
|
34
|
+
.and_return(body: json_response('token', 'access_token'),
|
35
|
+
headers: { 'Content-Type' => 'application/json' })
|
36
|
+
)
|
16
37
|
end
|
17
38
|
|
18
|
-
it "
|
19
|
-
expect { zc.access_tokens }.to raise_error(Zoom::ParameterMissing, [:
|
39
|
+
it "raises an error when args missing" do
|
40
|
+
expect { zc.access_tokens }.to raise_error(Zoom::ParameterMissing, [:grant_type, :code, :redirect_uri].to_s)
|
20
41
|
end
|
21
42
|
|
22
43
|
it 'returns a hash' do
|
23
44
|
expect(zc.access_tokens(args)).to be_kind_of(Hash)
|
24
45
|
end
|
46
|
+
|
47
|
+
it 'passes args in the body and sends x-www-form-urlencoded header' do
|
48
|
+
zc.access_tokens(args)
|
49
|
+
expect(Zoom::Client::OAuth).to have_received(:post).with(path, params)
|
50
|
+
end
|
25
51
|
end
|
26
52
|
end
|
@@ -23,6 +23,11 @@ describe Zoom::Actions::Token do
|
|
23
23
|
|
24
24
|
describe '#data_compliance action' do
|
25
25
|
before :each do
|
26
|
+
Zoom.configure do |config|
|
27
|
+
config.api_key = 'xxx'
|
28
|
+
config.api_secret = 'xxx'
|
29
|
+
end
|
30
|
+
|
26
31
|
stub_request(
|
27
32
|
:post,
|
28
33
|
zoom_auth_url('oauth/data/compliance')
|
@@ -30,7 +35,7 @@ describe Zoom::Actions::Token do
|
|
30
35
|
headers: { 'Content-Type' => 'application/json' })
|
31
36
|
end
|
32
37
|
|
33
|
-
it "
|
38
|
+
it "raises an error when args missing" do
|
34
39
|
expect { zc.data_compliance }.to raise_error(Zoom::ParameterMissing, [:client_id, :user_id, :account_id, :deauthorization_event_received, :compliance_completed].to_s)
|
35
40
|
end
|
36
41
|
|
@@ -4,23 +4,48 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Zoom::Actions::Token do
|
6
6
|
let(:zc) { oauth_client }
|
7
|
-
let(:args) { { refresh_token: 'xxx' } }
|
7
|
+
let(:args) { { grant_type: 'refresh_token', refresh_token: 'xxx' } }
|
8
8
|
|
9
9
|
describe '#refresh_tokens action' do
|
10
|
+
let(:path) { '/oauth/token' }
|
11
|
+
|
12
|
+
let(:params) do
|
13
|
+
{
|
14
|
+
base_uri: 'https://zoom.us/',
|
15
|
+
body: URI.encode_www_form(args.to_a),
|
16
|
+
headers: {
|
17
|
+
'Accept'=>'application/json',
|
18
|
+
'Authorization'=>'Basic eHh4Onh4eA==',
|
19
|
+
'Content-Type'=>'application/x-www-form-urlencoded'
|
20
|
+
}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
10
24
|
before :each do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
25
|
+
Zoom.configure do |config|
|
26
|
+
config.api_key = 'xxx'
|
27
|
+
config.api_secret = 'xxx'
|
28
|
+
end
|
29
|
+
|
30
|
+
allow(Zoom::Utils).to receive(:parse_response).and_return(code: 200)
|
31
|
+
allow(Zoom::Client::OAuth).to(
|
32
|
+
receive(:post).with(path, params)
|
33
|
+
.and_return(body: json_response('token', 'access_token'),
|
34
|
+
headers: { 'Content-Type' => 'application/json' })
|
35
|
+
)
|
16
36
|
end
|
17
37
|
|
18
|
-
it "
|
19
|
-
expect { zc.refresh_tokens }.to raise_error(Zoom::ParameterMissing, [:refresh_token].to_s)
|
38
|
+
it "raises an error when args missing" do
|
39
|
+
expect { zc.refresh_tokens }.to raise_error(Zoom::ParameterMissing, [:grant_type, :refresh_token].to_s)
|
20
40
|
end
|
21
41
|
|
22
42
|
it 'returns a hash' do
|
23
43
|
expect(zc.refresh_tokens(args)).to be_kind_of(Hash)
|
24
44
|
end
|
45
|
+
|
46
|
+
it 'passes args in the body and sends x-www-form-urlencoded header' do
|
47
|
+
zc.refresh_tokens(args)
|
48
|
+
expect(Zoom::Client::OAuth).to have_received(:post).with(path, params)
|
49
|
+
end
|
25
50
|
end
|
26
51
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Zoom::Actions::Token do
|
6
|
+
let(:zc) { oauth_client }
|
7
|
+
let(:args) { { access_token: 'xxx' } }
|
8
|
+
let(:body) { { token: 'xxx' } }
|
9
|
+
|
10
|
+
describe '#revoke_tokens action' do
|
11
|
+
let(:path) { '/oauth/revoke' }
|
12
|
+
|
13
|
+
let(:params) do
|
14
|
+
{
|
15
|
+
base_uri: 'https://zoom.us/',
|
16
|
+
body: URI.encode_www_form(body.to_a),
|
17
|
+
headers: {
|
18
|
+
'Accept'=>'application/json',
|
19
|
+
'Authorization'=>'Basic eHh4Onh4eA==',
|
20
|
+
'Content-Type'=>'application/x-www-form-urlencoded'
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
before :each do
|
26
|
+
Zoom.configure do |config|
|
27
|
+
config.api_key = 'xxx'
|
28
|
+
config.api_secret = 'xxx'
|
29
|
+
end
|
30
|
+
|
31
|
+
allow(Zoom::Utils).to receive(:parse_response).and_return(code: 200)
|
32
|
+
allow(Zoom::Client::OAuth).to(
|
33
|
+
receive(:post).with(path, params)
|
34
|
+
.and_return(body: json_response('token', 'access_token'),
|
35
|
+
headers: { 'Content-Type' => 'application/json' })
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "raises an error when args missing" do
|
40
|
+
expect { zc.revoke_tokens }.to raise_error(Zoom::ParameterMissing, [:token].to_s)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns a hash' do
|
44
|
+
expect(zc.revoke_tokens(args)).to be_kind_of(Hash)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'passes args in the body and sends x-www-form-urlencoded header' do
|
48
|
+
zc.revoke_tokens(args)
|
49
|
+
expect(Zoom::Client::OAuth).to have_received(:post).with(path, params)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -5,12 +5,16 @@ require 'spec_helper'
|
|
5
5
|
describe Zoom::Actions::User do
|
6
6
|
let(:zc) { zoom_client }
|
7
7
|
let(:args) do
|
8
|
-
{
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
{
|
9
|
+
action: 'create',
|
10
|
+
user_info: {
|
11
|
+
email: 'foo@bar.com',
|
12
|
+
type: 1,
|
13
|
+
first_name: 'Zoomie',
|
14
|
+
last_name: 'Userton',
|
15
|
+
password: 'testerino'
|
16
|
+
}
|
17
|
+
}
|
14
18
|
end
|
15
19
|
|
16
20
|
describe '#user_create' do
|
@@ -28,46 +32,14 @@ describe Zoom::Actions::User do
|
|
28
32
|
expect { zc.user_create(filter_key(args, :action)) }.to raise_error(Zoom::ParameterMissing, [:action].to_s)
|
29
33
|
end
|
30
34
|
|
31
|
-
it 'does not raise an error when action is create' do
|
32
|
-
args[:action] = 'create'
|
33
|
-
expect { zc.user_create(args) }.not_to raise_error
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'does not raise an error when action is custCreate' do
|
37
|
-
args[:action] = 'custCreate'
|
38
|
-
expect { zc.user_create(args) }.not_to raise_error
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'does not raise an error when action is autoCreate' do
|
42
|
-
args[:action] = 'autoCreate'
|
43
|
-
expect { zc.user_create(args) }.not_to raise_error
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'does not raise an error when action is ssoCreate' do
|
47
|
-
args[:action] = 'ssoCreate'
|
48
|
-
expect { zc.user_create(args) }.not_to raise_error
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'requires valid action' do
|
52
|
-
args[:action] = 'baz'
|
53
|
-
expect { zc.user_create(args) }.to raise_error(Zoom::ParameterValueNotPermitted, "#{:action.to_s}: #{args[:action].to_s}")
|
54
|
-
end
|
55
|
-
|
56
35
|
it 'requires email param' do
|
57
|
-
|
36
|
+
args[:user_info].delete(:email)
|
37
|
+
expect { zc.user_create(args) }.to raise_error(Zoom::ParameterMissing, [{user_info: [:email]}].to_s)
|
58
38
|
end
|
59
39
|
|
60
40
|
it 'requires type param' do
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
it 'does not require password param when action is not autoCreate' do
|
65
|
-
expect { zc.user_create(filter_key(args, :password)) }.not_to raise_error
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'requires password param when action is autoCreate' do
|
69
|
-
args[:action] = 'autoCreate'
|
70
|
-
expect { zc.user_create(filter_key(args, :password)) }.to raise_error(Zoom::ParameterMissing, [:password].to_s)
|
41
|
+
args[:user_info].delete(:type)
|
42
|
+
expect { zc.user_create(args) }.to raise_error(Zoom::ParameterMissing, [{user_info: [:type]}].to_s)
|
71
43
|
end
|
72
44
|
|
73
45
|
it 'returns a hash' do
|
@@ -77,10 +49,10 @@ describe Zoom::Actions::User do
|
|
77
49
|
it 'returns same params' do
|
78
50
|
res = zc.user_create(args)
|
79
51
|
|
80
|
-
expect(res['email']).to eq(args[:email])
|
81
|
-
expect(res['first_name']).to eq(args[:first_name])
|
82
|
-
expect(res['last_name']).to eq(args[:last_name])
|
83
|
-
expect(res['type']).to eq(args[:type])
|
52
|
+
expect(res['email']).to eq(args[:user_info][:email])
|
53
|
+
expect(res['first_name']).to eq(args[:user_info][:first_name])
|
54
|
+
expect(res['last_name']).to eq(args[:user_info][:last_name])
|
55
|
+
expect(res['type']).to eq(args[:user_info][:type])
|
84
56
|
end
|
85
57
|
end
|
86
58
|
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Zoom::Actions::User do
|
6
|
+
let(:zc) { zoom_client }
|
7
|
+
let(:args) { { id: 'eIimBAXqSrWOcB_EOIXTog', email: 'new.email@example.com' } }
|
8
|
+
|
9
|
+
describe '#user_email_update' do
|
10
|
+
context 'with a valid response' do
|
11
|
+
before :each do
|
12
|
+
stub_request(
|
13
|
+
:patch,
|
14
|
+
zoom_url("/users/#{args[:id]}/email")
|
15
|
+
).to_return(status: 204,
|
16
|
+
body: json_response('user', 'update_email'),
|
17
|
+
headers: { 'Content-Type' => 'application/json' })
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'requires id param' do
|
21
|
+
expect { zc.user_email_update(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns the http status code as a number' do
|
25
|
+
expect(zc.user_email_update(args)).to eql(204)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with a 400 response' do
|
30
|
+
before :each do
|
31
|
+
stub_request(
|
32
|
+
:patch,
|
33
|
+
zoom_url("/users/#{args[:id]}/email")
|
34
|
+
).to_return(status: 400,
|
35
|
+
body: json_response('error', 'not_found_administrator'),
|
36
|
+
headers: { 'Content-Type' => 'application/json' })
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'raises an error' do
|
40
|
+
expect { zc.user_email_update(args) }.to raise_error(Zoom::Error)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'with a 404 response' do
|
45
|
+
before :each do
|
46
|
+
stub_request(
|
47
|
+
:patch,
|
48
|
+
zoom_url("/users/#{args[:id]}/email")
|
49
|
+
).to_return(status: 404,
|
50
|
+
body: json_response('error', 'user_not_exist'),
|
51
|
+
headers: { 'Content-Type' => 'application/json' })
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'raises an error' do
|
55
|
+
expect { zc.user_email_update(args) }.to raise_error(Zoom::Error)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|