zoom_rb 0.11.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/Gemfile.lock +6 -6
  4. data/README.md +0 -4
  5. data/lib/zoom/actions/account.rb +18 -51
  6. data/lib/zoom/actions/billing.rb +30 -27
  7. data/lib/zoom/actions/dashboard.rb +11 -22
  8. data/lib/zoom/actions/groups.rb +11 -9
  9. data/lib/zoom/actions/im/chat.rb +11 -24
  10. data/lib/zoom/actions/meeting.rb +34 -67
  11. data/lib/zoom/actions/phone.rb +5 -17
  12. data/lib/zoom/actions/recording.rb +8 -26
  13. data/lib/zoom/actions/report.rb +10 -20
  14. data/lib/zoom/actions/roles.rb +11 -28
  15. data/lib/zoom/actions/sip_audio.rb +16 -57
  16. data/lib/zoom/actions/token.rb +15 -24
  17. data/lib/zoom/actions/user.rb +65 -123
  18. data/lib/zoom/actions/webinar.rb +37 -77
  19. data/lib/zoom/actions.rb +49 -0
  20. data/lib/zoom/utils.rb +10 -7
  21. data/lib/zoom/version.rb +1 -1
  22. data/lib/zoom_rb.rb +1 -0
  23. data/spec/fixtures/error/admin_cannot_activated.json +4 -0
  24. data/spec/fixtures/error/group_not_exist.json +4 -0
  25. data/spec/fixtures/error/not_found_administrator.json +4 -0
  26. data/spec/fixtures/groups/create.json +5 -0
  27. data/spec/fixtures/groups/update.json +0 -0
  28. data/spec/fixtures/user/update_email.json +0 -0
  29. data/spec/fixtures/user/update_status.json +0 -0
  30. data/spec/lib/zoom/actions/groups/create_spec.rb +96 -1
  31. data/spec/lib/zoom/actions/groups/update_spec.rb +59 -0
  32. data/spec/lib/zoom/actions/meeting/create_spec.rb +1 -1
  33. data/spec/lib/zoom/actions/user/create_spec.rb +18 -46
  34. data/spec/lib/zoom/actions/user/update_email_spec.rb +59 -0
  35. data/spec/lib/zoom/actions/user/update_status_spec.rb +59 -0
  36. data/spec/lib/zoom/actions_spec.rb +84 -0
  37. data/spec/lib/zoom/utils_spec.rb +1 -1
  38. metadata +29 -6
@@ -3,39 +3,22 @@
3
3
  module Zoom
4
4
  module Actions
5
5
  module Roles
6
- def roles_list(*_args)
7
- Utils.parse_response self.class.get("/roles", headers: request_headers)
8
- end
6
+ extend Zoom::Actions
9
7
 
10
- def roles_create(*args)
11
- params = Zoom::Params.new(Utils.extract_options!(args))
12
- params.require(:name).permit(%i[description privileges])
13
- Utils.parse_response self.class.post("/roles", body: params.to_json, headers: request_headers)
14
- end
8
+ get 'roles_list', '/roles'
15
9
 
16
- def roles_members(*args)
17
- params = Zoom::Params.new(Utils.extract_options!(args))
18
- params.require(:role_id)
19
- Utils.parse_response self.class.get("/roles/#{params[:role_id]}/members", headers: request_headers)
20
- end
10
+ post 'roles_create', '/roles',
11
+ require: :name,
12
+ permit: %i[description privileges]
21
13
 
22
- def roles_assign(*args)
23
- params = Zoom::Params.new(Utils.extract_options!(args))
24
- params.require(%i[role_id members])
25
- Utils.parse_response self.class.post("/roles/#{params[:role_id]}/members", body: params.except(:role_id).to_json, headers: request_headers)
26
- end
14
+ get 'roles_members', '/roles/:role_id/members'
27
15
 
28
- def roles_unassign(*args)
29
- params = Zoom::Params.new(Utils.extract_options!(args))
30
- params.require(%i[role_id member_id])
31
- Utils.parse_response self.class.delete("/roles/#{params[:role_id]}/members/#{params[:member_id]}", headers: request_headers)
32
- end
16
+ post 'roles_assign', '/roles/:role_id/members',
17
+ require: :members
33
18
 
