zoom_rb 0.9.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +1 -1
  3. data/CHANGELOG.md +58 -0
  4. data/Gemfile.lock +85 -51
  5. data/Makefile +1 -1
  6. data/README.md +31 -3
  7. data/lib/zoom/actions/account.rb +18 -76
  8. data/lib/zoom/actions/billing.rb +41 -0
  9. data/lib/zoom/actions/dashboard.rb +22 -0
  10. data/lib/zoom/actions/groups.rb +19 -0
  11. data/lib/zoom/actions/im/chat.rb +13 -14
  12. data/lib/zoom/actions/meeting.rb +38 -63
  13. data/lib/zoom/actions/phone.rb +15 -0
  14. data/lib/zoom/actions/recording.rb +13 -22
  15. data/lib/zoom/actions/report.rb +8 -43
  16. data/lib/zoom/actions/roles.rb +24 -0
  17. data/lib/zoom/actions/sip_audio.rb +34 -0
  18. data/lib/zoom/actions/token.rb +26 -0
  19. data/lib/zoom/actions/user.rb +66 -139
  20. data/lib/zoom/actions/webinar.rb +43 -84
  21. data/lib/zoom/actions.rb +59 -0
  22. data/lib/zoom/client.rb +27 -16
  23. data/lib/zoom/clients/jwt.rb +22 -0
  24. data/lib/zoom/clients/oauth.rb +60 -0
  25. data/lib/zoom/constants/account/options/pay_modes.rb +12 -0
  26. data/lib/zoom/constants/account/settings/permitted_settings.rb +125 -0
  27. data/lib/zoom/constants/constants.rb +35 -0
  28. data/lib/zoom/constants/meeting/approval_types.rb +11 -0
  29. data/lib/zoom/constants/meeting/audio_type.rb +11 -0
  30. data/lib/zoom/constants/meeting/auto_recording.rb +11 -0
  31. data/lib/zoom/constants/meeting/registration_types.rb +11 -0
  32. data/lib/zoom/constants/meeting/types.rb +12 -0
  33. data/lib/zoom/constants/recurrence/monthly_weeks.rb +13 -0
  34. data/lib/zoom/constants/recurrence/types.rb +11 -0
  35. data/lib/zoom/constants/recurrence/weekly_days.rb +15 -0
  36. data/lib/zoom/constants/user/create_types.rb +12 -0
  37. data/lib/zoom/constants/user/types.rb +11 -0
  38. data/lib/zoom/constants/webinar/approval_types.rb +11 -0
  39. data/lib/zoom/constants/webinar/audio_type.rb +11 -0
  40. data/lib/zoom/constants/webinar/auto_recording.rb +11 -0
  41. data/lib/zoom/constants/webinar/registration_types.rb +11 -0
  42. data/lib/zoom/constants/webinar/types.rb +11 -0
  43. data/lib/zoom/error.rb +9 -1
  44. data/lib/zoom/params.rb +51 -12
  45. data/lib/zoom/utils.rb +22 -38
  46. data/lib/zoom/version.rb +2 -2
  47. data/lib/{zoom.rb → zoom_rb.rb} +12 -5
  48. data/spec/fixtures/account/create.json +6 -0
  49. data/spec/{lib/zoom/actions/report/hosts_report_spec.rb → fixtures/account/delete.json} +0 -0
  50. data/spec/fixtures/account/get.json +13 -0
  51. data/spec/fixtures/account/list.json +18 -0
  52. data/spec/fixtures/account/managed_domains.json +7 -0
  53. data/spec/fixtures/account/options_update.json +7 -0
  54. data/spec/fixtures/account/settings_get.json +120 -0
  55. data/spec/{lib/zoom/actions/report/meeting_polls_report_spec.rb → fixtures/account/settings_update.json} +0 -0
  56. data/spec/fixtures/account/trusted_domains.json +3 -0
  57. data/spec/fixtures/billing/get.json +12 -0
  58. data/spec/fixtures/billing/plans_list.json +44 -0
  59. data/spec/fixtures/billing/plans_subscribe.json +30 -0
  60. data/spec/fixtures/billing/plans_usage.json +30 -0
  61. data/spec/{lib/zoom/actions/report/meetings_report_spec.rb → fixtures/billing/update.json} +0 -0
  62. data/spec/fixtures/chat/channels/get.json +5 -0
  63. data/spec/fixtures/chat/users/channels/list.json +17 -0
  64. data/spec/fixtures/dashboard/crc.json +104 -0
  65. data/spec/fixtures/dashboard/meeting/detail.json +20 -0
  66. data/spec/fixtures/dashboard/meeting/participants.json +56 -0
  67. data/spec/fixtures/{metrics_meetings.json → dashboard/meetings.json} +1 -2
  68. data/spec/fixtures/error/admin_cannot_activated.json +4 -0
  69. data/spec/fixtures/error/channel_not_found.json +4 -0
  70. data/spec/fixtures/error/group_does_not_exist.json +4 -0
  71. data/spec/fixtures/error/group_not_belong_to_account.json +4 -0
  72. data/spec/fixtures/error/group_not_exist.json +4 -0
  73. data/spec/fixtures/error/meeting_not_exist.json +4 -0
  74. data/spec/fixtures/error/next_page_token_invalid.json +4 -0
  75. data/spec/fixtures/error/not_found_administrator.json +4 -0
  76. data/spec/fixtures/error/unauthorized_request.json +4 -0
  77. data/spec/fixtures/error/user_not_exist.json +1 -1
  78. data/spec/fixtures/groups/create.json +5 -0
  79. data/spec/fixtures/groups/get.json +5 -0
  80. data/spec/fixtures/groups/list.json +15 -0
  81. data/spec/{lib/zoom/actions/report/telephone_report_spec.rb → fixtures/groups/update.json} +0 -0
  82. data/spec/fixtures/meeting/add_registrant.json +7 -0
  83. data/spec/fixtures/meeting/create.json +31 -16
  84. data/spec/fixtures/meeting/get.json +43 -33
  85. data/spec/fixtures/meeting/invitation.json +3 -0
  86. data/spec/fixtures/meeting/live_stream/errors/meeting_not_found.json +4 -0
  87. data/spec/fixtures/meeting/live_stream/errors/missing_field.json +10 -0
  88. data/spec/fixtures/{recording_get.json → recording/get.json} +17 -6
  89. data/spec/fixtures/recording/list.json +53 -0
  90. data/spec/fixtures/recording/settings/get.json +7 -0
  91. data/spec/fixtures/report/meeting/participants.json +17 -0
  92. data/spec/fixtures/report/meeting.json +19 -0
  93. data/spec/fixtures/roles/assign.json +4 -0
  94. data/spec/fixtures/roles/create.json +9 -0
  95. data/spec/fixtures/roles/get.json +11 -0
  96. data/spec/fixtures/roles/list.json +29 -0
  97. data/spec/fixtures/roles/members.json +15 -0
  98. data/spec/fixtures/sip_audio/sip_trunks_get.json +19 -0
  99. data/spec/fixtures/sip_audio/sip_trunks_internal_callout_countries_add.json +10 -0
  100. data/spec/fixtures/sip_audio/sip_trunks_internal_callout_country_list.json +15 -0
  101. data/spec/fixtures/sip_audio/sip_trunks_internal_numbers_add.json +14 -0
  102. data/spec/fixtures/sip_audio/sip_trunks_internal_numbers_list.json +16 -0
  103. data/spec/fixtures/sip_audio/sip_trunks_numbers_assign.json +7 -0
  104. data/spec/fixtures/sip_audio/sip_trunks_numbers_list.json +9 -0
  105. data/spec/fixtures/token/access_token.json +7 -0
  106. data/spec/fixtures/token/data_compliance.json +8 -0
  107. data/spec/fixtures/token/refresh_token.json +7 -0
  108. data/spec/fixtures/user/assistant/create.json +4 -0
  109. data/spec/fixtures/user/assistant/list.json +8 -0
  110. data/spec/fixtures/user/email_check.json +3 -0
  111. data/spec/fixtures/user/get.json +35 -21
  112. data/spec/fixtures/user/list.json +17 -13
  113. data/spec/fixtures/user/permissions.json +65 -0
  114. data/spec/fixtures/user/recording/list.json +50 -0
  115. data/spec/fixtures/user/scheduler/list.json +12 -0
  116. data/spec/fixtures/user/settings_get.json +74 -0
  117. data/spec/fixtures/user/token.json +3 -0
  118. data/spec/{lib/zoom/actions/report/webinar_details_report_spec.rb → fixtures/user/update_email.json} +0 -0
  119. data/spec/{lib/zoom/actions/report/webinar_polls_report_spec.rb → fixtures/user/update_password.json} +0 -0
  120. data/spec/{lib/zoom/actions/report/webinar_qa_report_spec.rb → fixtures/user/update_status.json} +0 -0
  121. data/spec/fixtures/user/vanity_name.json +3 -0
  122. data/spec/fixtures/webinar/panelist_list.json +12 -0
  123. data/spec/fixtures/webinar/poll_get.json +13 -0
  124. data/spec/fixtures/webinar/polls_list.json +16 -0
  125. data/spec/fixtures/webinar/registrant/get.json +25 -0
  126. data/spec/lib/zoom/actions/account/create_spec.rb +68 -0
  127. data/spec/lib/zoom/actions/account/delete_spec.rb +44 -0
  128. data/spec/lib/zoom/actions/account/get_locked_settings_spec.rb +43 -0
  129. data/spec/lib/zoom/actions/account/get_spec.rb +43 -0
  130. data/spec/lib/zoom/actions/account/list_spec.rb +58 -0
  131. data/spec/lib/zoom/actions/account/managed_domains_spec.rb +43 -0
  132. data/spec/lib/zoom/actions/account/options_update_spec.rb +58 -0
  133. data/spec/lib/zoom/actions/account/settings_get_spec.rb +50 -0
  134. data/spec/lib/zoom/actions/account/settings_update_spec.rb +55 -0
  135. data/spec/lib/zoom/actions/account/trusted_domains_spec.rb +43 -0
  136. data/spec/lib/zoom/actions/billing/get_spec.rb +48 -0
  137. data/spec/lib/zoom/actions/billing/plans_list_spec.rb +48 -0
  138. data/spec/lib/zoom/actions/billing/plans_subscribe_spec.rb +69 -0
  139. data/spec/lib/zoom/actions/billing/plans_usage_spec.rb +48 -0
  140. data/spec/lib/zoom/actions/billing/update_spec.rb +64 -0
  141. data/spec/lib/zoom/actions/dashboard/crc_spec.rb +33 -0
  142. data/spec/lib/zoom/actions/dashboard/meeting_details_spec.rb +62 -0
  143. data/spec/lib/zoom/actions/dashboard/meeting_participants_spec.rb +74 -0
  144. data/spec/lib/zoom/actions/dashboard/meetings_spec.rb +63 -0
  145. data/spec/lib/zoom/actions/groups/create_spec.rb +98 -0
  146. data/spec/lib/zoom/actions/{group → groups}/delete_spec.rb +0 -0
  147. data/spec/lib/zoom/actions/{group → groups}/edit_spec.rb +0 -0
  148. data/spec/lib/zoom/actions/groups/get_spec.rb +62 -0
  149. data/spec/lib/zoom/actions/groups/list_spec.rb +47 -0
  150. data/spec/lib/zoom/actions/{group → groups}/member/add_spec.rb +0 -0
  151. data/spec/lib/zoom/actions/{group → groups}/member/delete_spec.rb +0 -0
  152. data/spec/lib/zoom/actions/{group → groups/member}/list_spec.rb +0 -0
  153. data/spec/lib/zoom/actions/groups/update_spec.rb +59 -0
  154. data/spec/lib/zoom/actions/im/chat/channels/get_spec.rb +64 -0
  155. data/spec/lib/zoom/actions/im/chat/users/channels/get_spec.rb +45 -0
  156. data/spec/lib/zoom/actions/meeting/add_registrant_spec.rb +30 -0
  157. data/spec/lib/zoom/actions/meeting/create_spec.rb +13 -13
  158. data/spec/lib/zoom/actions/meeting/delete_spec.rb +17 -34
  159. data/spec/lib/zoom/actions/meeting/get_spec.rb +21 -31
  160. data/spec/lib/zoom/actions/meeting/invitation_spec.rb +48 -0
  161. data/spec/lib/zoom/actions/meeting/livestream_spec.rb +61 -0
  162. data/spec/lib/zoom/actions/meeting/update_spec.rb +48 -42
  163. data/spec/lib/zoom/actions/recording/file_delete_spec.rb +33 -0
  164. data/spec/lib/zoom/actions/recording/get_spec.rb +19 -35
  165. data/spec/lib/zoom/actions/recording/list_spec.rb +20 -26
  166. data/spec/lib/zoom/actions/recording/settings/get_spec.rb +42 -0
  167. data/spec/lib/zoom/actions/recording/settings/update_spec.rb +32 -0
  168. data/spec/lib/zoom/actions/report/meeting_details_report_spec.rb +44 -0
  169. data/spec/lib/zoom/actions/report/meeting_participants_report_spec.rb +44 -0
  170. data/spec/lib/zoom/actions/roles/assign_spec.rb +25 -0
  171. data/spec/lib/zoom/actions/roles/create_spec.rb +55 -0
  172. data/spec/lib/zoom/actions/roles/get_spec.rb +37 -0
  173. data/spec/lib/zoom/actions/roles/list_spec.rb +28 -0
  174. data/spec/lib/zoom/actions/roles/members_spec.rb +35 -0
  175. data/spec/lib/zoom/actions/roles/unassign_spec.rb +34 -0
  176. data/spec/lib/zoom/actions/sip_audio/add_trunks_internal_callout_countries_spec.rb +25 -0
  177. data/spec/lib/zoom/actions/sip_audio/add_trunks_internal_numbers_spec.rb +25 -0
  178. data/spec/lib/zoom/actions/sip_audio/assign_numbers_spec.rb +29 -0
  179. data/spec/lib/zoom/actions/sip_audio/delete_internal_callout_countries_spec.rb +44 -0
  180. data/spec/lib/zoom/actions/sip_audio/delete_trunk_internal_numbers_spec.rb +44 -0
  181. data/spec/lib/zoom/actions/sip_audio/delete_trunk_numbers_spec.rb +44 -0
  182. data/spec/lib/zoom/actions/sip_audio/delete_trunks_spec.rb +44 -0
  183. data/spec/lib/zoom/actions/sip_audio/get_trunks_spec.rb +50 -0
  184. data/spec/lib/zoom/actions/sip_audio/list_trunk_numbers_spec.rb +46 -0
  185. data/spec/lib/zoom/actions/sip_audio/list_trunks_internal_callout_country_spec.rb +53 -0
  186. data/spec/lib/zoom/actions/sip_audio/list_trunks_internal_numbers_spec.rb +53 -0
  187. data/spec/lib/zoom/actions/token/access_token_spec.rb +26 -0
  188. data/spec/lib/zoom/actions/token/data_compliance_spec.rb +41 -0
  189. data/spec/lib/zoom/actions/token/refresh_token_spec.rb +26 -0
  190. data/spec/lib/zoom/actions/user/assistant/create_spec.rb +59 -0
  191. data/spec/lib/zoom/actions/user/assistant/delete_all_spec.rb +44 -0
  192. data/spec/lib/zoom/actions/user/assistant/delete_spec.rb +48 -1
  193. data/spec/lib/zoom/actions/user/assistant/list_spec.rb +53 -0
  194. data/spec/lib/zoom/actions/user/create_spec.rb +18 -46
  195. data/spec/lib/zoom/actions/user/email_check_spec.rb +43 -0
  196. data/spec/lib/zoom/actions/user/get_spec.rb +10 -1
  197. data/spec/lib/zoom/actions/user/list_recordings_spec.rb +57 -0
  198. data/spec/lib/zoom/actions/user/list_spec.rb +32 -1
  199. data/spec/lib/zoom/actions/user/permissions_spec.rb +52 -0
  200. data/spec/lib/zoom/actions/user/scheduler/delete_all_spec.rb +44 -0
  201. data/spec/lib/zoom/actions/user/scheduler/delete_spec.rb +50 -0
  202. data/spec/lib/zoom/actions/user/scheduler/list_spec.rb +53 -0
  203. data/spec/lib/zoom/actions/user/settings_get_spec.rb +56 -0
  204. data/spec/lib/zoom/actions/user/settings_update_spec.rb +50 -0
  205. data/spec/lib/zoom/actions/user/token_spec.rb +61 -0
  206. data/spec/lib/zoom/actions/user/update_email_spec.rb +59 -0
  207. data/spec/lib/zoom/actions/user/update_password_spec.rb +29 -0
  208. data/spec/lib/zoom/actions/user/update_status_spec.rb +59 -0
  209. data/spec/lib/zoom/actions/user/vanity_name_spec.rb +51 -0
  210. data/spec/lib/zoom/actions/webinar/create_spec.rb +49 -44
  211. data/spec/lib/zoom/actions/webinar/panelist_list_spec.rb +44 -0
  212. data/spec/lib/zoom/actions/webinar/poll_get_spec.rb +47 -0
  213. data/spec/lib/zoom/actions/webinar/polls_list_spec.rb +44 -0
  214. data/spec/lib/zoom/actions/webinar/registrants/get_spec.rb +49 -0
  215. data/spec/lib/zoom/actions_spec.rb +105 -0
  216. data/spec/lib/zoom/client_spec.rb +85 -7
  217. data/spec/lib/zoom/params_spec.rb +23 -3
  218. data/spec/lib/zoom/utils_spec.rb +13 -18
  219. data/spec/spec_helper.rb +23 -2
  220. data/zoom_rb.gemspec +1 -1
  221. metadata +339 -111
  222. data/lib/zoom/actions/group.rb +0 -8
  223. data/lib/zoom/actions/metrics.rb +0 -27
  224. data/lib/zoom/constants.rb +0 -103
  225. data/spec/fixtures/meeting/delete.json +0 -4
  226. data/spec/fixtures/meeting/end.json +0 -4
  227. data/spec/fixtures/meeting/live.json +0 -32
  228. data/spec/fixtures/meeting/register.json +0 -7
  229. data/spec/fixtures/meeting/update.json +0 -4
  230. data/spec/fixtures/metrics_crc.json +0 -105
  231. data/spec/fixtures/metrics_meetingdetail.json +0 -32
  232. data/spec/fixtures/recording_delete.json +0 -4
  233. data/spec/fixtures/recording_list.json +0 -51
  234. data/spec/fixtures/user/assistant/delete.json +0 -5
  235. data/spec/lib/zoom/actions/group/create_spec.rb +0 -3
  236. data/spec/lib/zoom/actions/group/get_spec.rb +0 -3
  237. data/spec/lib/zoom/actions/group/member/list_spec.rb +0 -3
  238. data/spec/lib/zoom/actions/meeting/end_spec.rb +0 -55
  239. data/spec/lib/zoom/actions/meeting/live_spec.rb +0 -43
  240. data/spec/lib/zoom/actions/meeting/register_spec.rb +0 -45
  241. data/spec/lib/zoom/actions/metrics/crc_spec.rb +0 -48
  242. data/spec/lib/zoom/actions/metrics/im_spec.rb +0 -3
  243. data/spec/lib/zoom/actions/metrics/meetingdetail_spec.rb +0 -51
  244. data/spec/lib/zoom/actions/metrics/meetings_spec.rb +0 -61
  245. data/spec/lib/zoom/actions/metrics/qos_spec.rb +0 -3
  246. data/spec/lib/zoom/actions/metrics/webinardetail_spec.rb +0 -3
  247. data/spec/lib/zoom/actions/metrics/webinars_spec.rb +0 -3
  248. data/spec/lib/zoom/actions/metrics/zoomroomdetail_spec.rb +0 -3
  249. data/spec/lib/zoom/actions/metrics/zoomrooms_spec.rb +0 -3
  250. data/spec/lib/zoom/actions/recording/delete_spec.rb +0 -52
  251. data/spec/lib/zoom/actions/recording/mc_list_spec.rb +0 -51
  252. data/spec/lib/zoom/actions/user/activate_spec.rb +0 -3
  253. data/spec/lib/zoom/actions/user/checkemail_spec.rb +0 -3
  254. data/spec/lib/zoom/actions/user/checkzpk_spec.rb +0 -3
  255. data/spec/lib/zoom/actions/user/deactivate_spec.rb +0 -3
  256. data/spec/lib/zoom/actions/user/revoketoken_spec.rb +0 -3
  257. data/spec/lib/zoom/actions/user/updatepassword_spec.rb +0 -3
  258. data/spec/lib/zoom/actions/webinar/panelists_spec.rb +0 -3
  259. data/spec/lib/zoom/actions/webinar/polls_spec.rb +0 -3
