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.
Files changed (273) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +1 -1
  3. data/.gitignore +2 -1
  4. data/CHANGELOG.md +53 -0
  5. data/Gemfile.lock +85 -51
  6. data/Makefile +1 -1
  7. data/README.md +31 -3
  8. data/lib/zoom/actions/account.rb +18 -76
  9. data/lib/zoom/actions/billing.rb +41 -0
  10. data/lib/zoom/actions/dashboard.rb +22 -0
  11. data/lib/zoom/actions/groups.rb +19 -0
  12. data/lib/zoom/actions/im/chat.rb +13 -14
  13. data/lib/zoom/actions/meeting.rb +38 -63
  14. data/lib/zoom/actions/phone.rb +15 -0
  15. data/lib/zoom/actions/recording.rb +13 -22
  16. data/lib/zoom/actions/report.rb +8 -43
  17. data/lib/zoom/actions/roles.rb +24 -0
  18. data/lib/zoom/actions/sip_audio.rb +34 -0
  19. data/lib/zoom/actions/token.rb +26 -0
  20. data/lib/zoom/actions/user.rb +66 -139
  21. data/lib/zoom/actions/webinar.rb +43 -84
  22. data/lib/zoom/actions.rb +49 -0
  23. data/lib/zoom/client.rb +27 -16
  24. data/lib/zoom/clients/jwt.rb +22 -0
  25. data/lib/zoom/clients/oauth.rb +60 -0
  26. data/lib/zoom/constants/account/options/pay_modes.rb +12 -0
  27. data/lib/zoom/constants/account/settings/permitted_settings.rb +125 -0
  28. data/lib/zoom/constants/constants.rb +35 -0
  29. data/lib/zoom/constants/meeting/approval_types.rb +11 -0
  30. data/lib/zoom/constants/meeting/audio_type.rb +11 -0
  31. data/lib/zoom/constants/meeting/auto_recording.rb +11 -0
  32. data/lib/zoom/constants/meeting/registration_types.rb +11 -0
  33. data/lib/zoom/constants/meeting/types.rb +12 -0
  34. data/lib/zoom/constants/recurrence/monthly_weeks.rb +13 -0
  35. data/lib/zoom/constants/recurrence/types.rb +11 -0
  36. data/lib/zoom/constants/recurrence/weekly_days.rb +15 -0
  37. data/lib/zoom/constants/user/create_types.rb +12 -0
  38. data/lib/zoom/constants/user/types.rb +11 -0
  39. data/lib/zoom/constants/webinar/approval_types.rb +11 -0
  40. data/lib/zoom/constants/webinar/audio_type.rb +11 -0
  41. data/lib/zoom/constants/webinar/auto_recording.rb +11 -0
  42. data/lib/zoom/constants/webinar/registration_types.rb +11 -0
  43. data/lib/zoom/constants/webinar/types.rb +11 -0
  44. data/lib/zoom/error.rb +9 -1
  45. data/lib/zoom/params.rb +51 -12
  46. data/lib/zoom/utils.rb +22 -38
  47. data/lib/zoom/version.rb +2 -2
  48. data/lib/{zoom.rb → zoom_rb.rb} +12 -5
  49. data/spec/fixtures/account/create.json +6 -0
  50. data/spec/{lib/zoom/actions/report/hosts_report_spec.rb → fixtures/account/delete.json} +0 -0
  51. data/spec/fixtures/account/get.json +13 -0
  52. data/spec/fixtures/account/list.json +18 -0
  53. data/spec/fixtures/account/managed_domains.json +7 -0
  54. data/spec/fixtures/account/options_update.json +7 -0
  55. data/spec/fixtures/account/settings_get.json +120 -0
  56. data/spec/{lib/zoom/actions/report/meeting_polls_report_spec.rb → fixtures/account/settings_update.json} +0 -0
  57. data/spec/fixtures/account/trusted_domains.json +3 -0
  58. data/spec/fixtures/billing/get.json +12 -0
  59. data/spec/fixtures/billing/plans_list.json +44 -0
  60. data/spec/fixtures/billing/plans_subscribe.json +30 -0
  61. data/spec/fixtures/billing/plans_usage.json +30 -0
  62. data/spec/{lib/zoom/actions/report/meetings_report_spec.rb → fixtures/billing/update.json} +0 -0
  63. data/spec/fixtures/chat/channels/get.json +5 -0
  64. data/spec/fixtures/chat/users/channels/list.json +17 -0
  65. data/spec/fixtures/dashboard/crc.json +104 -0
  66. data/spec/fixtures/dashboard/meeting/detail.json +20 -0
  67. data/spec/fixtures/dashboard/meeting/participants.json +56 -0
  68. data/spec/fixtures/{metrics_meetings.json → dashboard/meetings.json} +1 -2
  69. data/spec/fixtures/error/admin_cannot_activated.json +4 -0
  70. data/spec/fixtures/error/channel_not_found.json +4 -0
  71. data/spec/fixtures/error/group_does_not_exist.json +4 -0
  72. data/spec/fixtures/error/group_not_belong_to_account.json +4 -0
  73. data/spec/fixtures/error/group_not_exist.json +4 -0
  74. data/spec/fixtures/error/meeting_not_exist.json +4 -0
  75. data/spec/fixtures/error/next_page_token_invalid.json +4 -0
  76. data/spec/fixtures/error/not_found_administrator.json +4 -0
  77. data/spec/fixtures/error/unauthorized_request.json +4 -0
  78. data/spec/fixtures/error/user_not_exist.json +1 -1
  79. data/spec/fixtures/groups/create.json +5 -0
  80. data/spec/fixtures/groups/get.json +5 -0
  81. data/spec/fixtures/groups/list.json +15 -0
  82. data/spec/{lib/zoom/actions/report/telephone_report_spec.rb → fixtures/groups/update.json} +0 -0
  83. data/spec/fixtures/meeting/add_registrant.json +7 -0
  84. data/spec/fixtures/meeting/create.json +31 -16
  85. data/spec/fixtures/meeting/get.json +43 -33
  86. data/spec/fixtures/meeting/invitation.json +3 -0
  87. data/spec/fixtures/meeting/live_stream/errors/meeting_not_found.json +4 -0
  88. data/spec/fixtures/meeting/live_stream/errors/missing_field.json +10 -0
  89. data/spec/fixtures/{recording_get.json → recording/get.json} +17 -6
  90. data/spec/fixtures/recording/list.json +53 -0
  91. data/spec/fixtures/recording/settings/get.json +7 -0
  92. data/spec/fixtures/report/meeting/participants.json +17 -0
  93. data/spec/fixtures/report/meeting.json +19 -0
  94. data/spec/fixtures/roles/assign.json +4 -0
  95. data/spec/fixtures/roles/create.json +9 -0
  96. data/spec/fixtures/roles/get.json +11 -0
  97. data/spec/fixtures/roles/list.json +29 -0
  98. data/spec/fixtures/roles/members.json +15 -0
  99. data/spec/fixtures/sip_audio/sip_trunks_get.json +19 -0
  100. data/spec/fixtures/sip_audio/sip_trunks_internal_callout_countries_add.json +10 -0
  101. data/spec/fixtures/sip_audio/sip_trunks_internal_callout_country_list.json +15 -0
  102. data/spec/fixtures/sip_audio/sip_trunks_internal_numbers_add.json +14 -0
  103. data/spec/fixtures/sip_audio/sip_trunks_internal_numbers_list.json +16 -0
  104. data/spec/fixtures/sip_audio/sip_trunks_numbers_assign.json +7 -0
  105. data/spec/fixtures/sip_audio/sip_trunks_numbers_list.json +9 -0
  106. data/spec/fixtures/token/access_token.json +7 -0
  107. data/spec/fixtures/token/data_compliance.json +8 -0
  108. data/spec/fixtures/token/refresh_token.json +7 -0
  109. data/spec/fixtures/user/assistant/create.json +4 -0
  110. data/spec/fixtures/user/assistant/list.json +8 -0
  111. data/spec/fixtures/user/email_check.json +3 -0
  112. data/spec/fixtures/user/get.json +35 -21
  113. data/spec/fixtures/user/list.json +17 -13
  114. data/spec/fixtures/user/permissions.json +65 -0
  115. data/spec/fixtures/user/recording/list.json +50 -0
  116. data/spec/fixtures/user/scheduler/list.json +12 -0
  117. data/spec/fixtures/user/settings_get.json +74 -0
  118. data/spec/fixtures/user/token.json +3 -0
  119. data/spec/{lib/zoom/actions/report/webinar_details_report_spec.rb → fixtures/user/update_email.json} +0 -0
  120. data/spec/{lib/zoom/actions/report/webinar_polls_report_spec.rb → fixtures/user/update_password.json} +0 -0
  121. data/spec/{lib/zoom/actions/report/webinar_qa_report_spec.rb → fixtures/user/update_status.json} +0 -0
  122. data/spec/fixtures/user/vanity_name.json +3 -0
  123. data/spec/fixtures/webinar/panelist_list.json +12 -0
  124. data/spec/fixtures/webinar/past_webinar_list.json +8 -0
  125. data/spec/fixtures/webinar/poll_get.json +13 -0
  126. data/spec/fixtures/webinar/polls_list.json +16 -0
  127. data/spec/fixtures/webinar/registrant/get.json +25 -0
  128. data/spec/lib/zoom/actions/account/create_spec.rb +68 -0
  129. data/spec/lib/zoom/actions/account/delete_spec.rb +44 -0
  130. data/spec/lib/zoom/actions/account/get_locked_settings_spec.rb +43 -0
  131. data/spec/lib/zoom/actions/account/get_spec.rb +43 -0
  132. data/spec/lib/zoom/actions/account/list_spec.rb +58 -0
  133. data/spec/lib/zoom/actions/account/managed_domains_spec.rb +43 -0
  134. data/spec/lib/zoom/actions/account/options_update_spec.rb +58 -0
  135. data/spec/lib/zoom/actions/account/settings_get_spec.rb +50 -0
  136. data/spec/lib/zoom/actions/account/settings_update_spec.rb +55 -0
  137. data/spec/lib/zoom/actions/account/trusted_domains_spec.rb +43 -0
  138. data/spec/lib/zoom/actions/billing/get_spec.rb +48 -0
  139. data/spec/lib/zoom/actions/billing/plans_list_spec.rb +48 -0
  140. data/spec/lib/zoom/actions/billing/plans_subscribe_spec.rb +69 -0
  141. data/spec/lib/zoom/actions/billing/plans_usage_spec.rb +48 -0
  142. data/spec/lib/zoom/actions/billing/update_spec.rb +64 -0
  143. data/spec/lib/zoom/actions/dashboard/crc_spec.rb +33 -0
  144. data/spec/lib/zoom/actions/dashboard/meeting_details_spec.rb +62 -0
  145. data/spec/lib/zoom/actions/dashboard/meeting_participants_spec.rb +74 -0
  146. data/spec/lib/zoom/actions/dashboard/meetings_spec.rb +63 -0
  147. data/spec/lib/zoom/actions/groups/create_spec.rb +98 -0
  148. data/spec/lib/zoom/actions/{group → groups}/delete_spec.rb +0 -0
  149. data/spec/lib/zoom/actions/{group → groups}/edit_spec.rb +0 -0
  150. data/spec/lib/zoom/actions/groups/get_spec.rb +62 -0
  151. data/spec/lib/zoom/actions/groups/list_spec.rb +47 -0
  152. data/spec/lib/zoom/actions/{group → groups}/member/add_spec.rb +0 -0
  153. data/spec/lib/zoom/actions/{group → groups}/member/delete_spec.rb +0 -0
  154. data/spec/lib/zoom/actions/{group → groups/member}/list_spec.rb +0 -0
  155. data/spec/lib/zoom/actions/groups/update_spec.rb +59 -0
  156. data/spec/lib/zoom/actions/im/chat/channels/get_spec.rb +64 -0
  157. data/spec/lib/zoom/actions/im/chat/users/channels/get_spec.rb +45 -0
  158. data/spec/lib/zoom/actions/meeting/add_registrant_spec.rb +30 -0
  159. data/spec/lib/zoom/actions/meeting/create_spec.rb +13 -13
  160. data/spec/lib/zoom/actions/meeting/delete_spec.rb +17 -34
  161. data/spec/lib/zoom/actions/meeting/get_spec.rb +21 -31
  162. data/spec/lib/zoom/actions/meeting/invitation_spec.rb +48 -0
  163. data/spec/lib/zoom/actions/meeting/livestream_spec.rb +61 -0
  164. data/spec/lib/zoom/actions/meeting/update_spec.rb +48 -42
  165. data/spec/lib/zoom/actions/recording/file_delete_spec.rb +33 -0
  166. data/spec/lib/zoom/actions/recording/get_spec.rb +19 -35
  167. data/spec/lib/zoom/actions/recording/list_spec.rb +20 -26
  168. data/spec/lib/zoom/actions/recording/settings/get_spec.rb +42 -0
  169. data/spec/lib/zoom/actions/recording/settings/update_spec.rb +32 -0
  170. data/spec/lib/zoom/actions/report/meeting_details_report_spec.rb +44 -0
  171. data/spec/lib/zoom/actions/report/meeting_participants_report_spec.rb +44 -0
  172. data/spec/lib/zoom/actions/report/webinar_participants_report_spec.rb +2 -2
  173. data/spec/lib/zoom/actions/roles/assign_spec.rb +25 -0
  174. data/spec/lib/zoom/actions/roles/create_spec.rb +55 -0
  175. data/spec/lib/zoom/actions/roles/get_spec.rb +37 -0
  176. data/spec/lib/zoom/actions/roles/list_spec.rb +28 -0
  177. data/spec/lib/zoom/actions/roles/members_spec.rb +35 -0
  178. data/spec/lib/zoom/actions/roles/unassign_spec.rb +34 -0
  179. data/spec/lib/zoom/actions/sip_audio/add_trunks_internal_callout_countries_spec.rb +25 -0
  180. data/spec/lib/zoom/actions/sip_audio/add_trunks_internal_numbers_spec.rb +25 -0
  181. data/spec/lib/zoom/actions/sip_audio/assign_numbers_spec.rb +29 -0
  182. data/spec/lib/zoom/actions/sip_audio/delete_internal_callout_countries_spec.rb +44 -0
  183. data/spec/lib/zoom/actions/sip_audio/delete_trunk_internal_numbers_spec.rb +44 -0
  184. data/spec/lib/zoom/actions/sip_audio/delete_trunk_numbers_spec.rb +44 -0
  185. data/spec/lib/zoom/actions/sip_audio/delete_trunks_spec.rb +44 -0
  186. data/spec/lib/zoom/actions/sip_audio/get_trunks_spec.rb +50 -0
  187. data/spec/lib/zoom/actions/sip_audio/list_trunk_numbers_spec.rb +46 -0
  188. data/spec/lib/zoom/actions/sip_audio/list_trunks_internal_callout_country_spec.rb +53 -0
  189. data/spec/lib/zoom/actions/sip_audio/list_trunks_internal_numbers_spec.rb +53 -0
  190. data/spec/lib/zoom/actions/token/access_token_spec.rb +26 -0
  191. data/spec/lib/zoom/actions/token/data_compliance_spec.rb +41 -0
  192. data/spec/lib/zoom/actions/token/refresh_token_spec.rb +26 -0
  193. data/spec/lib/zoom/actions/user/assistant/create_spec.rb +59 -0
  194. data/spec/lib/zoom/actions/user/assistant/delete_all_spec.rb +44 -0
  195. data/spec/lib/zoom/actions/user/assistant/delete_spec.rb +48 -1
  196. data/spec/lib/zoom/actions/user/assistant/list_spec.rb +53 -0
  197. data/spec/lib/zoom/actions/user/create_spec.rb +20 -48
  198. data/spec/lib/zoom/actions/user/delete_spec.rb +2 -2
  199. data/spec/lib/zoom/actions/user/email_check_spec.rb +43 -0
  200. data/spec/lib/zoom/actions/user/get_spec.rb +12 -3
  201. data/spec/lib/zoom/actions/user/list_recordings_spec.rb +57 -0
  202. data/spec/lib/zoom/actions/user/list_spec.rb +34 -3
  203. data/spec/lib/zoom/actions/user/permissions_spec.rb +52 -0
  204. data/spec/lib/zoom/actions/user/scheduler/delete_all_spec.rb +44 -0
  205. data/spec/lib/zoom/actions/user/scheduler/delete_spec.rb +50 -0
  206. data/spec/lib/zoom/actions/user/scheduler/list_spec.rb +53 -0
  207. data/spec/lib/zoom/actions/user/settings_get_spec.rb +56 -0
  208. data/spec/lib/zoom/actions/user/settings_update_spec.rb +50 -0
  209. data/spec/lib/zoom/actions/user/token_spec.rb +61 -0
  210. data/spec/lib/zoom/actions/user/update_email_spec.rb +59 -0
  211. data/spec/lib/zoom/actions/user/update_password_spec.rb +29 -0
  212. data/spec/lib/zoom/actions/user/update_spec.rb +2 -2
  213. data/spec/lib/zoom/actions/user/update_status_spec.rb +59 -0
  214. data/spec/lib/zoom/actions/user/vanity_name_spec.rb +51 -0
  215. data/spec/lib/zoom/actions/webinar/create_spec.rb +49 -44
  216. data/spec/lib/zoom/actions/webinar/delete_spec.rb +3 -3
  217. data/spec/lib/zoom/actions/webinar/get_spec.rb +1 -1
  218. data/spec/lib/zoom/actions/webinar/list_spec.rb +2 -2
  219. data/spec/lib/zoom/actions/webinar/panelist_list_spec.rb +44 -0
  220. data/spec/lib/zoom/actions/webinar/past_webinar_list_spec.rb +44 -0
  221. data/spec/lib/zoom/actions/webinar/poll_get_spec.rb +47 -0
  222. data/spec/lib/zoom/actions/webinar/polls_list_spec.rb +44 -0
  223. data/spec/lib/zoom/actions/webinar/registrants/add_spec.rb +2 -2
  224. data/spec/lib/zoom/actions/webinar/registrants/get_spec.rb +49 -0
  225. data/spec/lib/zoom/actions/webinar/registrants/list_spec.rb +2 -2
  226. data/spec/lib/zoom/actions/webinar/registrants/update_status_spec.rb +1 -1
  227. data/spec/lib/zoom/actions/webinar/update_spec.rb +2 -2
  228. data/spec/lib/zoom/actions_spec.rb +84 -0
  229. data/spec/lib/zoom/client_spec.rb +85 -7
  230. data/spec/lib/zoom/params_spec.rb +23 -3
  231. data/spec/lib/zoom/utils_spec.rb +13 -18
  232. data/spec/spec_helper.rb +23 -2
  233. data/zoom_rb.gemspec +1 -1
  234. metadata +343 -112
  235. data/.ruby-version +0 -1
  236. data/lib/zoom/actions/group.rb +0 -8
  237. data/lib/zoom/actions/metrics.rb +0 -27
  238. data/lib/zoom/constants.rb +0 -103
  239. data/spec/fixtures/meeting/delete.json +0 -4
  240. data/spec/fixtures/meeting/end.json +0 -4
  241. data/spec/fixtures/meeting/live.json +0 -32
  242. data/spec/fixtures/meeting/register.json +0 -7
  243. data/spec/fixtures/meeting/update.json +0 -4
  244. data/spec/fixtures/metrics_crc.json +0 -105
  245. data/spec/fixtures/metrics_meetingdetail.json +0 -32
  246. data/spec/fixtures/recording_delete.json +0 -4
  247. data/spec/fixtures/recording_list.json +0 -51
  248. data/spec/fixtures/user/assistant/delete.json +0 -5
  249. data/spec/lib/zoom/actions/group/create_spec.rb +0 -3
  250. data/spec/lib/zoom/actions/group/get_spec.rb +0 -3
  251. data/spec/lib/zoom/actions/group/member/list_spec.rb +0 -3
  252. data/spec/lib/zoom/actions/meeting/end_spec.rb +0 -55
  253. data/spec/lib/zoom/actions/meeting/live_spec.rb +0 -43
  254. data/spec/lib/zoom/actions/meeting/register_spec.rb +0 -45
  255. data/spec/lib/zoom/actions/metrics/crc_spec.rb +0 -48
  256. data/spec/lib/zoom/actions/metrics/im_spec.rb +0 -3
  257. data/spec/lib/zoom/actions/metrics/meetingdetail_spec.rb +0 -51
  258. data/spec/lib/zoom/actions/metrics/meetings_spec.rb +0 -61
  259. data/spec/lib/zoom/actions/metrics/qos_spec.rb +0 -3
  260. data/spec/lib/zoom/actions/metrics/webinardetail_spec.rb +0 -3
  261. data/spec/lib/zoom/actions/metrics/webinars_spec.rb +0 -3
  262. data/spec/lib/zoom/actions/metrics/zoomroomdetail_spec.rb +0 -3
  263. data/spec/lib/zoom/actions/metrics/zoomrooms_spec.rb +0 -3
  264. data/spec/lib/zoom/actions/recording/delete_spec.rb +0 -52
  265. data/spec/lib/zoom/actions/recording/mc_list_spec.rb +0 -51
  266. data/spec/lib/zoom/actions/user/activate_spec.rb +0 -3
  267. data/spec/lib/zoom/actions/user/checkemail_spec.rb +0 -3
  268. data/spec/lib/zoom/actions/user/checkzpk_spec.rb +0 -3
  269. data/spec/lib/zoom/actions/user/deactivate_spec.rb +0 -3
  270. data/spec/lib/zoom/actions/user/revoketoken_spec.rb +0 -3
  271. data/spec/lib/zoom/actions/user/updatepassword_spec.rb +0 -3
  272. data/spec/lib/zoom/actions/webinar/panelists_spec.rb +0 -3
  273. data/spec/lib/zoom/actions/webinar/polls_spec.rb +0 -3
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Zoom::Actions::Billing do
6
+ let(:zc) { zoom_client }
7
+ let(:args) { { account_id: '1' } }
8
+
9
+ describe '#billing_plans_usage action' do
10
+ context 'with a valid response' do
11
+ before :each do
12
+ stub_request(
13
+ :get,
14
+ zoom_url("/accounts/#{args[:account_id]}/plans/usage")
15
+ ).to_return(body: json_response('billing', 'plans_usage'),
16
+ headers: { 'Content-Type' => 'application/json' })
17
+ end
18
+
19
+ it 'makes the request' do
20
+ zc.billing_plans_usage(args)
21
+ expect(WebMock).to have_requested(:get, zoom_url("/accounts/#{args[:account_id]}/plans/usage")).with(headers: request_headers)
22
+ end
23
+
24
+ it 'returns a hash' do
25
+ expect(zc.billing_plans_usage(args)).to be_kind_of(Hash)
26
+ end
27
+
28
+ it 'raises an error when missing a required param' do
29
+ expect { zc.billing_plans_usage }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s)
30
+ end
31
+ end
32
+
33
+ context 'with a 4xx response' do
34
+ before :each do
35
+ stub_request(
36
+ :get,
37
+ zoom_url("/accounts/#{args[:account_id]}/plans/usage")
38
+ ).to_return(status: 400,
39
+ body: json_response('error', 'not_found'),
40
+ headers: { 'Content-Type' => 'application/json' })
41
+ end
42
+
43
+ it 'raises Zoom::Error exception' do
44
+ expect { zc.billing_plans_usage(args) }.to raise_error(Zoom::Error)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Zoom::Actions::Billing do
6
+ let(:zc) { zoom_client }
7
+ let(:required_args) { { account_id: '1' } }
8
+ let(:permitted_args) {
9
+ {
10
+ first_name: 'Foo',
11
+ last_name: 'Bar',
12
+ email: 'foo@bar.com',
13
+ phone_number: '1234567890',
14
+ address: '123 Test Street',
15
+ apt: '',
16
+ city: 'Vancouver',
17
+ state: 'WA',
18
+ zip: '98660',
19
+ country: 'US'
20
+ }
21
+ }
22
+ let(:args) { required_args.merge(permitted_args) }
23
+
24
+ describe '#billing_update action' do
25
+ context 'with a valid response' do
26
+ before :each do
27
+ stub_request(
28
+ :patch,
29
+ zoom_url("/accounts/#{args[:account_id]}/billing")
30
+ ).to_return(status: 204,
31
+ body: json_response('billing', 'update'),
32
+ headers: { 'Content-Type' => 'application/json' })
33
+ end
34
+
35
+ it 'makes the request' do
36
+ zc.billing_update(args)
37
+ expect(WebMock).to have_requested(:patch, zoom_url("/accounts/#{args[:account_id]}/billing")).with(body: permitted_args.to_json, headers: request_headers)
38
+ end
39
+
40
+ it 'requires id param' do
41
+ expect { zc.billing_update }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s)
42
+ end
43
+
44
+ it 'returns a success response' do
45
+ expect(zc.billing_update(args)).to eql(204)
46
+ end
47
+ end
48
+
49
+ context 'with a 4xx response' do
50
+ before :each do
51
+ stub_request(
52
+ :patch,
53
+ zoom_url("/accounts/#{args[:account_id]}/billing")
54
+ ).to_return(status: 404,
55
+ body: json_response('error', 'validation'),
56
+ headers: { 'Content-Type' => 'application/json' })
57
+ end
58
+
59
+ it 'raises Zoom::Error exception' do
60
+ expect { zc.billing_update(args) }.to raise_error(Zoom::Error)
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Zoom::Actions::Dashboard do
6
+ let(:zc) { zoom_client }
7
+ let(:args) { { from: '2013-04-05T15:50:47Z', to: '2013-04-09T19:00:00Z' } }
8
+ let(:response) { zc.dashboard_crc(args) }
9
+
10
+ describe '#dashboard_crc get' do
11
+ before :each do
12
+ stub_request(
13
+ :get,
14
+ zoom_url('/metrics/crc')
15
+ ).to_return(status: 200,
16
+ body: json_response('dashboard','crc'),
17
+ headers: { 'Content-Type' => 'application/json' })
18
+ end
19
+
20
+ it "requires a 'from' argument" do
21
+ expect { zc.dashboard_crc(filter_key(args, :from)) }.to raise_error(Zoom::ParameterMissing)
22
+ end
23
+
24
+ it "requires a 'to' argument" do
25
+ expect { zc.dashboard_crc(filter_key(args, :to)) }.to raise_error(Zoom::ParameterMissing)
26
+ end
27
+
28
+ it 'returns a hash' do
29
+ expect(response).to be_kind_of(Hash)
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Zoom::Actions::Dashboard do
6
+
7
+ let(:zc) { zoom_client }
8
+ let(:args) { { meeting_id: 't13b6hjVQXybvGKyeHC96w==', type: 1 } }
9
+ let(:response) { zc.dashboard_meeting_details(args) }
10
+
11
+ describe '#dashboard_meeting_details action' do
12
+ context 'with 200 response' do
13
+ before :each do
14
+ stub_request(
15
+ :get,
16
+ zoom_url("/metrics/meetings/#{args[:meeting_id]}")
17
+ ).to_return(status: 200,
18
+ body: json_response('dashboard','meeting', 'detail'),
19
+ headers: { 'Content-Type' => 'application/json' })
20
+ end
21
+
22
+ it "requires a 'meeting_id' argument" do
23
+ expect { zc.dashboard_meeting_details(filter_key(args, :meeting_id)) }.to raise_error(Zoom::ParameterMissing)
24
+ end
25
+
26
+ it 'returns a hash' do
27
+ expect(response).to be_kind_of(Hash)
28
+ end
29
+ end
30
+
31
+ context 'with 300 response' do
32
+ before :each do
33
+ stub_request(
34
+ :get,
35
+ zoom_url("/metrics/meetings/#{args[:meeting_id]}")
36
+ ).to_return(status: 300,
37
+ body: '{ "code": 1001, "message": "The next page token is invalid or expired." }',
38
+ headers: { 'Content-Type' => 'application/json' })
39
+ end
40
+
41
+ it 'raises Zoom::Error exception' do
42
+ expect { response }.to raise_error(Zoom::Error)
43
+ end
44
+ end
45
+
46
+ context 'with 404 response' do
47
+ before :each do
48
+ stub_request(
49
+ :get,
50
+ zoom_url("/metrics/meetings/#{args[:meeting_id]}")
51
+ ).to_return(status: 404,
52
+ body: '{ "code": 3001, "message": "Meeting ID is invalid or the meeting has not ended yet. This meeting’s details are not available." }',
53
+ headers: { 'Content-Type' => 'application/json' })
54
+ end
55
+
56
+ it 'raises Zoom::Error exception' do
57
+ expect { response }.to raise_error(Zoom::Error)
58
+ end
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Zoom::Actions::Dashboard do
6
+
7
+ let(:zc) { zoom_client }
8
+ let(:args) { { meeting_id: 't13b6hjVQXybvGKyeHC96w==', type: 1 } }
9
+ let(:response) { zc.dashboard_meeting_participants(args) }
10
+
11
+ describe '#dashboard_meeting_participants action' do
12
+ context 'with 200 response' do
13
+ before :each do
14
+ stub_request(
15
+ :get,
16
+ zoom_url("/metrics/meetings/#{args[:meeting_id]}/participants")
17
+ ).to_return(status: 200,
18
+ body: json_response('dashboard','meeting', 'participants'),
19
+ headers: { 'Content-Type' => 'application/json' })
20
+ end
21
+
22
+ it "requires a 'meeting_id' argument" do
23
+ expect { zc.dashboard_meeting_participants(filter_key(args, :meeting_id)) }.to raise_error(Zoom::ParameterMissing)
24
+ end
25
+
26
+ it 'returns a hash' do
27
+ expect(response).to be_kind_of(Hash)
28
+ end
29
+
30
+ it "returns 'next_page_token'" do
31
+ expect(response['next_page_token']).to be_kind_of(String)
32
+ end
33
+
34
+ it "returns 'total_records'" do
35
+ expect(response['total_records']).to eq(2)
36
+ end
37
+
38
+ it "returns 'participants' Array" do
39
+ expect(response['participants']).to be_kind_of(Array)
40
+ end
41
+ end
42
+
43
+ context 'with 300 response' do
44
+ before :each do
45
+ stub_request(
46
+ :get,
47
+ zoom_url("/metrics/meetings/#{args[:meeting_id]}/participants")
48
+ ).to_return(status: 300,
49
+ body: '{ "code": 1001, "message": "Can not access webinar info. {meetingId} or the next page token is either invalid or expired." }',
50
+ headers: { 'Content-Type' => 'application/json' })
51
+ end
52
+
53
+ it 'raises Zoom::Error exception' do
54
+ expect { response }.to raise_error(Zoom::Error)
55
+ end
56
+ end
57
+
58
+ context 'with 404 response' do
59
+ before :each do
60
+ stub_request(
61
+ :get,
62
+ zoom_url("/metrics/meetings/#{args[:meeting_id]}/participants")
63
+ ).to_return(status: 404,
64
+ body: '{ "code": 3001, "message": "Meeting ID is invalid or not ended yet." }',
65
+ headers: { 'Content-Type' => 'application/json' })
66
+ end
67
+
68
+ it 'raises Zoom::Error exception' do
69
+ expect { response }.to raise_error(Zoom::Error)
70
+ end
71
+ end
72
+ end
73
+
74
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Zoom::Actions::Dashboard do
6
+ let(:zc) { zoom_client }
7
+ let(:args) { { type: 1, from: '2013-04-05T15:50:47Z', to: '2013-04-09T19:00:00Z' } }
8
+ let(:response) { zc.dashboard_meetings(args) }
9
+
10
+ describe '#dashboard_meetings action' do
11
+ context 'with 200 response' do
12
+ before :each do
13
+ stub_request(
14
+ :get,
15
+ zoom_url('/metrics/meetings')
16
+ ).to_return(status: 200,
17
+ body: json_response('dashboard','meetings'),
18
+ headers: { 'Content-Type' => 'application/json' })
19
+ end
20
+
21
+ it "requires a 'from' argument" do
22
+ expect { zc.dashboard_meetings(filter_key(args, :from)) }.to raise_error(Zoom::ParameterMissing)
23
+ end
24
+
25
+ it "requires a 'to' argument" do
26
+ expect { zc.dashboard_meetings(filter_key(args, :to)) }.to raise_error(Zoom::ParameterMissing)
27
+ end
28
+
29
+ it 'returns a hash' do
30
+ expect(zc.dashboard_meetings(args)).to be_kind_of(Hash)
31
+ end
32
+
33
+ it "returns 'next_page_token'" do
34
+ expect(response['next_page_token']).to be_kind_of(String)
35
+ end
36
+
37
+ it "returns 'total_records'" do
38
+ expect(response['total_records']).to eq(1)
39
+ end
40
+
41
+ it "returns 'meetings' Array" do
42
+ expect(response['meetings']).to be_kind_of(Array)
43
+ end
44
+ end
45
+
46
+ context 'with 300 response' do
47
+ before :each do
48
+ stub_request(
49
+ :get,
50
+ zoom_url('/metrics/meetings')
51
+ ).to_return(status: 300,
52
+ body: '{ "code": 300, "message": "Can not access webinar info, {meetingId}" }',
53
+ headers: { 'Content-Type' => 'application/json' })
54
+ end
55
+
56
+ it 'raises an error' do
57
+ expect { response }.to raise_error(Zoom::Error)
58
+ end
59
+ end
60
+
61
+ end
62
+
63
+ end
@@ -0,0 +1,98 @@
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) { { 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,62 @@
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: 2 } }
8
+ let(:wrong_args) { { group_id: 999999 } }
9
+
10
+ describe '#groups_get action' do
11
+ context 'with valid response' do
12
+ before :each do
13
+ stub_request(
14
+ :get,
15
+ zoom_url("/groups/#{args['group_id']}")
16
+ ).to_return(body: json_response('groups', 'get'), headers: { 'Content-Type' => 'application/json' })
17
+ end
18
+
19
+ it 'returns a hash' do
20
+ expect(zc.groups_get(args)).to be_kind_of(Hash)
21
+ end
22
+
23
+ it "return 'name' parameter" do
24
+ expect(zc.groups_get(args)['name']).not_to be_nil
25
+ end
26
+ end
27
+
28
+ context 'with a 404 response' do
29
+ before :each do
30
+ stub_request(
31
+ :get,
32
+ zoom_url("/groups/#{wrong_args['group_id']}")
33
+ ).to_return(status: 404,
34
+ body: json_response('error', 'group_does_not_exist'),
35
+ headers: { 'Content-Type' => 'application/json' })
36
+ end
37
+
38
+ it 'raises Zoom::Error exception with text' do
39
+ expect { zc.groups_get(wrong_args) }.to raise_error(Zoom::Error, {
40
+ base: 'A group with this 999999 does not exist.'
41
+ }.to_s)
42
+ end
43
+ end
44
+
45
+ context 'with a 400 response' do
46
+ before :each do
47
+ stub_request(
48
+ :get,
49
+ zoom_url("/groups/#{wrong_args['group_id']}")
50
+ ).to_return(status: 400,
51
+ body: json_response('error', 'group_not_belong_to_account'),
52
+ headers: { 'Content-Type' => 'application/json' })
53
+ end
54
+
55
+ it 'raises Zoom::Error exception with text' do
56
+ expect { zc.groups_get(wrong_args) }.to raise_error(Zoom::Error, {
57
+ base: 'Group does not belong to your account.'
58
+ }.to_s)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Zoom::Actions::Groups do
6
+ let(:zc) { zoom_client }
7
+
8
+ describe '#groups_list action' do
9
+ context 'with valid response' do
10
+ before :each do
11
+ stub_request(
12
+ :get,
13
+ zoom_url('/groups')
14
+ ).to_return(body: json_response('groups', 'list'), headers: { 'Content-Type' => 'application/json' })
15
+ end
16
+
17
+ it 'returns a hash' do
18
+ expect(zc.groups_list).to be_kind_of(Hash)
19
+ end
20
+
21
+ it "returns 'total_records'" do
22
+ expect(zc.groups_list['total_records']).to eq(2)
23
+ end
24
+
25
+ it "returns 'groups' Array" do
26
+ expect(zc.groups_list['groups']).to be_kind_of(Array)
27
+ end
28
+ end
29
+
30
+ context 'with a 404 response' do
31
+ before :each do
32
+ stub_request(
33
+ :get,
34
+ zoom_url("/groups")
35
+ ).to_return(status: 404,
36
+ body: json_response('error', 'group_does_not_exist'),
37
+ headers: { 'Content-Type' => 'application/json' })
38
+ end
39
+
40
+ it 'raises Zoom::Error exception with text' do
41
+ expect { zc.groups_list }.to raise_error(Zoom::Error, {
42
+ base: 'A group with this 999999 does not exist.'
43
+ }.to_s)
44
+ end
45
+ end
46
+ end
47
+ 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