34
- def roles_get(*args)
35
- params = Zoom::Params.new(Utils.extract_options!(args))
36
- params.require(:role_id)
37
- Utils.parse_response self.class.get("/roles/#{params[:role_id]}", headers: request_headers)
38
- end
19
+ delete 'roles_unassign', '/roles/:role_id/members/:member_id'
20
+
21
+ get 'roles_get', '/roles/:role_id'
39
22
  end
40
23
  end
41
24
  end
@@ -3,73 +3,32 @@
3
3
  module Zoom
4
4
  module Actions
5
5
  module SipAudio
6
- def sip_trunks_get(*args)
7
- params = Zoom::Params.new(Utils.extract_options!(args))
8
- params.require(:account_id)
9
- Utils.parse_response self.class.get("/accounts/#{params[:account_id]}/sip_trunk/trunks", headers: request_headers)
10
- end
6
+ extend Zoom::Actions
11
7
 
12
- def sip_trunks_delete(*args)
13
- params = Zoom::Params.new(Utils.extract_options!(args))
14
- params.require(:account_id, :trunk_id)
15
- Utils.parse_response self.class.delete("/accounts/#{params[:account_id]}/sip_trunk/trunks/#{params[:trunk_id]}", headers: request_headers)
16
- end
8
+ get 'sip_trunks_get', '/accounts/:account_id/sip_trunk/trunks'
17
9
 
18
- def sip_trunk_numbers_delete(*args)
19
- params = Zoom::Params.new(Utils.extract_options!(args))
20
- params.require(:account_id)
21
- Utils.parse_response self.class.delete("/accounts/#{params[:account_id]}/sip_trunk/numbers", headers: request_headers)
22
- end
10
+ delete 'sip_trunks_delete', '/accounts/:account_id/sip_trunk/trunks/:trunk_id'
23
11
 
24
- def sip_trunks_internal_numbers_delete(*args)
25
- params = Zoom::Params.new(Utils.extract_options!(args))
26
- params.require(%i[account_id number_id])
27
- Utils.parse_response self.class.delete("/accounts/#{params[:account_id]}/sip_trunk/internal_numbers/#{params[:number_id]}", headers: request_headers)
28
- end
12
+ delete 'sip_trunk_numbers_delete', '/accounts/:account_id/sip_trunk/numbers'
29
13
 
30
- def sip_trunks_internal_callout_country_delete(*args)
31
- params = Zoom::Params.new(Utils.extract_options!(args))
32
- params.require(%i[account_id country_id])
33
- Utils.parse_response self.class.delete("/accounts/#{params[:account_id]}/sip_trunk/callout_countries/#{params[:country_id]}", headers: request_headers)
34
- end
14
+ delete 'sip_trunks_internal_numbers_delete',
15
+ '/accounts/:account_id/sip_trunk/internal_numbers/:number_id'
35
16
 
36
- def sip_trunks_internal_numbers_list(*args)
37
- params = Zoom::Params.new(Utils.extract_options!(args))
38
- params.require(:account_id).permit(%i[page_size next_page_token])
39
- response = self.class.get("/accounts/#{params[:account_id]}/sip_trunk/internal_numbers", query: params, headers: request_headers)
40
- Utils.parse_response(response)
41
- end
17
+ delete 'sip_trunks_internal_callout_country_delete',
18
+ '/accounts/:account_id/sip_trunk/callout_countries/:country_id'
42
19
 
43
- def sip_trunks_internal_callout_country_list(*args)
44
- params = Zoom::Params.new(Utils.extract_options!(args))
45
- params.require(:account_id)
46
- response = self.class.get("/accounts/#{params[:account_id]}/sip_trunk/callout_countries", headers: request_headers)
47
- Utils.parse_response(response)
48
- end
20
+ get 'sip_trunks_internal_numbers_list', '/accounts/:account_id/sip_trunk/internal_numbers',
21
+ permit: %i[page_size next_page_token]
49
22
 
50
- def sip_trunks_numbers_list(*args)
51
- params = Zoom::Params.new(Utils.extract_options!(args))
52
- response = self.class.get("/sip_trunk/numbers", headers: request_headers)
53
- Utils.parse_response(response)
54
- end
23
+ get 'sip_trunks_internal_callout_country_list', '/accounts/:account_id/sip_trunk/callout_countries'
55
24
 