@@ -3,51 +3,56 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe Zoom::Actions::Webinar do
6
- let(:zc) { zoom_client }
7
- let(:args) { { host_id: 'test_user_id' } }
8
-
9
- describe '#webinar_create' do
10
- context 'with a valid response' do
11
- before :each do
12
- stub_request(
13
- :post,
14
- zoom_url("/users/#{args[:host_id]}/webinars")
15
- ).to_return(body: json_response('webinar', 'create'),
16
- headers: { 'Content-Type' => 'application/json' })
17
- end
18
-
19
- it "requires a 'host_id' argument" do
20
- expect { zc.webinar_create(filter_key(args, :host_id)) }.to raise_error(Zoom::ParameterMissing, [:host_id].to_s)
21
- end
22
-
23
- it 'returns a hash' do
24
- expect(zc.webinar_create(args)).to be_kind_of(Hash)
25
- end
26
-
27
- it 'returns the setted params' do
28
- res = zc.webinar_create(args)
29
- expect(res['host_id']).to eq(args[:host_id])
30
- end
31
-
32
- it "returns 'start_url' and 'join_url'" do
33
- res = zc.webinar_create(args)
34
-
35
- expect(res['start_url']).to_not be_nil
36
- expect(res['join_url']).to_not be_nil
37
- end
38
- end
39
-
40
- context 'with a 4xx response' do
41
- before :each do
42
- stub_request(
43
- :post,
44
- zoom_url("/users/#{args[:host_id]}/webinars")
45
- ).to_return(body: json_response('error', 'validation'),
46
- headers: { 'Content-Type' => 'application/json' })
47
- end
48
6
 
