zoom_rb 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.gitignore +2 -1
- data/CHANGELOG.md +53 -0
- data/Gemfile.lock +85 -51
- data/Makefile +1 -1
- data/README.md +31 -3
- data/lib/zoom/actions/account.rb +18 -76
- data/lib/zoom/actions/billing.rb +41 -0
- data/lib/zoom/actions/dashboard.rb +22 -0
- data/lib/zoom/actions/groups.rb +19 -0
- data/lib/zoom/actions/im/chat.rb +13 -14
- data/lib/zoom/actions/meeting.rb +38 -63
- data/lib/zoom/actions/phone.rb +15 -0
- data/lib/zoom/actions/recording.rb +13 -22
- data/lib/zoom/actions/report.rb +8 -43
- data/lib/zoom/actions/roles.rb +24 -0
- data/lib/zoom/actions/sip_audio.rb +34 -0
- data/lib/zoom/actions/token.rb +26 -0
- data/lib/zoom/actions/user.rb +66 -139
- data/lib/zoom/actions/webinar.rb +43 -84
- data/lib/zoom/actions.rb +49 -0
- data/lib/zoom/client.rb +27 -16
- data/lib/zoom/clients/jwt.rb +22 -0
- data/lib/zoom/clients/oauth.rb +60 -0
- data/lib/zoom/constants/account/options/pay_modes.rb +12 -0
- data/lib/zoom/constants/account/settings/permitted_settings.rb +125 -0
- data/lib/zoom/constants/constants.rb +35 -0
- data/lib/zoom/constants/meeting/approval_types.rb +11 -0
- data/lib/zoom/constants/meeting/audio_type.rb +11 -0
- data/lib/zoom/constants/meeting/auto_recording.rb +11 -0
- data/lib/zoom/constants/meeting/registration_types.rb +11 -0
- data/lib/zoom/constants/meeting/types.rb +12 -0
- data/lib/zoom/constants/recurrence/monthly_weeks.rb +13 -0
- data/lib/zoom/constants/recurrence/types.rb +11 -0
- data/lib/zoom/constants/recurrence/weekly_days.rb +15 -0
- data/lib/zoom/constants/user/create_types.rb +12 -0
- data/lib/zoom/constants/user/types.rb +11 -0
- data/lib/zoom/constants/webinar/approval_types.rb +11 -0
- data/lib/zoom/constants/webinar/audio_type.rb +11 -0
- data/lib/zoom/constants/webinar/auto_recording.rb +11 -0
- data/lib/zoom/constants/webinar/registration_types.rb +11 -0
- data/lib/zoom/constants/webinar/types.rb +11 -0
- data/lib/zoom/error.rb +9 -1
- data/lib/zoom/params.rb +51 -12
- data/lib/zoom/utils.rb +22 -38
- data/lib/zoom/version.rb +2 -2
- data/lib/{zoom.rb → zoom_rb.rb} +12 -5
- data/spec/fixtures/account/create.json +6 -0
- data/spec/{lib/zoom/actions/report/hosts_report_spec.rb → fixtures/account/delete.json} +0 -0
- data/spec/fixtures/account/get.json +13 -0
- data/spec/fixtures/account/list.json +18 -0
- data/spec/fixtures/account/managed_domains.json +7 -0
- data/spec/fixtures/account/options_update.json +7 -0
- data/spec/fixtures/account/settings_get.json +120 -0
- data/spec/{lib/zoom/actions/report/meeting_polls_report_spec.rb → fixtures/account/settings_update.json} +0 -0
- data/spec/fixtures/account/trusted_domains.json +3 -0
- data/spec/fixtures/billing/get.json +12 -0
- data/spec/fixtures/billing/plans_list.json +44 -0
- data/spec/fixtures/billing/plans_subscribe.json +30 -0
- data/spec/fixtures/billing/plans_usage.json +30 -0
- data/spec/{lib/zoom/actions/report/meetings_report_spec.rb → fixtures/billing/update.json} +0 -0
- data/spec/fixtures/chat/channels/get.json +5 -0
- data/spec/fixtures/chat/users/channels/list.json +17 -0
- data/spec/fixtures/dashboard/crc.json +104 -0
- data/spec/fixtures/dashboard/meeting/detail.json +20 -0
- data/spec/fixtures/dashboard/meeting/participants.json +56 -0
- data/spec/fixtures/{metrics_meetings.json → dashboard/meetings.json} +1 -2
- data/spec/fixtures/error/admin_cannot_activated.json +4 -0
- data/spec/fixtures/error/channel_not_found.json +4 -0
- data/spec/fixtures/error/group_does_not_exist.json +4 -0
- data/spec/fixtures/error/group_not_belong_to_account.json +4 -0
- data/spec/fixtures/error/group_not_exist.json +4 -0
- data/spec/fixtures/error/meeting_not_exist.json +4 -0
- data/spec/fixtures/error/next_page_token_invalid.json +4 -0
- data/spec/fixtures/error/not_found_administrator.json +4 -0
- data/spec/fixtures/error/unauthorized_request.json +4 -0
- data/spec/fixtures/error/user_not_exist.json +1 -1
- data/spec/fixtures/groups/create.json +5 -0
- data/spec/fixtures/groups/get.json +5 -0
- data/spec/fixtures/groups/list.json +15 -0
- data/spec/{lib/zoom/actions/report/telephone_report_spec.rb → fixtures/groups/update.json} +0 -0
- data/spec/fixtures/meeting/add_registrant.json +7 -0
- data/spec/fixtures/meeting/create.json +31 -16
- data/spec/fixtures/meeting/get.json +43 -33
- data/spec/fixtures/meeting/invitation.json +3 -0
- data/spec/fixtures/meeting/live_stream/errors/meeting_not_found.json +4 -0
- data/spec/fixtures/meeting/live_stream/errors/missing_field.json +10 -0
- data/spec/fixtures/{recording_get.json → recording/get.json} +17 -6
- data/spec/fixtures/recording/list.json +53 -0
- data/spec/fixtures/recording/settings/get.json +7 -0
- data/spec/fixtures/report/meeting/participants.json +17 -0
- data/spec/fixtures/report/meeting.json +19 -0
- data/spec/fixtures/roles/assign.json +4 -0
- data/spec/fixtures/roles/create.json +9 -0
- data/spec/fixtures/roles/get.json +11 -0
- data/spec/fixtures/roles/list.json +29 -0
- data/spec/fixtures/roles/members.json +15 -0
- data/spec/fixtures/sip_audio/sip_trunks_get.json +19 -0
- data/spec/fixtures/sip_audio/sip_trunks_internal_callout_countries_add.json +10 -0
- data/spec/fixtures/sip_audio/sip_trunks_internal_callout_country_list.json +15 -0
- data/spec/fixtures/sip_audio/sip_trunks_internal_numbers_add.json +14 -0
- data/spec/fixtures/sip_audio/sip_trunks_internal_numbers_list.json +16 -0
- data/spec/fixtures/sip_audio/sip_trunks_numbers_assign.json +7 -0
- data/spec/fixtures/sip_audio/sip_trunks_numbers_list.json +9 -0
- data/spec/fixtures/token/access_token.json +7 -0
- data/spec/fixtures/token/data_compliance.json +8 -0
- data/spec/fixtures/token/refresh_token.json +7 -0
- data/spec/fixtures/user/assistant/create.json +4 -0
- data/spec/fixtures/user/assistant/list.json +8 -0
- data/spec/fixtures/user/email_check.json +3 -0
- data/spec/fixtures/user/get.json +35 -21
- data/spec/fixtures/user/list.json +17 -13
- data/spec/fixtures/user/permissions.json +65 -0
- data/spec/fixtures/user/recording/list.json +50 -0
- data/spec/fixtures/user/scheduler/list.json +12 -0
- data/spec/fixtures/user/settings_get.json +74 -0
- data/spec/fixtures/user/token.json +3 -0
- data/spec/{lib/zoom/actions/report/webinar_details_report_spec.rb → fixtures/user/update_email.json} +0 -0
- data/spec/{lib/zoom/actions/report/webinar_polls_report_spec.rb → fixtures/user/update_password.json} +0 -0
- data/spec/{lib/zoom/actions/report/webinar_qa_report_spec.rb → fixtures/user/update_status.json} +0 -0
- data/spec/fixtures/user/vanity_name.json +3 -0
- data/spec/fixtures/webinar/panelist_list.json +12 -0
- data/spec/fixtures/webinar/past_webinar_list.json +8 -0
- data/spec/fixtures/webinar/poll_get.json +13 -0
- data/spec/fixtures/webinar/polls_list.json +16 -0
- data/spec/fixtures/webinar/registrant/get.json +25 -0
- data/spec/lib/zoom/actions/account/create_spec.rb +68 -0
- data/spec/lib/zoom/actions/account/delete_spec.rb +44 -0
- data/spec/lib/zoom/actions/account/get_locked_settings_spec.rb +43 -0
- data/spec/lib/zoom/actions/account/get_spec.rb +43 -0
- data/spec/lib/zoom/actions/account/list_spec.rb +58 -0
- data/spec/lib/zoom/actions/account/managed_domains_spec.rb +43 -0
- data/spec/lib/zoom/actions/account/options_update_spec.rb +58 -0
- data/spec/lib/zoom/actions/account/settings_get_spec.rb +50 -0
- data/spec/lib/zoom/actions/account/settings_update_spec.rb +55 -0
- data/spec/lib/zoom/actions/account/trusted_domains_spec.rb +43 -0
- data/spec/lib/zoom/actions/billing/get_spec.rb +48 -0
- data/spec/lib/zoom/actions/billing/plans_list_spec.rb +48 -0
- data/spec/lib/zoom/actions/billing/plans_subscribe_spec.rb +69 -0
- data/spec/lib/zoom/actions/billing/plans_usage_spec.rb +48 -0
- data/spec/lib/zoom/actions/billing/update_spec.rb +64 -0
- data/spec/lib/zoom/actions/dashboard/crc_spec.rb +33 -0
- data/spec/lib/zoom/actions/dashboard/meeting_details_spec.rb +62 -0
- data/spec/lib/zoom/actions/dashboard/meeting_participants_spec.rb +74 -0
- data/spec/lib/zoom/actions/dashboard/meetings_spec.rb +63 -0
- data/spec/lib/zoom/actions/groups/create_spec.rb +98 -0
- data/spec/lib/zoom/actions/{group → groups}/delete_spec.rb +0 -0
- data/spec/lib/zoom/actions/{group → groups}/edit_spec.rb +0 -0
- data/spec/lib/zoom/actions/groups/get_spec.rb +62 -0
- data/spec/lib/zoom/actions/groups/list_spec.rb +47 -0
- data/spec/lib/zoom/actions/{group → groups}/member/add_spec.rb +0 -0
- data/spec/lib/zoom/actions/{group → groups}/member/delete_spec.rb +0 -0
- data/spec/lib/zoom/actions/{group → groups/member}/list_spec.rb +0 -0
- data/spec/lib/zoom/actions/groups/update_spec.rb +59 -0
- data/spec/lib/zoom/actions/im/chat/channels/get_spec.rb +64 -0
- data/spec/lib/zoom/actions/im/chat/users/channels/get_spec.rb +45 -0
- data/spec/lib/zoom/actions/meeting/add_registrant_spec.rb +30 -0
- data/spec/lib/zoom/actions/meeting/create_spec.rb +13 -13
- data/spec/lib/zoom/actions/meeting/delete_spec.rb +17 -34
- data/spec/lib/zoom/actions/meeting/get_spec.rb +21 -31
- data/spec/lib/zoom/actions/meeting/invitation_spec.rb +48 -0
- data/spec/lib/zoom/actions/meeting/livestream_spec.rb +61 -0
- data/spec/lib/zoom/actions/meeting/update_spec.rb +48 -42
- data/spec/lib/zoom/actions/recording/file_delete_spec.rb +33 -0
- data/spec/lib/zoom/actions/recording/get_spec.rb +19 -35
- data/spec/lib/zoom/actions/recording/list_spec.rb +20 -26
- data/spec/lib/zoom/actions/recording/settings/get_spec.rb +42 -0
- data/spec/lib/zoom/actions/recording/settings/update_spec.rb +32 -0
- data/spec/lib/zoom/actions/report/meeting_details_report_spec.rb +44 -0
- data/spec/lib/zoom/actions/report/meeting_participants_report_spec.rb +44 -0
- data/spec/lib/zoom/actions/report/webinar_participants_report_spec.rb +2 -2
- data/spec/lib/zoom/actions/roles/assign_spec.rb +25 -0
- data/spec/lib/zoom/actions/roles/create_spec.rb +55 -0
- data/spec/lib/zoom/actions/roles/get_spec.rb +37 -0
- data/spec/lib/zoom/actions/roles/list_spec.rb +28 -0
- data/spec/lib/zoom/actions/roles/members_spec.rb +35 -0
- data/spec/lib/zoom/actions/roles/unassign_spec.rb +34 -0
- data/spec/lib/zoom/actions/sip_audio/add_trunks_internal_callout_countries_spec.rb +25 -0
- data/spec/lib/zoom/actions/sip_audio/add_trunks_internal_numbers_spec.rb +25 -0
- data/spec/lib/zoom/actions/sip_audio/assign_numbers_spec.rb +29 -0
- data/spec/lib/zoom/actions/sip_audio/delete_internal_callout_countries_spec.rb +44 -0
- data/spec/lib/zoom/actions/sip_audio/delete_trunk_internal_numbers_spec.rb +44 -0
- data/spec/lib/zoom/actions/sip_audio/delete_trunk_numbers_spec.rb +44 -0
- data/spec/lib/zoom/actions/sip_audio/delete_trunks_spec.rb +44 -0
- data/spec/lib/zoom/actions/sip_audio/get_trunks_spec.rb +50 -0
- data/spec/lib/zoom/actions/sip_audio/list_trunk_numbers_spec.rb +46 -0
- data/spec/lib/zoom/actions/sip_audio/list_trunks_internal_callout_country_spec.rb +53 -0
- data/spec/lib/zoom/actions/sip_audio/list_trunks_internal_numbers_spec.rb +53 -0
- data/spec/lib/zoom/actions/token/access_token_spec.rb +26 -0
- data/spec/lib/zoom/actions/token/data_compliance_spec.rb +41 -0
- data/spec/lib/zoom/actions/token/refresh_token_spec.rb +26 -0
- data/spec/lib/zoom/actions/user/assistant/create_spec.rb +59 -0
- data/spec/lib/zoom/actions/user/assistant/delete_all_spec.rb +44 -0
- data/spec/lib/zoom/actions/user/assistant/delete_spec.rb +48 -1
- data/spec/lib/zoom/actions/user/assistant/list_spec.rb +53 -0
- data/spec/lib/zoom/actions/user/create_spec.rb +20 -48
- data/spec/lib/zoom/actions/user/delete_spec.rb +2 -2
- data/spec/lib/zoom/actions/user/email_check_spec.rb +43 -0
- data/spec/lib/zoom/actions/user/get_spec.rb +12 -3
- data/spec/lib/zoom/actions/user/list_recordings_spec.rb +57 -0
- data/spec/lib/zoom/actions/user/list_spec.rb +34 -3
- data/spec/lib/zoom/actions/user/permissions_spec.rb +52 -0
- data/spec/lib/zoom/actions/user/scheduler/delete_all_spec.rb +44 -0
- data/spec/lib/zoom/actions/user/scheduler/delete_spec.rb +50 -0
- data/spec/lib/zoom/actions/user/scheduler/list_spec.rb +53 -0
- data/spec/lib/zoom/actions/user/settings_get_spec.rb +56 -0
- data/spec/lib/zoom/actions/user/settings_update_spec.rb +50 -0
- data/spec/lib/zoom/actions/user/token_spec.rb +61 -0
- data/spec/lib/zoom/actions/user/update_email_spec.rb +59 -0
- data/spec/lib/zoom/actions/user/update_password_spec.rb +29 -0
- data/spec/lib/zoom/actions/user/update_spec.rb +2 -2
- data/spec/lib/zoom/actions/user/update_status_spec.rb +59 -0
- data/spec/lib/zoom/actions/user/vanity_name_spec.rb +51 -0
- data/spec/lib/zoom/actions/webinar/create_spec.rb +49 -44
- data/spec/lib/zoom/actions/webinar/delete_spec.rb +3 -3
- data/spec/lib/zoom/actions/webinar/get_spec.rb +1 -1
- data/spec/lib/zoom/actions/webinar/list_spec.rb +2 -2
- data/spec/lib/zoom/actions/webinar/panelist_list_spec.rb +44 -0
- data/spec/lib/zoom/actions/webinar/past_webinar_list_spec.rb +44 -0
- data/spec/lib/zoom/actions/webinar/poll_get_spec.rb +47 -0
- data/spec/lib/zoom/actions/webinar/polls_list_spec.rb +44 -0
- data/spec/lib/zoom/actions/webinar/registrants/add_spec.rb +2 -2
- data/spec/lib/zoom/actions/webinar/registrants/get_spec.rb +49 -0
- data/spec/lib/zoom/actions/webinar/registrants/list_spec.rb +2 -2
- data/spec/lib/zoom/actions/webinar/registrants/update_status_spec.rb +1 -1
- data/spec/lib/zoom/actions/webinar/update_spec.rb +2 -2
- data/spec/lib/zoom/actions_spec.rb +84 -0
- data/spec/lib/zoom/client_spec.rb +85 -7
- data/spec/lib/zoom/params_spec.rb +23 -3
- data/spec/lib/zoom/utils_spec.rb +13 -18
- data/spec/spec_helper.rb +23 -2
- data/zoom_rb.gemspec +1 -1
- metadata +343 -112
- data/.ruby-version +0 -1
- data/lib/zoom/actions/group.rb +0 -8
- data/lib/zoom/actions/metrics.rb +0 -27
- data/lib/zoom/constants.rb +0 -103
- data/spec/fixtures/meeting/delete.json +0 -4
- data/spec/fixtures/meeting/end.json +0 -4
- data/spec/fixtures/meeting/live.json +0 -32
- data/spec/fixtures/meeting/register.json +0 -7
- data/spec/fixtures/meeting/update.json +0 -4
- data/spec/fixtures/metrics_crc.json +0 -105
- data/spec/fixtures/metrics_meetingdetail.json +0 -32
- data/spec/fixtures/recording_delete.json +0 -4
- data/spec/fixtures/recording_list.json +0 -51
- data/spec/fixtures/user/assistant/delete.json +0 -5
- data/spec/lib/zoom/actions/group/create_spec.rb +0 -3
- data/spec/lib/zoom/actions/group/get_spec.rb +0 -3
- data/spec/lib/zoom/actions/group/member/list_spec.rb +0 -3
- data/spec/lib/zoom/actions/meeting/end_spec.rb +0 -55
- data/spec/lib/zoom/actions/meeting/live_spec.rb +0 -43
- data/spec/lib/zoom/actions/meeting/register_spec.rb +0 -45
- data/spec/lib/zoom/actions/metrics/crc_spec.rb +0 -48
- data/spec/lib/zoom/actions/metrics/im_spec.rb +0 -3
- data/spec/lib/zoom/actions/metrics/meetingdetail_spec.rb +0 -51
- data/spec/lib/zoom/actions/metrics/meetings_spec.rb +0 -61
- data/spec/lib/zoom/actions/metrics/qos_spec.rb +0 -3
- data/spec/lib/zoom/actions/metrics/webinardetail_spec.rb +0 -3
- data/spec/lib/zoom/actions/metrics/webinars_spec.rb +0 -3
- data/spec/lib/zoom/actions/metrics/zoomroomdetail_spec.rb +0 -3
- data/spec/lib/zoom/actions/metrics/zoomrooms_spec.rb +0 -3
- data/spec/lib/zoom/actions/recording/delete_spec.rb +0 -52
- data/spec/lib/zoom/actions/recording/mc_list_spec.rb +0 -51
- data/spec/lib/zoom/actions/user/activate_spec.rb +0 -3
- data/spec/lib/zoom/actions/user/checkemail_spec.rb +0 -3
- data/spec/lib/zoom/actions/user/checkzpk_spec.rb +0 -3
- data/spec/lib/zoom/actions/user/deactivate_spec.rb +0 -3
- data/spec/lib/zoom/actions/user/revoketoken_spec.rb +0 -3
- data/spec/lib/zoom/actions/user/updatepassword_spec.rb +0 -3
- data/spec/lib/zoom/actions/webinar/panelists_spec.rb +0 -3
- data/spec/lib/zoom/actions/webinar/polls_spec.rb +0 -3
@@ -17,7 +17,7 @@ RSpec.describe Zoom::Actions::Webinar do
|
|
17
17
|
zoom_url("/webinars/#{args[:id]}/registrants")
|
18
18
|
).to_return(status: 201,
|
19
19
|
body: json_response('webinar', 'registrant', 'add'),
|
20
|
-
headers: {
|
20
|
+
headers: { 'Content-Type' => 'application/json' })
|
21
21
|
end
|
22
22
|
|
23
23
|
it "requires a 'id' argument" do
|
@@ -53,7 +53,7 @@ RSpec.describe Zoom::Actions::Webinar do
|
|
53
53
|
zoom_url("/webinars/#{args[:id]}/registrants")
|
54
54
|
).to_return(status: 404,
|
55
55
|
body: json_response('error', 'not_found'),
|
56
|
-
headers: {
|
56
|
+
headers: { 'Content-Type' => 'application/json' })
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'raises Zoom::Error exception' do
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Zoom::Actions::Webinar do
|
6
|
+
let(:zc) { zoom_client }
|
7
|
+
let(:args) { { webinar_id: 'webinar_id', id: 'registrant_id' } }
|
8
|
+
|
9
|
+
describe '#webinar_registrant_get' do
|
10
|
+
context 'with a valid response' do
|
11
|
+
before :each do
|
12
|
+
stub_request(
|
13
|
+
:get,
|
14
|
+
zoom_url("/webinars/#{args[:webinar_id]}/registrants/#{args[:id]}")
|
15
|
+
).to_return(body: json_response('webinar', 'registrant', 'get'),
|
16
|
+
headers: { 'Content-Type' => 'application/json' })
|
17
|
+
end
|
18
|
+
|
19
|
+
it "requires a 'webinar_id' argument" do
|
20
|
+
expect { zc.webinar_registrant_get(filter_key(args, :webinar_id)) }.to raise_error(Zoom::ParameterMissing, [:webinar_id].to_s)
|
21
|
+
end
|
22
|
+
it "requires a 'id' argument" do
|
23
|
+
expect { zc.webinar_registrant_get(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
|
24
|
+
end
|
25
|
+
it "allows occurrence_id" do
|
26
|
+
expect { zc.webinar_registrant_get(args.merge(:occurrence_id => '5')) }.not_to raise_error
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns an Hash' do
|
30
|
+
expect(zc.webinar_registrant_get(args)).to be_kind_of(Hash)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'with a 4xx response' do
|
35
|
+
before :each do
|
36
|
+
stub_request(
|
37
|
+
:get,
|
38
|
+
zoom_url("/webinars/#{args[:webinar_id]}/registrants/#{args[:id]}")
|
39
|
+
).to_return(status: 404,
|
40
|
+
body: json_response('error', 'validation'),
|
41
|
+
headers: { 'Content-Type' => 'application/json' })
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'raises Zoom::Error exception' do
|
45
|
+
expect { zc.webinar_registrant_get(args) }.to raise_error(Zoom::Error)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -13,7 +13,7 @@ RSpec.describe Zoom::Actions::Webinar do
|
|
13
13
|
:get,
|
14
14
|
zoom_url("/webinars/#{args[:id]}/registrants")
|
15
15
|
).to_return(body: json_response('webinar', 'registrant', 'list'),
|
16
|
-
headers: {
|
16
|
+
headers: { 'Content-Type' => 'application/json' })
|
17
17
|
end
|
18
18
|
|
19
19
|
it "requires a 'id' argument" do
|
@@ -32,7 +32,7 @@ RSpec.describe Zoom::Actions::Webinar do
|
|
32
32
|
zoom_url("/webinars/#{args[:id]}/registrants")
|
33
33
|
).to_return(status: 404,
|
34
34
|
body: json_response('error', 'validation'),
|
35
|
-
headers: {
|
35
|
+
headers: { 'Content-Type' => 'application/json' })
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'raises Zoom::Error exception' do
|
@@ -31,7 +31,7 @@ RSpec.describe Zoom::Actions::Webinar do
|
|
31
31
|
zoom_url("/webinars/#{args[:id]}/registrants/status")
|
32
32
|
).to_return(status: 404,
|
33
33
|
body: json_response('error', 'validation'),
|
34
|
-
headers: {
|
34
|
+
headers: { 'Content-Type' => 'application/json' })
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'raises Zoom::Error exception' do
|
@@ -14,7 +14,7 @@ describe Zoom::Actions::Webinar do
|
|
14
14
|
zoom_url("/webinars/#{args[:id]}")
|
15
15
|
).to_return(status: 204,
|
16
16
|
body: json_response('webinar', 'update'),
|
17
|
-
headers: {
|
17
|
+
headers: { 'Content-Type' => 'application/json' })
|
18
18
|
end
|
19
19
|
|
20
20
|
it "requires a 'id' argument" do
|
@@ -33,7 +33,7 @@ describe Zoom::Actions::Webinar do
|
|
33
33
|
zoom_url("/webinars/#{args[:id]}")
|
34
34
|
).to_return(status: 404,
|
35
35
|
body: json_response('error', 'not_found'),
|
36
|
-
headers: {
|
36
|
+
headers: { 'Content-Type' => 'application/json' })
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'raises an error' do
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Zoom::Actions do
|
6
|
+
let(:client) { Zoom::Client::OAuth.new(access_token: 'xxx', timeout: 15) }
|
7
|
+
let(:path) { '/:id/foo/:bar' }
|
8
|
+
let(:path_keys) { [:id, :bar] }
|
9
|
+
let(:params) { { id: 100, bar: 'baz' } }
|
10
|
+
let(:base_uri) { 'https://example.com' }
|
11
|
+
let(:parsed_path) { '/100/foo/baz' }
|
12
|
+
|
13
|
+
describe 'self.extract_path_keys' do
|
14
|
+
subject { described_class.extract_path_keys(path) }
|
15
|
+
|
16
|
+
it { is_expected.to match_array(path_keys) }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'self.parse_path' do
|
20
|
+
subject { described_class.parse_path(path, path_keys, params) }
|
21
|
+
|
22
|
+
it { is_expected.to eq(parsed_path) }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'self.make_request' do
|
26
|
+
subject { described_class.make_request(client, method, parsed_path, params, base_uri) }
|
27
|
+
|
28
|
+
let(:request_options) {
|
29
|
+
{
|
30
|
+
headers: client.request_headers,
|
31
|
+
base_uri: base_uri
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
context 'when get' do
|
36
|
+
let(:method) { :get }
|
37
|
+
|
38
|
+
it 'calls get method on client with get request_options' do
|
39
|
+
request_options[:query] = params
|
40
|
+
expect(client.class).to receive(method).with(parsed_path, **request_options)
|
41
|
+
subject
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when post' do
|
46
|
+
let(:method) { :post }
|
47
|
+
|
48
|
+
it 'calls post method on client with post request_options' do
|
49
|
+
request_options[:body] = params.to_json
|
50
|
+
expect(client.class).to receive(method).with(parsed_path, **request_options)
|
51
|
+
subject
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when put' do
|
56
|
+
let(:method) { :put }
|
57
|
+
|
58
|
+
it 'calls put method on client with put request_options' do
|
59
|
+
request_options[:body] = params.to_json
|
60
|
+
expect(client.class).to receive(method).with(parsed_path, **request_options)
|
61
|
+
subject
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when patch' do
|
66
|
+
let(:method) { :patch }
|
67
|
+
|
68
|
+
it 'calls patch method on client with patch request_options' do
|
69
|
+
request_options[:body] = params.to_json
|
70
|
+
expect(client.class).to receive(method).with(parsed_path, **request_options)
|
71
|
+
subject
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'when delete' do
|
76
|
+
let(:method) { :delete }
|
77
|
+
|
78
|
+
it 'calls delete method on client with delete request_options' do
|
79
|
+
expect(client.class).to receive(method).with(parsed_path, **request_options)
|
80
|
+
subject
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
|
5
|
+
describe Zoom::Client do
|
6
6
|
|
7
|
-
|
7
|
+
describe 'default attributes' do
|
8
8
|
it 'must include httparty methods' do
|
9
9
|
expect(Zoom::Client).to include(HTTParty)
|
10
|
+
expect(Zoom::Client::JWT).to include(HTTParty)
|
10
11
|
end
|
11
12
|
|
12
13
|
it 'must have the base url set to Zoom API endpoint' do
|
@@ -19,7 +20,8 @@ xdescribe Zoom::Client do
|
|
19
20
|
config.api_secret = 'xxx'
|
20
21
|
end
|
21
22
|
Zoom.new
|
22
|
-
expect(Zoom::Client.default_options[:timeout]).to eq(15)
|
23
|
+
expect(Zoom::Client::JWT.default_options[:timeout]).to eq(15)
|
24
|
+
Zoom.configuration = nil
|
23
25
|
end
|
24
26
|
|
25
27
|
it 'must get the timeout from the configuration' do
|
@@ -29,17 +31,93 @@ xdescribe Zoom::Client do
|
|
29
31
|
config.timeout = 20
|
30
32
|
end
|
31
33
|
Zoom.new
|
32
|
-
expect(Zoom::Client.default_options[:timeout]).to eq(20)
|
34
|
+
expect(Zoom::Client::JWT.default_options[:timeout]).to eq(20)
|
35
|
+
Zoom.configuration = nil
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
36
|
-
|
39
|
+
describe 'JWT client' do
|
40
|
+
let(:client) {
|
41
|
+
Zoom::Client::JWT.new(api_key: 'xxx', api_secret: 'xxx', timeout: 15)
|
42
|
+
}
|
37
43
|
it 'requires api_key and api_secret for a new instance' do
|
38
|
-
expect { Zoom::Client.new(api_key: 'xxx') }.to raise_error(
|
44
|
+
expect { Zoom::Client::JWT.new(api_key: 'xxx') }.to raise_error(Zoom::ParameterMissing)
|
45
|
+
expect { Zoom::Client::JWT.new(api_key: 'xxx', api_secret: 'xxx') }.not_to raise_error
|
39
46
|
end
|
40
47
|
|
41
48
|
it 'creates instance of Zoom::Client if api_key and api_secret is provided' do
|
42
|
-
expect(
|
49
|
+
expect(client).to be_kind_of(Zoom::Client)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'has the bearer token in the auth header' do
|
53
|
+
fake_token = 'NotTheRealToken'
|
54
|
+
allow(client).to receive(:access_token) {fake_token}
|
55
|
+
expect(client.request_headers['Authorization']).to eq("Bearer #{fake_token}")
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'OAuth client' do
|
61
|
+
let(:access_token) {'xxx'}
|
62
|
+
let(:refresh_token) {'xxx'}
|
63
|
+
let(:auth_token) {'xxx'}
|
64
|
+
let(:client) {
|
65
|
+
Zoom::Client::OAuth.new(access_token: access_token, timeout: 30)
|
66
|
+
}
|
67
|
+
it 'raises an error if there is no token' do
|
68
|
+
expect { Zoom::Client::OAuth.new(timeout: 30) }.to raise_error(Zoom::ParameterMissing)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'raises an error if there is no complete auth token, auth code and redirect_uri' do
|
72
|
+
expect { Zoom::Client::OAuth.new(auth_token: 'xxx', auth_code: 'xxx', redirect_uri: 'xxx') }.not_to raise_error
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'requires atleast an access token' do
|
76
|
+
expect { Zoom::Client::OAuth.new(access_token: access_token) }.not_to raise_error
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'requires atleast a refresh token' do
|
80
|
+
expect { Zoom::Client::OAuth.new(refresh_token: refresh_token) }.not_to raise_error
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'creates instance of Zoom::Client if api_key and api_secret is provided' do
|
84
|
+
expect(client).to be_kind_of(Zoom::Client)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'has the bearer token in the auth header' do
|
88
|
+
expect(client.request_headers['Authorization']).to eq("Bearer #{access_token}")
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'set_tokens' do
|
92
|
+
let(:zc) { oauth_client }
|
93
|
+
let(:args) { { auth_code: 'xxx', redirect_uri: 'http://localhost:3000' } }
|
94
|
+
|
95
|
+
before :each do
|
96
|
+
Zoom.configure do |config|
|
97
|
+
config.api_key = 'xxx'
|
98
|
+
config.api_secret = 'xxx'
|
99
|
+
config.timeout = 20
|
100
|
+
end
|
101
|
+
|
102
|
+
stub_request(
|
103
|
+
:post,
|
104
|
+
zoom_auth_url('oauth/token')
|
105
|
+
).to_return(body: json_response('token', 'access_token'),
|
106
|
+
headers: { 'Content-Type' => 'application/json' })
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'sets the refresh_token, access_token, expires_in and expires_at' do
|
110
|
+
expected_values = JSON.parse(json_response('token', 'access_token'))
|
111
|
+
zc.auth
|
112
|
+
expect(zc.access_token).to eq(expected_values['access_token'])
|
113
|
+
expect(zc.refresh_token).to eq(expected_values['refresh_token'])
|
114
|
+
expect(zc.expires_in).to eq(expected_values['expires_in'])
|
115
|
+
expect(zc.expires_at).to eq((Time.now + expected_values['expires_in']).to_i)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'has the basic auth authorization header' do
|
119
|
+
expect(zc.oauth_request_headers['Authorization']).to eq("Basic eHh4Onh4eA==")
|
120
|
+
end
|
43
121
|
end
|
44
122
|
end
|
45
123
|
end
|
@@ -8,7 +8,7 @@ RSpec.describe Zoom::Params do
|
|
8
8
|
let(:params) { Zoom::Params.new(foo: :bar, baz: :bang) }
|
9
9
|
|
10
10
|
it 'does not raise an error when required keys are present' do
|
11
|
-
expect { params.require(:foo) }.not_to raise_error
|
11
|
+
expect { params.require(:foo) }.not_to raise_error
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'does raise an error when required keys are missing' do
|
@@ -20,15 +20,35 @@ RSpec.describe Zoom::Params do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
describe '#require_one_of' do
|
24
|
+
let(:params) { Zoom::Params.new(foo: :bar, baz: :bang) }
|
25
|
+
|
26
|
+
it 'does raise an error when required keys are missing' do
|
27
|
+
expect { params.require_one_of(:bar) }.to raise_error(Zoom::ParameterMissing, [:bar].to_s)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'does raise an error when there is a missing required keys out of many' do
|
31
|
+
expect { params.require_one_of(:bar, :fooey, :fooa) }.to raise_error(Zoom::ParameterMissing, "You are missing atleast one of #{[:bar, :fooey, :fooa].to_s}")
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'does not raise an error when one of the required keys are missing' do
|
35
|
+
expect { params.require_one_of(:foo) }.not_to raise_error
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'does not raise an error when one of the required keys are missing' do
|
39
|
+
expect { params.require_one_of(:foo, :bebop) }.not_to raise_error
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
23
43
|
describe '#permit' do
|
24
44
|
let(:params) { Zoom::Params.new(foo: true, bar: :baz ) }
|
25
45
|
|
26
46
|
it 'does not raise an error when permitted keys are present' do
|
27
|
-
expect { params.require(:foo).permit(:bar) }.not_to raise_error
|
47
|
+
expect { params.require(:foo).permit(:bar) }.not_to raise_error
|
28
48
|
end
|
29
49
|
|
30
50
|
it 'does not raise an error when permitted keys are not present' do
|
31
|
-
expect { params.require(:foo).permit(:bar, :bang) }.not_to raise_error
|
51
|
+
expect { params.require(:foo).permit(:bar, :bang) }.not_to raise_error
|
32
52
|
end
|
33
53
|
|
34
54
|
context 'raises an error' do
|
data/spec/lib/zoom/utils_spec.rb
CHANGED
@@ -2,21 +2,26 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
|
5
|
+
describe Zoom::Utils do
|
6
6
|
|
7
7
|
before(:all) do
|
8
8
|
class Utils < Zoom::Utils; end
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
describe '#argument_error' do
|
12
12
|
it 'raises ArgumentError' do
|
13
13
|
expect(Utils.argument_error('foo')).to be_instance_of(ArgumentError)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
it 'raises Zoom::
|
19
|
-
response = { '
|
17
|
+
describe '#raise_if_error!' do
|
18
|
+
it 'raises Zoom::AuthenticationError if error is present and code = 124' do
|
19
|
+
response = { 'code' => 124, 'message' => 'Invalid access token.' }
|
20
|
+
expect { Utils.raise_if_error!(response) }.to raise_error(Zoom::AuthenticationError)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'raises Zoom::Error if error is present and code >= 300' do
|
24
|
+
response = { 'code' => 400, 'message' => 'lol error' }
|
20
25
|
expect { Utils.raise_if_error!(response) }.to raise_error(Zoom::Error)
|
21
26
|
end
|
22
27
|
|
@@ -26,31 +31,21 @@ xdescribe Zoom::Utils do
|
|
26
31
|
end
|
27
32
|
end
|
28
33
|
|
29
|
-
|
30
|
-
it 'raises ArgumentError if the param is not present' do
|
31
|
-
expect { Utils.require_params(:foo, { bar: 'bar' }) }.to raise_error(ArgumentError)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'does not raise ArgumentError if the param is present' do
|
35
|
-
expect { Utils.require_params(:foo, { foo: 'foo' }) }.to_not raise_error
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
xdescribe '#extract_options!' do
|
34
|
+
describe '#extract_options!' do
|
40
35
|
it 'converts array to hash options' do
|
41
36
|
args = [{ foo: 'foo' }, { bar: 'bar' }, { zemba: 'zemba' }]
|
42
37
|
expect(Utils.extract_options!(args)).to be_kind_of(Hash)
|
43
38
|
end
|
44
39
|
end
|
45
40
|
|
46
|
-
|
41
|
+
describe '#process_datetime_params' do
|
47
42
|
it 'converts the Time objects to formatted strings' do
|
48
43
|
args = {
|
49
44
|
foo: 'foo',
|
50
45
|
bar: Time.utc(2000, 'jan', 1, 20, 15, 1)
|
51
46
|
}
|
52
47
|
expect(
|
53
|
-
Utils.process_datetime_params!(
|
48
|
+
Utils.process_datetime_params!(args)
|
54
49
|
).to eq({ foo: 'foo',
|
55
50
|
bar: '2000-01-01T20:15:01Z' })
|
56
51
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,7 @@ SimpleCov.start
|
|
5
5
|
|
6
6
|
require 'rubygems'
|
7
7
|
require 'bundler/setup'
|
8
|
-
require '
|
8
|
+
require 'zoom_rb'
|
9
9
|
require 'webmock/rspec'
|
10
10
|
|
11
11
|
RSpec.configure do |config|
|
@@ -20,14 +20,35 @@ def json_response(*path, endpoint)
|
|
20
20
|
open(fixture(path, endpoint + '.json')).read
|
21
21
|
end
|
22
22
|
|
23
|
+
def request_headers
|
24
|
+
{
|
25
|
+
'Accept' => 'application/json',
|
26
|
+
'Content-Type' => 'application/json',
|
27
|
+
'Authorization' => /Bearer .+/
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
23
31
|
def zoom_url(url)
|
24
32
|
/https:\/\/api.zoom.us\/v2#{url}.*/
|
25
33
|
end
|
26
34
|
|
27
|
-
|
35
|
+
#OAuth endpoints have a different base_uri
|
36
|
+
def zoom_auth_url(url)
|
37
|
+
/https:\/\/zoom.us\/#{url}.*/
|
38
|
+
end
|
39
|
+
|
40
|
+
def jwt_client
|
28
41
|
Zoom.new
|
29
42
|
end
|
30
43
|
|
44
|
+
def oauth_client
|
45
|
+
Zoom::Client::OAuth.new(auth_token: 'xxx', auth_code: 'xxx', redirect_uri: 'xxx', timeout: 15)
|
46
|
+
end
|
47
|
+
|
48
|
+
def zoom_client
|
49
|
+
jwt_client
|
50
|
+
end
|
51
|
+
|
31
52
|
def filter_key(hash, key)
|
32
53
|
copy = hash.dup
|
33
54
|
copy.delete(key)
|
data/zoom_rb.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.add_dependency 'json', '>= 1.8'
|
11
11
|
gem.add_dependency 'jwt'
|
12
12
|
|
13
|
-
gem.add_development_dependency 'pry'
|
13
|
+
gem.add_development_dependency 'pry-byebug'
|
14
14
|
gem.add_development_dependency 'hint-rubocop_style', '~> 0'
|
15
15
|
gem.add_development_dependency 'rspec', '~> 3.8'
|
16
16
|
gem.add_development_dependency 'rspec_junit_formatter', '~> 0.4.1'
|