56
- def sip_trunks_internal_numbers_add(*args)
57
- params = Zoom::Params.new(Utils.extract_options!(args))
58
- params.require(:account_id)
59
- Utils.parse_response self.class.post("/accounts/#{params[:account_id]}/sip_trunk/internal_numbers", headers: request_headers)
60
- end
25
+ get 'sip_trunks_numbers_list', '/sip_trunk/numbers'
61
26
 
62
- def sip_trunks_internal_callout_countries_add(*args)
63
- params = Zoom::Params.new(Utils.extract_options!(args))
64
- params.require(:account_id)
65
- Utils.parse_response self.class.post("/accounts/#{params[:account_id]}/sip_trunk/callout_countries", headers: request_headers)
66
- end
27
+ post 'sip_trunks_internal_numbers_add', '/accounts/:account_id/sip_trunk/internal_numbers'
67
28
 
68
- def sip_trunks_numbers_assign(*args)
69
- params = Zoom::Params.new(Utils.extract_options!(args))
70
- params.require(:account_id)
71
- Utils.parse_response self.class.post("/accounts/#{params[:account_id]}/sip_trunk/numbers", headers: request_headers)
72
- end
29
+ post 'sip_trunks_internal_callout_countries_add', '/accounts/:account_id/sip_trunk/callout_countries'
30
+
31
+ post 'sip_trunks_numbers_assign', '/accounts/:account_id/sip_trunk/numbers'
73
32
  end
74
33
  end
75
34
  end
@@ -3,33 +3,24 @@
3
3
  module Zoom
4
4
  module Actions
5
5
  module Token
6
- def access_tokens(*args)
7
- options = Zoom::Params.new(Utils.extract_options!(args))
8
- options.require(%i[auth_code redirect_uri])
9
- response = self.class.post("/oauth/token?grant_type=authorization_code&code=#{options[:auth_code]}&redirect_uri=#{options[:redirect_uri]}", headers: oauth_request_headers, base_uri: 'https://zoom.us/')
10
- Utils.parse_response(response)
11
- end
6
+ extend Zoom::Actions
12
7
 
13
- def refresh_tokens(*args)
14
- options = Zoom::Params.new(Utils.extract_options!(args))
15
- options.require(:refresh_token)
16
- response = self.class.post("/oauth/token?grant_type=refresh_token&refresh_token=#{options[:refresh_token]}", headers: oauth_request_headers, base_uri: 'https://zoom.us/')
17
- Utils.parse_response(response)
18
- end
8
+ post 'access_tokens',
9
+ '/oauth/token?grant_type=authorization_code&code=:auth_code&redirect_uri=:redirect_uri',
10
+ base_uri: 'https://zoom.us/'
19
11
 
20
- def data_compliance(*args)
21
- options = Zoom::Params.new(Utils.extract_options!(args))
22
- options.require(%i[client_id user_id account_id deauthorization_event_received compliance_completed])
23
- response = self.class.post("/oauth/data/compliance", body: options.to_json, headers: oauth_request_headers, base_uri: 'https://zoom.us/')
24
- Utils.parse_response response
25
- end
12
+ post 'refresh_tokens',
13
+ '/oauth/token?grant_type=refresh_token&refresh_token=:refresh_token',
14
+ base_uri: 'https://zoom.us/'
26
15
 
27
- def revoke_tokens(*args)
28
- options = Zoom::Params.new(Utils.extract_options!(args))
29
- options.require(%i[access_token])
30
- response = self.class.post("/oauth/revoke?token=#{options[:access_token]}", headers: oauth_request_headers, base_uri: 'https://zoom.us/')
31
- Utils.parse_response(response)
32
- end
16
+ post 'data_compliance', '/oauth/data/compliance',
17
+ base_uri: 'https://zoom.us/',
18
+ require: %i[
19
+ client_id user_id account_id deauthorization_event_received compliance_completed
20
+ ]
21
+
22
+ post 'revoke_tokens', '/oauth/revoke?token=:access_token',
23
+ base_uri: 'https://zoom.us/'
33
24
  end
34
25
  end
35
26
  end
@@ -3,130 +3,72 @@
3
3
  module Zoom
4
4
  module Actions
5
5
  module User