49
- it 'raises Zoom::Error exception' do
50
- expect { zc.webinar_create(args) }.to raise_error(Zoom::Error)
7
+ [:jwt_client, :oauth_client].each do |client|
8
+ describe "#{client}" do
9
+ let(:zc) { send(client) }
10
+ let(:args) { { host_id: 'test_user_id' } }
11
+
12
+ describe '#webinar_create' do
13
+ context 'with a valid response' do
14
+ before :each do
15
+ stub_request(
16
+ :post,
17
+ zoom_url("/users/#{args[:host_id]}/webinars")
18
+ ).to_return(body: json_response('webinar', 'create'),
19
+ headers: { 'Content-Type' => 'application/json' })
20
+ end
21
+
22
+ it "requires a 'host_id' argument" do
23
+ expect { zc.webinar_create(filter_key(args, :host_id)) }.to raise_error(Zoom::ParameterMissing, [:host_id].to_s)
24
+ end
25
+
26
+ it 'returns a hash' do
27
+ expect(zc.webinar_create(args)).to be_kind_of(Hash)
28
+ end
29
+
30
+ it 'returns the setted params' do
31
+ res = zc.webinar_create(args)
32
+ expect(res['host_id']).to eq(args[:host_id])
33
+ end
34
+
35
+ it "returns 'start_url' and 'join_url'" do
36
+ res = zc.webinar_create(args)
37
+
38
+ expect(res['start_url']).to_not be_nil
39
+ expect(res['join_url']).to_not be_nil
40
+ end
41
+ end
42
+
43
+ context 'with a 4xx response' do
44
+ before :each do
45
+ stub_request(
46
+ :post,
47
+ zoom_url("/users/#{args[:host_id]}/webinars")
48
+ ).to_return(body: json_response('error', 'validation'),
49
+ headers: { 'Content-Type' => 'application/json' })
50
+ end
51
+
52
+ it 'raises Zoom::Error exception' do
53
+ expect { zc.webinar_create(args) }.to raise_error(Zoom::Error)
54
+ end
55
+ end
51
56
  end