6
- def user_list(*args)
7
- params = Zoom::Params.new(Utils.extract_options!(args))
8
- params.permit(%i[status page_size role_id page_number include_fields next_page_token])
9
- response = self.class.get('/users', query: params, headers: request_headers)
10
- Utils.parse_response(response)
11
- end
12
-
13
- def user_create(*args)
14
- params = Zoom::Params.new(Utils.extract_options!(args))
15
- require_param_keys = %i[action email type]
16
- require_param_keys.append(:password) if params[:action] == 'autoCreate'
17
- params.require(require_param_keys)
18
- params.permit_value(:action, Zoom::Constants::User::CREATE_TYPES.keys)
19
- Utils.parse_response self.class.post('/users', body: { action: params[:action], user_info: params.except(:action) }.to_json, headers: request_headers)
20
- end
21
-
22
- def user_get(*args)
23
- params = Zoom::Params.new(Utils.extract_options!(args))
24
- params.require(:id).permit(:login_type)
25
- Utils.parse_response self.class.get("/users/#{params[:id]}", query: params.except(:id), headers: request_headers)
26
- end
27
-
28
- def user_update(*args)
29
- params = Zoom::Params.new(Utils.extract_options!(args))
30
- params.require(:id).permit(%i[first_name last_name type pmi timezone dept vanity_name host_key cms_user_id])
31
- Utils.parse_response self.class.patch("/users/#{params[:id]}", body: params.except(:id), headers: request_headers)
32
- end
33
-
34
- def user_delete(*args)
35
- params = Zoom::Params.new(Utils.extract_options!(args))
36
- params.require(:id).permit(%i[action transfer_email transfer_meeting transfer_webinar transfer_recording])
37
- Utils.parse_response self.class.delete("/users/#{params[:id]}", query: params.except(:id), headers: request_headers)
38
- end
39
-
40
- def user_assistants_list(*args)
41
- params = Zoom::Params.new(Utils.extract_options!(args))
42
- params.require(:user_id)
43
- Utils.parse_response(self.class.get("/users/#{params[:user_id]}/assistants", query: params.except(:user_id), headers: request_headers))
44
- end
45
-
46
- def user_assistants_create(*args)
47
- params = Zoom::Params.new(Utils.extract_options!(args))
48
- params.require(:user_id).permit(:assistants)
49
- Utils.parse_response self.class.post("/users/#{params[:user_id]}/assistants", body: params.except(:user_id).to_json, headers: request_headers)
50
- end
51
-
52
- def user_assistants_delete_all(*args)
53
- params = Zoom::Params.new(Utils.extract_options!(args))
54
- params.require(:user_id)
55
- Utils.parse_response(self.class.delete("/users/#{params[:user_id]}/assistants", query: params.except(:user_id), headers: request_headers))
56
- end
57
-
58
- def user_assistants_delete(*args)
59
- params = Zoom::Params.new(Utils.extract_options!(args))
60
- params.require(%i[user_id assistant_id])
61
- Utils.parse_response(self.class.delete("/users/#{params[:user_id]}/assistants/#{params[:assistant_id]}", query: params.except(:user_id, :assistant_id), headers: request_headers))
62
- end
63
-
64
- def user_schedulers_list(*args)
65
- params = Zoom::Params.new(Utils.extract_options!(args))
66
- params.require(:user_id)
67
- Utils.parse_response(self.class.get("/users/#{params[:user_id]}/schedulers", query: params.except(:user_id), headers: request_headers))
68
- end
69
-
70
- def user_schedulers_delete_all(*args)
71
- params = Zoom::Params.new(Utils.extract_options!(args))
72
- params.require(:user_id)
73
- Utils.parse_response(self.class.delete("/users/#{params[:user_id]}/schedulers", query: params.except(:user_id), headers: request_headers))
74
- end
75
-
76
- def user_schedulers_delete(*args)
77
- params = Zoom::Params.new(Utils.extract_options!(args))
78
- params.require(%i[user_id scheduler_id])
79
- Utils.parse_response(self.class.delete("/users/#{params[:user_id]}/schedulers/#{params[:scheduler_id]}", query: params.except(:user_id, :scheduler_id), headers: request_headers))
80
- end
81
-
82
- def user_settings_get(*args)
83
- params = Zoom::Params.new(Utils.extract_options!(args))
84
- params.require(:id).permit(:login_type)
85
- Utils.parse_response self.class.get("/users/#{params[:id]}/settings", query: params.except(:id), headers: request_headers)
86
- end
87
-
88
- def user_settings_update(*args)
89
- params = Zoom::Params.new(Utils.extract_options!(args))
90
- params.require(:id).permit(%i[schedule_meeting in_meeting email_notification recording telephony feature tsp])
91
- Utils.parse_response self.class.patch("/users/#{params[:id]}/settings", body: params.except(:id).to_json, headers: request_headers)
92
- end
93
-
94
- def user_email_check(*args)
95
- params = Zoom::Params.new(Utils.extract_options!(args))
96
- params.require(:email)
97
- Utils.parse_response(self.class.get('/users/email', query: params.slice(:email), headers: request_headers))
98
- end
99
-
100
- def user_recordings_list(*args)
101
- params = Zoom::Params.new(Utils.extract_options!(args))
102
- params.require(:id).permit(%i[page_size next_page_token mc trash from to trash_type])
103
- Utils.parse_response self.class.get("/users/#{params[:id]}/recordings", query: params.except(:id), headers: request_headers)
104
- end
105
-
106
- def user_token(*args)
107
- params = Zoom::Params.new(Utils.extract_options!(args))
108
- params.require(:user_id).permit(%i[type ttl])
109
- Utils.parse_response self.class.get("/users/#{params[:user_id]}/token", query: params.except(:user_id), headers: request_headers)
110
- end
111
-
112
- def user_permissions(*args)
113
- params = Zoom::Params.new(Utils.extract_options!(args))
114
- params.require(:user_id)
115
- Utils.parse_response self.class.get("/users/#{params[:user_id]}/permissions", headers: request_headers)
116
- end
117
-
118
- def user_vanity_name(*args)
119
- params = Zoom::Params.new(Utils.extract_options!(args))
120
- params.require(:vanity_name)
121
- Utils.parse_response self.class.get("/users/vanity_name", query: params.slice(:vanity_name), headers: request_headers)
122
- end
123
-
124
- def user_password_update(*args)
125
- params = Zoom::Params.new(Utils.extract_options!(args))
126
- params.require(:id).permit(%i[password])
127
- Utils.parse_response self.class.patch("/users/#{params[:id]}/password", body: params.except(:id), headers: request_headers)
128
- end
6
+ extend Zoom::Actions
129
7
 
8
+ get 'user_list', '/users',
9
+ permit: %i[status page_size role_id page_number include_fields next_page_token]
10
+
11
+ post 'user_create', '/users',
12
+ require: [
13
+ :action,
14
+ user_info: %i[email type]
15
+ ],
16
+ permit: {
17
+ user_info: %i[first_name last_name password]
18
+ }
19
+
20
+ get 'user_get', '/users/:id',
21
+ permit: :login_type
22
+
23
+ patch 'user_update', '/users/:id',
24
+ permit: %i[first_name last_name type pmi timezone dept vanity_name host_key cms_user_id]
25
+
26
+ delete 'user_delete', '/users/:id',
27
+ permit: %i[action transfer_email transfer_meeting transfer_webinar transfer_recording]
28
+
29
+ get 'user_assistants_list', '/users/:user_id/assistants'
30
+
31
+ post 'user_assistants_create', '/users/:user_id/assistants',
32
+ permit: :assistants
33
+
34
+ delete 'user_assistants_delete_all', '/users/:user_id/assistants'
35
+
36
+ delete 'user_assistants_delete', '/users/:user_id/assistants/:assistant_id'
37
+
38
+ get 'user_schedulers_list', '/users/:user_id/schedulers'
39
+
40
+ delete 'user_schedulers_delete_all', '/users/:user_id/schedulers'
41
+
42
+ delete 'user_schedulers_delete', '/users/:user_id/schedulers/:scheduler_id'
43
+
44
+ get 'user_settings_get', '/users/:id/settings',
45
+ permit: [:login_type, :option, :custom_query_fields]
46
+
47
+ patch 'user_settings_update', '/users/:id/settings',
48
+ permit: %i[schedule_meeting in_meeting email_notification recording telephony feature tsp]
49
+
50
+ get 'user_email_check', '/users/email',
51
+ require: :email
52
+
53
+ get 'user_recordings_list', '/users/:id/recordings',
54
+ permit: %i[page_size next_page_token mc trash from to trash_type]
55
+
56
+ get 'user_token', '/users/:user_id/token',
57
+ permit: %i[type ttl]
58
+
59
+ get 'user_permissions', '/users/:user_id/permissions'
60
+
61
+ get 'user_vanity_name', '/users/vanity_name',
62
+ require: :vanity_name
63
+
64
+ patch 'user_password_update', '/users/:id/password',
65
+ permit: :password
66
+
67
+ patch 'user_email_update', '/users/:id/email',
68
+ permit: :email
69
+
70
+ patch 'user_status_update', '/users/:id/status',
71
+ permit: :status
130
72
  end