52
57
  end
53
58
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Zoom::Actions::Webinar do
6
+ let(:zc) { zoom_client }
7
+ let(:args) { { webinar_id: '123456789' } }
8
+
9
+ describe '#webinar_panelist_list' do
10
+ context 'with a valid response' do
11
+ before :each do
12
+ stub_request(
13
+ :get,
14
+ zoom_url("/webinars/#{args[:webinar_id]}/panelists")
15
+ ).to_return(status: 200,
16
+ body: json_response('webinar', 'panelist_list'),
17
+ headers: { 'Content-Type' => 'application/json' })
18
+ end
19
+
20
+ it "requires a 'id' argument" do
21
+ expect { zc.webinar_panelist_list(filter_key(args, :webinar_id)) }.to raise_error(Zoom::ParameterMissing, [:webinar_id].to_s)
22
+ end
23
+
24
+ it 'returns a list of panelists as an array' do
25
+ expect(zc.webinar_panelist_list(args)['panelists']).to be_kind_of(Array)
26
+ end
27
+ end
28
+
29
+ context 'with a 4xx response' do
30
+ before :each do
31
+ stub_request(
32
+ :get,
33
+ zoom_url("/webinars/#{args[:webinar_id]}/panelists")
34
+ ).to_return(status: 404,
35
+ body: json_response('error', 'validation'),
36
+ headers: { 'Content-Type' => 'application/json' })
37
+ end
38
+
39
+ it 'raises Zoom::Error exception' do
40
+ expect { zc.webinar_panelist_list(args) }.to raise_error(Zoom::Error)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,47 @@
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: 'foo', poll_id: 'bar' } }
8
+
9
+ describe '#webinar_poll_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]}/polls/#{args[:poll_id]}")
15
+ ).to_return(status: :ok,
16
+ body: json_response('webinar', 'poll_get'),
17
+ headers: { 'Content-Type' => 'application/json' })
18
+ end
19
+
20
+ it "requires a 'webinar_id' argument" do
21
+ expect { zc.webinar_poll_get(filter_key(args, :webinar_id)) }.to raise_error(Zoom::ParameterMissing, [:webinar_id].to_s)
22
+ end
23
+
24
+ it "requires a 'poll_id' argument" do
25
+ expect { zc.webinar_poll_get(filter_key(args, :poll_id)) }.to raise_error(Zoom::ParameterMissing, [:poll_id].to_s)
26
+ end
27
+
28
+ it 'returns a hash' do
29
+ expect(zc.webinar_poll_get(args)).to be_a(Hash)
30
+ end
31
+ end
32
+
33
+ context 'with a 4xx response' do
34
+ before :each do
35
+ stub_request(
36
+ :get,
37
+ zoom_url("/webinars/#{args[:webinar_id]}/polls/#{args[:poll_id]}")
38
+ ).to_return(body: json_response('error', 'validation'),
39
+ headers: { 'Content-Type' => 'application/json' })
40
+ end
41
+
42
+ it 'raises Zoom::Error exception' do
43
+ expect { zc.webinar_poll_get(args) }.to raise_error(Zoom::Error)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Zoom::Actions::Webinar do
6
+ let(:zc) { zoom_client }
7
+ let(:args) { { webinar_id: '123456789' } }
8
+
9
+ describe '#webinar_polls_list' do
10
+ context 'with a valid response' do
11
+ before :each do
12
+ stub_request(
13
+ :get,
14
+ zoom_url("/webinars/#{args[:webinar_id]}/polls")
15
+ ).to_return(status: :ok,
16
+ body: json_response('webinar', 'polls_list'),
17
+ headers: { 'Content-Type' => 'application/json' })
18
+ end
19
+
20
+ it "requires a 'webinar_id' argument" do
21
+ expect { zc.webinar_polls_list(filter_key(args, :webinar_id)) }.to raise_error(Zoom::ParameterMissing, [:webinar_id].to_s)
22
+ end
23
+
24
+ it 'returns the http status code as a number' do
25
+ expect(zc.webinar_polls_list(args)['polls']).to be_an(Array)
26
+ end
27
+ end
28
+
29
+ context 'with a 4xx response' do
30
+ before :each do
31
+ stub_request(
32
+ :get,
33
+ zoom_url("/webinars/#{args[:webinar_id]}/polls")
34
+ ).to_return(status: 404,
35
+ body: json_response('error', 'not_found'),
36
+ headers: { 'Content-Type' => 'application/json' })
37
+ end
38
+
39
+ it 'raises an error' do
40
+ expect { zc.webinar_polls_list(args) }.to raise_error(Zoom::Error)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -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
@@ -0,0 +1,105 @@
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(:oauth) { false }
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, request_options) }
27
+
28
+ let(:request_options) { Zoom::Actions.determine_request_options(client, oauth) }
29
+
30
+ context 'when get' do
31
+ let(:method) { :get }
32
+
33
+ it 'calls get method on client with get request_options' do
34
+ request_options[:query] = params
35
+ expect(client.class).to receive(method).with(parsed_path, **request_options)
36
+ subject
37
+ end
38
+ end
39
+
40
+ context 'when post' do
41
+ let(:method) { :post }
42
+
43
+ it 'calls post method on client with post request_options' do
44
+ request_options[:body] = params.to_json
45
+ expect(client.class).to receive(method).with(parsed_path, **request_options)
46
+ subject
47
+ end
48
+ end
49
+
50
+ context 'when put' do
51
+ let(:method) { :put }
52
+
53
+ it 'calls put method on client with put request_options' do
54
+ request_options[:body] = params.to_json
55
+ expect(client.class).to receive(method).with(parsed_path, **request_options)
56
+ subject
57
+ end
58
+ end
59
+
60
+ context 'when patch' do
61
+ let(:method) { :patch }
62
+
63
+ it 'calls patch method on client with patch request_options' do
64
+ request_options[:body] = params.to_json
65
+ expect(client.class).to receive(method).with(parsed_path, **request_options)
66
+ subject
67
+ end
68
+ end
69
+
70
+ context 'when delete' do
71
+ let(:method) { :delete }
72
+
73
+ it 'calls delete method on client with delete request_options' do
74
+ expect(client.class).to receive(method).with(parsed_path, **request_options)
75
+ subject
76
+ end
77
+ end
78
+
79
+ context 'when oauth' do
80
+ let(:method) { :get }
81
+ let(:oauth) { true }
82
+
83
+ it 'passes oauth request options' do
84
+ request_options[:query] = params
85
+ expect(request_options[:headers]).to eq(client.oauth_request_headers)
86
+ expect(request_options[:base_uri]).to eq('https://zoom.us/')
87
+ expect(client.class).to receive(method).with(parsed_path, **request_options)
88
+ subject
89
+ end
90
+ end
91
+
92
+ context 'when not oauth' do
93
+ let(:method) { :get }
94
+ let(:oauth) { false }
95
+
96
+ it 'passes standard request options' do
97
+ request_options[:query] = params
98
+ expect(request_options[:headers]).to eq(client.request_headers)
99
+ expect(request_options[:base_uri]).to be_nil
100
+ expect(client.class).to receive(method).with(parsed_path, **request_options)
101
+ subject
102
+ end
103
+ end
104
+ end
105
+ end
@@ -2,11 +2,12 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- xdescribe Zoom::Client do
5
+ describe Zoom::Client do
6
6
 
7
- xdescribe 'default attributes' do
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
- xdescribe 'constructor' do
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(ArgumentError)
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(Zoom::Client.new(api_key: 'xxx', api_secret: 'xxx', timeout: 15)).to be_an_instance_of(Zoom::Client)
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(Zoom::ParameterMissing)
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(Zoom::ParameterNotPermitted)
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(Zoom::ParameterNotPermitted)
51
+ expect { params.require(:foo).permit(:bar, :bang) }.not_to raise_error
32
52
  end
33
53
 
34
54
  context 'raises an error' do
@@ -2,21 +2,26 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- xdescribe Zoom::Utils do
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
- xdescribe '#argument_error' do
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
- xdescribe '#raise_if_error!' do
18
- it 'raises Zoom::Error if error is present' do
19
- response = { 'error' => { 'message' => 'lol error' } }
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
- xdescribe '#require_params' do
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
- xdescribe '#process_datetime_params' do
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!(:bar, args)
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 'zoom'
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
- def zoom_client
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', '~> 0'
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'