131
73
  end
132
74
  end
@@ -3,6 +3,8 @@
3
3
  module Zoom
4
4
  module Actions
5
5
  module Webinar
6
+ extend Zoom::Actions
7
+
6
8
  RECURRENCE_KEYS = %i[type repeat_interval weekly_days monthly_day monthly_week
7
9
  monthly_week_day end_times end_date_time].freeze
8
10
  SETTINGS_KEYS = %i[host_video panelists_video practice_session hd_video approval_type
@@ -14,95 +16,53 @@ module Zoom
14
16
  post_webinar_survey survey_url registrants_email_notification
15
17
  meeting_authentication authentication_option
16
18
  authentication_domains registrants_confirmation_email question_answer].freeze
17
- def webinar_list(*args)
18
- params = Zoom::Params.new(Utils.extract_options!(args))
19
- params.require(:host_id).permit(%i[page_size page_number])
20
- Utils.parse_response self.class.get("/users/#{params[:host_id]}/webinars", query: params.except(:host_id), headers: request_headers)
21
- end
22
19
 
23
- def webinar_create(*args)
24
- params = Zoom::Params.new(Utils.extract_options!(args))
25
- params.require(:host_id).permit(:topic, :type, :start_time, :duration,
26
- :timezone, :password, :agenda,
27
- recurrence: RECURRENCE_KEYS,
28
- settings: SETTINGS_KEYS)
29
- # TODO: process recurrence keys based on constants
30
- # TODO: process settings keys based on constants
31
- Utils.parse_response self.class.post("/users/#{params[:host_id]}/webinars", body: params.except(:host_id).to_json, headers: request_headers)
32
- end
20
+ get 'webinar_list', '/users/:host_id/webinars',
21
+ permit: %i[page_size page_number]
22
+
23
+ # TODO: process recurrence keys based on constants
24
+ # TODO: process settings keys based on constants
25
+ post 'webinar_create', '/users/:host_id/webinars',
26
+ permit: [
27
+ :topic, :type, :start_time, :duration, :timezone, :password, :agenda,
28
+ { recurrence: RECURRENCE_KEYS, settings: SETTINGS_KEYS }
29
+ ]
33
30
 
34
- def webinar_get(*args)
35
- params = Zoom::Params.new(Utils.extract_options!(args))
36
- params.require(:id)
37
- Utils.parse_response self.class.get("/webinars/#{params[:id]}", headers: request_headers)
38
- end
31
+ get 'webinar_get', '/webinars/:id'
39
32
 
40
- def webinar_update(*args)
41
- params = Zoom::Params.new(Utils.extract_options!(args))
42
- params.require(:id).permit(:topic, :type, :start_time, :duration,
43
- :timezone, :password, :agenda,
44
- recurrence: RECURRENCE_KEYS,
45
- settings: SETTINGS_KEYS)
46
- Utils.parse_response self.class.patch("/webinars/#{params[:id]}", body: params.except(:id).to_json, headers: request_headers)
47
- end
33
+ patch 'webinar_update', '/webinars/:id',
34
+ permit: [
35
+ :topic, :type, :start_time, :duration, :timezone, :password, :agenda,
36
+ { recurrence: RECURRENCE_KEYS, settings: SETTINGS_KEYS }
37
+ ]
48
38
 
49
- def webinar_delete(*args)
50
- params = Zoom::Params.new(Utils.extract_options!(args))
51
- params.require(:id).permit(:occurrence_id)
52
- Utils.parse_response self.class.delete("/webinars/#{params[:id]}", query: params.except(:id), headers: request_headers)
53
- end
39
+ delete 'webinar_delete', '/webinars/:id',
40
+ permit: :occurrence_id
54
41
 
55
- def webinar_registrants_list(*args)
56
- params = Zoom::Params.new(Utils.extract_options!(args))
57
- params.require(:id).permit(%i[occurrence_id status page_size page_number])
58
- Utils.parse_response self.class.get("/webinars/#{params[:id]}/registrants", query: params.except(:id), headers: request_headers)
59
- end
42
+ get 'webinar_registrants_list', '/webinars/:id/registrants',
43
+ permit: %i[occurrence_id status page_size page_number]
60
44
 
61
- def webinar_registrant_add(*args)
62
- params = Zoom::Params.new(Utils.extract_options!(args))
63
- params.require(%i[id email first_name last_name])
64
- .permit(%i[occurrence_ids address city country zip state phone
65
- industry org job_title purchasing_time_frame role_in_purchase_process
66
- no_of_employees comments custom_questions])
67
- Utils.parse_response self.class.post("/webinars/#{params[:id]}/registrants", body: params.except(:id, :occurrence_ids).to_json, query: params.slice(:occurrence_ids), headers: request_headers)
68
- end
45
+ post 'webinar_registrant_add', '/webinars/:id/registrants',
46
+ require: %i[email first_name last_name],
47
+ permit: %i[
48
+ occurrence_ids address city country zip state phone industry org job_title
49
+ purchasing_time_frame role_in_purchase_process no_of_employees comments custom_questions
50
+ ]
69
51
 
70
- def webinar_registrants_status_update(*args)
71
- params = Zoom::Params.new(Utils.extract_options!(args))
72
- params.require(%i[id action])
73
- .permit(:occurrence_id, registrants: [])
74
- Utils.parse_response self.class.put("/webinars/#{params[:id]}/registrants/status", body: params.except(:id, :occurrence_id).to_json, query: params.slice(:occurrence_id), headers: request_headers)
75
- end
52
+ put 'webinar_registrants_status_update', '/webinars/:id/registrants/status',
53
+ require: :action,
54
+ permit: [ :occurrence_id, registrants: [] ]
76
55
 
77
- def past_webinar_list(*args)
78
- params = Zoom::Params.new(Utils.extract_options!(args))
79
- params.require(:id)
80
- Utils.parse_response self.class.get("/past_webinars/#{params[:id]}/instances", headers: request_headers)
81
- end
56
+ get 'past_webinar_list', '/past_webinars/:id/instances'
82
57
 
83
- def webinar_registrant_get(*args)
84
- params = Zoom::Params.new(Utils.extract_options!(args))
85
- params.require(%i[webinar_id id]).permit(:occurrence_id)
86
- Utils.parse_response self.class.get("/webinars/#{params[:webinar_id]}/registrants/#{params[:id]}", query: params.except(:webinar_id, :id), headers: request_headers)
87
- end
58
+ get 'webinar_registrant_get', '/webinars/:webinar_id/registrants/:id',
59
+ permit: :occurrence_id
88
60
 
89
- def webinar_polls_list(*args)
90
- params = Zoom::Params.new(Utils.extract_options!(args))
91
- params.require(:webinar_id)
92
- Utils.parse_response self.class.get("/webinars/#{params[:webinar_id]}/polls", headers: request_headers)
93
- end
61
+ get 'webinar_polls_list', '/webinars/:webinar_id/polls'
94
62
 
95
- def webinar_poll_get(*args)
96
- params = Zoom::Params.new(Utils.extract_options!(args))
97
- params.require(%i[webinar_id poll_id])
98
- Utils.parse_response self.class.get("/webinars/#{params[:webinar_id]}/polls/#{params[:poll_id]}", headers: request_headers)
99
- end
63
+ get 'webinar_poll_get', '/webinars/:webinar_id/polls/:poll_id'
100
64
 
101
- def webinar_panelist_list(*args)
102
- params = Zoom::Params.new(Utils.extract_options!(args))
103
- params.require(:webinar_id)
104
- Utils.parse_response self.class.get("/webinars/#{params[:webinar_id]}/panelists", headers: request_headers)
105
- end
65
+ get 'webinar_panelist_list', '/webinars/:webinar_id/panelists'
106
66
  end
107
67
  end
108
68
  end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zoom
4
+ module Actions
5
+ def self.extract_path_keys(path)
6
+ path.scan(/:\w+/).map { |match| match[1..].to_sym }
7
+ end
8
+
9
+ def self.parse_path(path, path_keys, params)
10
+ parsed_path = path.dup
11
+ path_keys.each do |key|
12
+ value = params[key].to_s
13
+ parsed_path = parsed_path.sub(":#{key}", value)
14
+ end
15
+ parsed_path
16
+ end
17
+
18
+ def self.make_request(client, method, parsed_path, params, base_uri)
19
+ request_options = { headers: client.request_headers }
20
+ request_options[:base_uri] = base_uri if base_uri
21
+ case method
22
+ when :get
23
+ request_options[:query] = params
24
+ when :post, :put, :patch
25
+ request_options[:body] = params.to_json
26
+ end
27
+ client.class.public_send(method, parsed_path, **request_options)
28
+ end
29
+
30
+ [:get, :post, :patch, :put, :delete].each do |method|
31
+ define_method(method) do |name, path, options={}|
32
+ required, permitted, base_uri = options.values_at :require, :permit, :base_uri
33
+ required = Array(required) unless required.is_a?(Hash)
34
+ permitted = Array(permitted) unless permitted.is_a?(Hash)
35
+
36
+ define_method(name) do |*args|
37
+ path_keys = Zoom::Actions.extract_path_keys(path)
38
+ params = Zoom::Params.new(Utils.extract_options!(args))
39
+ parsed_path = Zoom::Actions.parse_path(path, path_keys, params)
40
+ params = params.require(path_keys) unless path_keys.empty?
41
+ params_without_required = required.empty? ? params : params.require(required)
42
+ params_without_required.permit(permitted) unless permitted.empty?
43
+ response = Zoom::Actions.make_request(self, method, parsed_path, params, base_uri)
44
+ Utils.parse_response(response)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
data/lib/zoom/utils.rb CHANGED
@@ -32,7 +32,8 @@ module Zoom
32
32
  end
33
33
 
34
34
  def extract_options!(array)
35
- array.last.is_a?(::Hash) ? array.pop : {}
35
+ params = array.last.is_a?(::Hash) ? array.pop : {}
36
+ process_datetime_params!(params)
36
37
  end
37
38
 
38
39
  def validate_password(password)
@@ -40,14 +41,16 @@ module Zoom
40
41
  raise(Error , 'Invalid Password') unless password[password_regex].nil?
41
42
  end
42
43
 
43
- def process_datetime_params!(params, options)
44
- params = [params] unless params.is_a? Array
45
- params.each do |param|
46
- if options[param] && options[param].kind_of?(Time)
47
- options[param] = options[param].strftime('%FT%TZ')
44
+ def process_datetime_params!(params)
45
+ params.each do |key, value|
46
+ case key
47
+ when Symbol, String
48
+ params[key] = value.is_a?(Time) ? value.strftime('%FT%TZ') : value
49
+ when Hash
50
+ process_datetime_params!(params[key])
48
51
  end
49
52
  end
50
- options
53
+ params
51
54
  end
52
55
  end
53
56
  end
data/lib/zoom/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zoom
4
- VERSION = '0.11.0'
4
+ VERSION = '1.0.0'
5
5
  end
data/lib/zoom_rb.rb CHANGED
@@ -6,6 +6,7 @@ require 'zoom/version'
6
6
  require 'zoom/constants/constants'
7
7
  require 'zoom/params'
8
8
  require 'zoom/utils'
9
+ require 'zoom/actions'
9
10
  require 'zoom/actions/account'
10
11
  require 'zoom/actions/billing'
11
12
  require 'zoom/actions/dashboard'
@@ -0,0 +1,4 @@
1
+ {
2
+ "code": 400,
3
+ "message": "Zoom Room and Admin users’ status cannot be activated or deactivated."
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "code": 4130,
3
+ "message": "A group with this 3 does not exist."
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "code": 400,
3
+ "message": "Only an account administrator can change email."
4
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "id": "3",
3
+ "name": "Zoom Group Name",
4
+ "total_members": "1"
5
+ }