diff --git a/.standard.yml b/.standard.yml new file mode 100644 index 00000000..2a955844 --- /dev/null +++ b/.standard.yml @@ -0,0 +1,6 @@ +require: rubocop-rspec +parallel: true + +ignore: + - 'test/**/*': + - Layout/AlignHash \ No newline at end of file diff --git a/Gemfile b/Gemfile index 7f4f5e95..be173b20 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ # frozen_string_literal: true -source 'https://rubygems.org' +source "https://rubygems.org" gemspec diff --git a/Gemfile.lock b/Gemfile.lock index aabf90a4..3a3cf918 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,45 +1,30 @@ PATH remote: . specs: - zoom_rb (1.1.8) + zoom_rb (2.0.0) httparty (>= 0.13) json (>= 1.8) - jwt GEM remote: https://rubygems.org/ specs: - activesupport (7.0.4.3) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) addressable (2.8.4) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) byebug (11.1.3) coderay (1.1.3) - concurrent-ruby (1.2.2) crack (0.4.5) rexml diff-lcs (1.5.0) docile (1.4.0) hashdiff (1.0.1) - hint-rubocop_style (0.3.6) - rubocop (>= 0.78.0) - rubocop-performance (>= 1.3.0) - rubocop-rails (>= 2.0.0) - rubocop-rspec (>= 1.33.0) httparty (0.21.0) mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) - i18n (1.12.0) - concurrent-ruby (~> 1.0) json (2.6.3) - jwt (2.7.0) + language_server-protocol (3.17.0.3) method_source (1.0.0) mini_mime (1.1.2) - minitest (5.18.0) multi_xml (0.6.0) parallel (1.22.1) parser (3.2.2.0) @@ -51,7 +36,6 @@ GEM byebug (~> 11.0) pry (>= 0.13, < 0.15) public_suffix (5.0.1) - rack (3.0.7) rainbow (3.1.1) regexp_parser (2.7.0) rexml (3.2.5) @@ -70,27 +54,23 @@ GEM rspec-support (3.12.0) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.49.0) + rubocop (1.48.1) json (~> 2.3) parallel (~> 1.10) parser (>= 3.2.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) + rubocop-ast (>= 1.26.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.28.0) parser (>= 3.2.1.0) rubocop-capybara (2.17.1) rubocop (~> 1.41) - rubocop-performance (1.17.1) + rubocop-performance (1.16.0) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.19.0) - activesupport (>= 4.2.0) - rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) rubocop-rspec (2.19.0) rubocop (~> 1.33) rubocop-capybara (~> 2.17) @@ -102,8 +82,10 @@ GEM simplecov-html (0.12.3) simplecov-lcov (0.8.0) simplecov_json_formatter (0.1.4) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) + standard (1.26.0) + language_server-protocol (~> 3.17.0.2) + rubocop (~> 1.48.1) + rubocop-performance (~> 1.16.0) unicode-display_width (2.4.2) webmock (3.18.1) addressable (>= 2.8.0) @@ -114,12 +96,13 @@ PLATFORMS ruby DEPENDENCIES - hint-rubocop_style pry-byebug rspec (>= 3.8) rspec_junit_formatter (>= 0.4.1) + rubocop-rspec (>= 2.19.0) simplecov (>= 0.22.0) simplecov-lcov (>= 0.8.0) + standard (>= 1.25.0) webmock (>= 3.4) zoom_rb! diff --git a/README.md b/README.md index 90c436f1..8bd78cfa 100644 --- a/README.md +++ b/README.md @@ -18,18 +18,19 @@ Or install it yourself as: ## Usage -The Zoom API uses OAuth or JWT to [Authenticate](https://marketplace.zoom.us/docs/api-reference/Authentication) API request. By default, a JWT client will be used. +The Zoom API uses OAuth 2.0 to [Authenticate](https://developers.zoom.us/docs/api/rest/using-zoom-apis/#authentication) API request. By default, a `ServerToServerOAuth` client will be used. ```ruby Zoom.configure do |c| - c.api_key = 'xxx' - c.api_secret = 'xxx' + c.account_id = 'xxx' + c.client_id = 'xxx' + c.client_secret = 'xxx' end zoom_client = Zoom.new ``` -To create an OAuth flow you need to make a call to auth, then create the client directly from an access token. +To create a non-ServerToServer OAuth flow, you need to make a call to auth, then create the client directly from an access token. First you need to get an auth_code externally from: ``` diff --git a/Rakefile b/Rakefile index 13a79ede..29955274 100644 --- a/Rakefile +++ b/Rakefile @@ -1 +1 @@ -require "bundler/gem_tasks" \ No newline at end of file +require "bundler/gem_tasks" diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index c4d7ed79..05041eec 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -3,14 +3,14 @@ module Zoom module Actions def self.extract_path_keys(path) - path.scan(/:\w+/).map { |match| match[1..-1].to_sym } + path.scan(/:\w+/).map { |match| match[1..].to_sym } end def self.parse_path(path, path_keys, params) parsed_path = path.dup path_keys.each do |key| - value = params[key].to_s - parsed_path = parsed_path.sub(":#{key}", value) + value = params[key].to_s + parsed_path = parsed_path.sub(":#{key}", value) end parsed_path end @@ -19,10 +19,10 @@ def self.determine_request_options(client, oauth) if oauth { headers: client.oauth_request_headers, - base_uri: 'https://zoom.us/' + base_uri: "https://zoom.us/" } else - { headers: client.request_headers } + {headers: client.request_headers} end end @@ -40,8 +40,8 @@ def self.make_request(args) end [:get, :post, :patch, :put, :delete].each do |method| - define_method(method) do |name, path, options={}| - required, permitted, oauth, args_to_params, headers = + define_method(method) do |name, path, options = {}| + required, permitted, oauth, args_to_params, _headers = options.values_at :require, :permit, :oauth, :args_to_params, :headers required = Array(required) unless required.is_a?(Hash) permitted = Array(permitted) unless permitted.is_a?(Hash) diff --git a/lib/zoom/actions/account.rb b/lib/zoom/actions/account.rb index 9ae1c4ad..a8d29bad 100644 --- a/lib/zoom/actions/account.rb +++ b/lib/zoom/actions/account.rb @@ -5,31 +5,31 @@ module Actions module Account extend Zoom::Actions - get 'account_list', '/accounts', + get "account_list", "/accounts", permit: %i[page_size page_number] - post 'account_create', '/accounts', + post "account_create", "/accounts", require: %i[first_name last_name email password], - permit: { options: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] } + permit: {options: %i[share_rc room_connectors share_mc meeting_connectors pay_mode]} - get 'account_get', '/accounts/:account_id' + get "account_get", "/accounts/:account_id" - delete 'account_delete', '/accounts/:account_id' + delete "account_delete", "/accounts/:account_id" - patch 'account_options_update', '/accounts/:account_id/options', + patch "account_options_update", "/accounts/:account_id/options", permit: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] - get 'account_settings_get', '/accounts/:account_id/settings', + get "account_settings_get", "/accounts/:account_id/settings", permit: :option - patch 'account_settings_update', '/accounts/:account_id/settings', + patch "account_settings_update", "/accounts/:account_id/settings", permit: [:option, Zoom::Constants::Account::Settings::PERMITTED_KEYS] - get 'account_managed_domains', '/accounts/:account_id/managed_domains' + get "account_managed_domains", "/accounts/:account_id/managed_domains" - get 'account_get_locked_settings', '/accounts/:account_id/lock_settings' + get "account_get_locked_settings", "/accounts/:account_id/lock_settings" - get 'account_trusted_domains', '/accounts/:account_id/trusted_domains' + get "account_trusted_domains", "/accounts/:account_id/trusted_domains" end end end diff --git a/lib/zoom/actions/billing.rb b/lib/zoom/actions/billing.rb index fb122991..1be5eb7b 100644 --- a/lib/zoom/actions/billing.rb +++ b/lib/zoom/actions/billing.rb @@ -5,16 +5,16 @@ module Actions module Billing extend Zoom::Actions - get 'billing_get', '/accounts/:account_id/billing' + get "billing_get", "/accounts/:account_id/billing" - patch 'billing_update', '/accounts/:account_id/billing', - permit: %i[first_name last_name email phone_number address apt city state zip country] + patch "billing_update", "/accounts/:account_id/billing", + permit: %i[first_name last_name email phone_number address apt city state zip country] - get 'billing_plans_list', '/accounts/:account_id/plans' + get "billing_plans_list", "/accounts/:account_id/plans" - get 'billing_plans_usage', '/accounts/:account_id/plans/usage' + get "billing_plans_usage", "/accounts/:account_id/plans/usage" - post 'billing_plans_subscribe', '/accounts/:account_id/plans', + post "billing_plans_subscribe", "/accounts/:account_id/plans", require: { contact: %i[first_name last_name email phone_number address city state zip country], plan_base: %i[type hosts] diff --git a/lib/zoom/actions/dashboard.rb b/lib/zoom/actions/dashboard.rb index 9c45cfcc..30d41bfa 100644 --- a/lib/zoom/actions/dashboard.rb +++ b/lib/zoom/actions/dashboard.rb @@ -5,17 +5,17 @@ module Actions module Dashboard extend Zoom::Actions - get 'dashboard_crc', '/metrics/crc', + get "dashboard_crc", "/metrics/crc", require: %i[from to] - get 'dashboard_meetings', '/metrics/meetings', + get "dashboard_meetings", "/metrics/meetings", require: %i[from to], permit: %i[next_page_token page_size type] - get 'dashboard_meeting_details', '/metrics/meetings/:meeting_id', + get "dashboard_meeting_details", "/metrics/meetings/:meeting_id", permit: :type - get 'dashboard_meeting_participants', '/metrics/meetings/:meeting_id/participants', + get "dashboard_meeting_participants", "/metrics/meetings/:meeting_id/participants", permit: %i[next_page_token page_size type] end end diff --git a/lib/zoom/actions/groups.rb b/lib/zoom/actions/groups.rb index 041ca1c3..0e8145a5 100644 --- a/lib/zoom/actions/groups.rb +++ b/lib/zoom/actions/groups.rb @@ -5,14 +5,14 @@ module Actions module Groups extend Zoom::Actions - get 'groups_list', '/groups' + get "groups_list", "/groups" - get 'groups_get', '/groups/:group_id' + get "groups_get", "/groups/:group_id" - post 'group_create', '/groups', + post "group_create", "/groups", permit: :name - patch 'group_update', '/groups/:group_id', + patch "group_update", "/groups/:group_id", permit: :name end end diff --git a/lib/zoom/actions/im/chat.rb b/lib/zoom/actions/im/chat.rb index 0a900772..afa9f8f2 100644 --- a/lib/zoom/actions/im/chat.rb +++ b/lib/zoom/actions/im/chat.rb @@ -6,20 +6,20 @@ module IM module Chat extend Zoom::Actions - get 'get_chat_channels', '/chat/channels/:channel_id' + get "get_chat_channels", "/chat/channels/:channel_id" - get 'get_chat_user_channels', '/chat/users/:user_id/channels', + get "get_chat_user_channels", "/chat/users/:user_id/channels", permit: %i[next_page_token page_size] # Get chat messages for a specified period. # TODO: implement `next_page_token`, will be returned whenever the set of available chat history list exceeds 100. The expiration period is 30 minutes. - get 'chat_get', '/chat/get', - require: [ :access_token, :session_id, :from, :to ] + get "chat_get", "/chat/get", + require: [:access_token, :session_id, :from, :to] # Get chat history list for a specified time period. # TODO: implement `next_page_token`, will be returned whenever the set of available chat history list exceeds 100. The expiration period is 30 minutes. - get 'chat_list', '/chat/list', - require: [ :access_token, :from, :to ] + get "chat_list", "/chat/list", + require: [:access_token, :from, :to] end end end diff --git a/lib/zoom/actions/im/group.rb b/lib/zoom/actions/im/group.rb index 5ba64698..10f7b85a 100644 --- a/lib/zoom/actions/im/group.rb +++ b/lib/zoom/actions/im/group.rb @@ -7,4 +7,4 @@ module Group end end end -end \ No newline at end of file +end diff --git a/lib/zoom/actions/m323_device.rb b/lib/zoom/actions/m323_device.rb index c107e367..c79dbef7 100644 --- a/lib/zoom/actions/m323_device.rb +++ b/lib/zoom/actions/m323_device.rb @@ -5,4 +5,4 @@ module Actions module M323Device end end -end \ No newline at end of file +end diff --git a/lib/zoom/actions/meeting.rb b/lib/zoom/actions/meeting.rb index fe3d4894..721740f4 100644 --- a/lib/zoom/actions/meeting.rb +++ b/lib/zoom/actions/meeting.rb @@ -6,18 +6,18 @@ module Meeting extend Zoom::Actions # List all the scheduled meetings on Zoom. - get 'meeting_list', '/users/:user_id/meetings', + get "meeting_list", "/users/:user_id/meetings", permit: %i[type page_size next_page_token page_number] # Create a meeting on Zoom, return the created meeting URL - post 'meeting_create', '/users/:user_id/meetings', + post "meeting_create", "/users/:user_id/meetings", permit: %i[ topic type start_time duration schedule_for timezone password default_password agenda tracking_fields recurrence settings template_id ] # Get a meeting on Zoom via meeting ID, return the meeting info. - get 'meeting_get', '/meetings/:meeting_id/', + get "meeting_get", "/meetings/:meeting_id/", permit: %i[occurrence_id show_previous_occurrences] # Update meeting info on Zoom via meeting ID. @@ -26,22 +26,22 @@ module Meeting # TODO Verify `password` attr, may only contain the following characters: a-z A-Z 0-9 @ - _ # TODO Handle `option_audio` attr, Can be "both", "telephony", "voip". # TODO Handle `option_auto_record_type`, Can be "local", “cloud” or "none". - patch 'meeting_update', '/meetings/:meeting_id' + patch "meeting_update", "/meetings/:meeting_id" # Delete a meeting on Zoom, return the deleted meeting ID. - delete 'meeting_delete', '/meetings/:meeting_id' + delete "meeting_delete", "/meetings/:meeting_id" # Update a meeting's status - put 'meeting_update_status', '/meetings/:meeting_id/status', + put "meeting_update_status", "/meetings/:meeting_id/status", permit: :action # Update registrant's status - put 'meeting_registrants_status_update', '/meetings/:meeting_id/registrants/status', - require: :action, - permit: [ :occurrence_id, registrants: [] ] + put "meeting_registrants_status_update", "/meetings/:meeting_id/registrants/status", + require: :action, + permit: [:occurrence_id, registrants: []] # Register for a meeting. - post 'meeting_add_registrant', '/meetings/:meeting_id/registrants', + post "meeting_add_registrant", "/meetings/:meeting_id/registrants", require: %i[email first_name], permit: %i[ last_name address city country zip state phone industry org job_title @@ -50,31 +50,31 @@ module Meeting ] # Register up to 30 registrants at once for a meeting that requires registration. - post 'batch_registrants', '/meetings/:meeting_id/batch_registrants', + post "batch_registrants", "/meetings/:meeting_id/batch_registrants", permit: %i[registrants auto_approve registrants_confirmation_email] # Register for a meeting. - patch 'meeting_registrant_questions', '/meeting/:meeting_id/registrants/questions' + patch "meeting_registrant_questions", "/meeting/:meeting_id/registrants/questions" # List users that have registered for a meeting. - get 'list_meeting_registrants', '/meetings/:meeting_id/registrants', + get "list_meeting_registrants", "/meetings/:meeting_id/registrants", permit: %i[occurrence_id status page_size next_page_token] # Retrieve ended meeting details - get 'past_meeting_details', '/past_meetings/:meeting_uuid' + get "past_meeting_details", "/past_meetings/:meeting_uuid" # Retrieve past meeting instances - get 'past_meeting_instances', '/past_meetings/:meeting_id/instances' + get "past_meeting_instances", "/past_meetings/:meeting_id/instances" # Retrieve ended meeting participants - get 'past_meeting_participants', '/past_meetings/:meeting_uuid/participants' + get "past_meeting_participants", "/past_meetings/:meeting_uuid/participants" - patch 'livestream', '/meetings/:meeting_id/livestream', + patch "livestream", "/meetings/:meeting_id/livestream", require: %i[stream_url stream_key], permit: :page_url # Get a meeting on Zoom via meeting ID, return the meeting info. - get 'meeting_invitation', '/meetings/:meeting_id/invitation' + get "meeting_invitation", "/meetings/:meeting_id/invitation" end end end diff --git a/lib/zoom/actions/phone.rb b/lib/zoom/actions/phone.rb index 749f46a3..5a246423 100644 --- a/lib/zoom/actions/phone.rb +++ b/lib/zoom/actions/phone.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -# + module Zoom module Actions module Phone extend Zoom::Actions - get 'call_logs', '/phone/users/:user_id/call_logs' + get "call_logs", "/phone/users/:user_id/call_logs" - get 'phone_users_list', '/phone/users' + get "phone_users_list", "/phone/users" - get 'call_recordings', '/phone/users/:user_id/recordings' + get "call_recordings", "/phone/users/:user_id/recordings" end end end diff --git a/lib/zoom/actions/recording.rb b/lib/zoom/actions/recording.rb index 5eb99c21..599b75ad 100644 --- a/lib/zoom/actions/recording.rb +++ b/lib/zoom/actions/recording.rb @@ -6,19 +6,19 @@ module Recording extend Zoom::Actions RECORDING_SETTINGS_KEYS = %i[share_recording recording_authentication - authentication_option authentication_domains viewer_download password - on_demand approval_type send_email_to_host show_social_share_buttons].freeze + authentication_option authentication_domains viewer_download password + on_demand approval_type send_email_to_host show_social_share_buttons].freeze - get 'recording_list', '/users/:user_id/recordings' + get "recording_list", "/users/:user_id/recordings" - get 'meeting_recording_get', '/meetings/:meeting_id/recordings' + get "meeting_recording_get", "/meetings/:meeting_id/recordings" - get 'meeting_recording_settings_get', '/meetings/:meeting_id/recordings/settings' + get "meeting_recording_settings_get", "/meetings/:meeting_id/recordings/settings" - patch 'meeting_recording_settings_update', '/meetings/:meeting_id/recordings/settings', + patch "meeting_recording_settings_update", "/meetings/:meeting_id/recordings/settings", permit: RECORDING_SETTINGS_KEYS - delete 'meeting_recording_file_delete', '/meetings/:meeting_id/recordings/:recording_id' + delete "meeting_recording_file_delete", "/meetings/:meeting_id/recordings/:recording_id" end end end diff --git a/lib/zoom/actions/report.rb b/lib/zoom/actions/report.rb index a4cff056..8a67f0c7 100644 --- a/lib/zoom/actions/report.rb +++ b/lib/zoom/actions/report.rb @@ -5,18 +5,18 @@ module Actions module Report extend Zoom::Actions - get 'daily_report', '/report/daily', + get "daily_report", "/report/daily", permit: %i[year month] - get 'meeting_details_report', '/report/meetings/:id' + get "meeting_details_report", "/report/meetings/:id" - get 'meeting_participants_report', '/report/meetings/:id/participants', + get "meeting_participants_report", "/report/meetings/:id/participants", permit: %i[page_size next_page_token] - get 'webinar_participants_report', '/report/webinars/:id/participants', + get "webinar_participants_report", "/report/webinars/:id/participants", permit: %i[page_size next_page_token] - get 'webinar_details_report', '/report/webinars/:webinar_id' + get "webinar_details_report", "/report/webinars/:webinar_id" end end end diff --git a/lib/zoom/actions/roles.rb b/lib/zoom/actions/roles.rb index 10a7fd13..d5eeb863 100644 --- a/lib/zoom/actions/roles.rb +++ b/lib/zoom/actions/roles.rb @@ -5,20 +5,20 @@ module Actions module Roles extend Zoom::Actions - get 'roles_list', '/roles' + get "roles_list", "/roles" - post 'roles_create', '/roles', + post "roles_create", "/roles", require: :name, permit: %i[description privileges] - get 'roles_members', '/roles/:role_id/members' + get "roles_members", "/roles/:role_id/members" - post 'roles_assign', '/roles/:role_id/members', + post "roles_assign", "/roles/:role_id/members", require: :members - delete 'roles_unassign', '/roles/:role_id/members/:member_id' + delete "roles_unassign", "/roles/:role_id/members/:member_id" - get 'roles_get', '/roles/:role_id' + get "roles_get", "/roles/:role_id" end end end diff --git a/lib/zoom/actions/sip_audio.rb b/lib/zoom/actions/sip_audio.rb index 03550766..f3568e98 100644 --- a/lib/zoom/actions/sip_audio.rb +++ b/lib/zoom/actions/sip_audio.rb @@ -5,30 +5,30 @@ module Actions module SipAudio extend Zoom::Actions - get 'sip_trunks_get', '/accounts/:account_id/sip_trunk/trunks' + get "sip_trunks_get", "/accounts/:account_id/sip_trunk/trunks" - delete 'sip_trunks_delete', '/accounts/:account_id/sip_trunk/trunks/:trunk_id' + delete "sip_trunks_delete", "/accounts/:account_id/sip_trunk/trunks/:trunk_id" - delete 'sip_trunk_numbers_delete', '/accounts/:account_id/sip_trunk/numbers' + delete "sip_trunk_numbers_delete", "/accounts/:account_id/sip_trunk/numbers" - delete 'sip_trunks_internal_numbers_delete', - '/accounts/:account_id/sip_trunk/internal_numbers/:number_id' + delete "sip_trunks_internal_numbers_delete", + "/accounts/:account_id/sip_trunk/internal_numbers/:number_id" - delete 'sip_trunks_internal_callout_country_delete', - '/accounts/:account_id/sip_trunk/callout_countries/:country_id' + delete "sip_trunks_internal_callout_country_delete", + "/accounts/:account_id/sip_trunk/callout_countries/:country_id" - get 'sip_trunks_internal_numbers_list', '/accounts/:account_id/sip_trunk/internal_numbers', + get "sip_trunks_internal_numbers_list", "/accounts/:account_id/sip_trunk/internal_numbers", permit: %i[page_size next_page_token] - get 'sip_trunks_internal_callout_country_list', '/accounts/:account_id/sip_trunk/callout_countries' + get "sip_trunks_internal_callout_country_list", "/accounts/:account_id/sip_trunk/callout_countries" - get 'sip_trunks_numbers_list', '/sip_trunk/numbers' + get "sip_trunks_numbers_list", "/sip_trunk/numbers" - post 'sip_trunks_internal_numbers_add', '/accounts/:account_id/sip_trunk/internal_numbers' + post "sip_trunks_internal_numbers_add", "/accounts/:account_id/sip_trunk/internal_numbers" - post 'sip_trunks_internal_callout_countries_add', '/accounts/:account_id/sip_trunk/callout_countries' + post "sip_trunks_internal_callout_countries_add", "/accounts/:account_id/sip_trunk/callout_countries" - post 'sip_trunks_numbers_assign', '/accounts/:account_id/sip_trunk/numbers' + post "sip_trunks_numbers_assign", "/accounts/:account_id/sip_trunk/numbers" end end end diff --git a/lib/zoom/actions/token.rb b/lib/zoom/actions/token.rb index 231633a1..43811fcb 100644 --- a/lib/zoom/actions/token.rb +++ b/lib/zoom/actions/token.rb @@ -1,37 +1,37 @@ # frozen_string_literal: true -# + module Zoom module Actions module Token extend Zoom::Actions - post 'access_tokens', - '/oauth/token', + post "access_tokens", + "/oauth/token", oauth: true, require: %i[grant_type code redirect_uri], permit: :code_verifier, - args_to_params: { auth_code: :code } + args_to_params: {auth_code: :code} - post 'access_tokens_account_credentials', - '/oauth/token?grant_type=account_credentials', + post "access_tokens_account_credentials", + "/oauth/token?grant_type=account_credentials", oauth: true, require: :account_id - post 'refresh_tokens', - '/oauth/token', + post "refresh_tokens", + "/oauth/token", oauth: true, require: %i[grant_type refresh_token] - post 'data_compliance', '/oauth/data/compliance', + post "data_compliance", "/oauth/data/compliance", oauth: true, require: %i[ client_id user_id account_id deauthorization_event_received compliance_completed ] - post 'revoke_tokens', '/oauth/revoke', + post "revoke_tokens", "/oauth/revoke", oauth: true, require: :token, - args_to_params: { access_token: :token } + args_to_params: {access_token: :token} end end end diff --git a/lib/zoom/actions/user.rb b/lib/zoom/actions/user.rb index da28ee8b..f35cb063 100644 --- a/lib/zoom/actions/user.rb +++ b/lib/zoom/actions/user.rb @@ -5,10 +5,10 @@ module Actions module User extend Zoom::Actions - get 'user_list', '/users', + get "user_list", "/users", permit: %i[status page_size role_id page_number include_fields next_page_token] - post 'user_create', '/users', + post "user_create", "/users", require: [ :action, user_info: %i[email type] @@ -17,57 +17,57 @@ module User user_info: %i[first_name last_name password] } - get 'user_get', '/users/:id', + get "user_get", "/users/:id", permit: :login_type patch 'user_update', '/users/:id', permit: %i[first_name last_name type pmi timezone dept vanity_name host_key cms_user_id custom_attributes] - delete 'user_delete', '/users/:id', + delete "user_delete", "/users/:id", permit: %i[action transfer_email transfer_meeting transfer_webinar transfer_recording] - get 'user_assistants_list', '/users/:user_id/assistants' + get "user_assistants_list", "/users/:user_id/assistants" - post 'user_assistants_create', '/users/:user_id/assistants', + post "user_assistants_create", "/users/:user_id/assistants", permit: :assistants - delete 'user_assistants_delete_all', '/users/:user_id/assistants' + delete "user_assistants_delete_all", "/users/:user_id/assistants" - delete 'user_assistants_delete', '/users/:user_id/assistants/:assistant_id' + delete "user_assistants_delete", "/users/:user_id/assistants/:assistant_id" - get 'user_schedulers_list', '/users/:user_id/schedulers' + get "user_schedulers_list", "/users/:user_id/schedulers" - delete 'user_schedulers_delete_all', '/users/:user_id/schedulers' + delete "user_schedulers_delete_all", "/users/:user_id/schedulers" - delete 'user_schedulers_delete', '/users/:user_id/schedulers/:scheduler_id' + delete "user_schedulers_delete", "/users/:user_id/schedulers/:scheduler_id" - get 'user_settings_get', '/users/:id/settings', + get "user_settings_get", "/users/:id/settings", permit: [:login_type, :option, :custom_query_fields] - patch 'user_settings_update', '/users/:id/settings', + patch "user_settings_update", "/users/:id/settings", permit: %i[schedule_meeting in_meeting email_notification recording telephony feature tsp] - get 'user_email_check', '/users/email', + get "user_email_check", "/users/email", require: :email - get 'user_recordings_list', '/users/:id/recordings', + get "user_recordings_list", "/users/:id/recordings", permit: %i[page_size next_page_token mc trash from to trash_type] - get 'user_token', '/users/:user_id/token', + get "user_token", "/users/:user_id/token", permit: %i[type ttl] - get 'user_permissions', '/users/:user_id/permissions' + get "user_permissions", "/users/:user_id/permissions" - get 'user_vanity_name', '/users/vanity_name', + get "user_vanity_name", "/users/vanity_name", require: :vanity_name - patch 'user_password_update', '/users/:id/password', + patch "user_password_update", "/users/:id/password", permit: :password - patch 'user_email_update', '/users/:id/email', + patch "user_email_update", "/users/:id/email", permit: :email - patch 'user_status_update', '/users/:id/status', + patch "user_status_update", "/users/:id/status", permit: :status end end diff --git a/lib/zoom/actions/webinar.rb b/lib/zoom/actions/webinar.rb index a72cb3af..4de68627 100644 --- a/lib/zoom/actions/webinar.rb +++ b/lib/zoom/actions/webinar.rb @@ -6,90 +6,90 @@ module Webinar extend Zoom::Actions RECURRENCE_KEYS = %i[type repeat_interval weekly_days monthly_day monthly_week - monthly_week_day end_times end_date_time].freeze + monthly_week_day end_times end_date_time].freeze SETTINGS_KEYS = [ - %i[ - host_video panelists_video practice_session hd_video approval_type - registration_type audio auto_recording enforce_login - enforce_login_domains alternative_hosts close_registration - show_share_button allow_multiple_devices on_demand - request_permission_to_unmute_participants global_dial_in_countries - contact_name contact_email registrants_restrict_number - post_webinar_survey survey_url registrants_email_notification - meeting_authentication authentication_option - authentication_domains registrants_confirmation_email - ], - { - language_interpretation: [ - :enable, - interpreters: %i[email languages] - ], - question_and_answer: %i[ - allow_anonymous_questions answer_questions attendees_can_comment - attendees_can_upvote enable - ], - attendees_and_panelists_reminder_email_notification: %i[enable type], - follow_up_absentees_email_notification: %i[enable type], - follow_up_attendees_email_notification: %i[enable type] - } - ].freeze - - get 'webinar_list', '/users/:host_id/webinars', + %i[ + host_video panelists_video practice_session hd_video approval_type + registration_type audio auto_recording enforce_login + enforce_login_domains alternative_hosts close_registration + show_share_button allow_multiple_devices on_demand + request_permission_to_unmute_participants global_dial_in_countries + contact_name contact_email registrants_restrict_number + post_webinar_survey survey_url registrants_email_notification + meeting_authentication authentication_option + authentication_domains registrants_confirmation_email + ], + { + language_interpretation: [ + :enable, + interpreters: %i[email languages] + ], + question_and_answer: %i[ + allow_anonymous_questions answer_questions attendees_can_comment + attendees_can_upvote enable + ], + attendees_and_panelists_reminder_email_notification: %i[enable type], + follow_up_absentees_email_notification: %i[enable type], + follow_up_attendees_email_notification: %i[enable type] + } + ].freeze + + get "webinar_list", "/users/:host_id/webinars", permit: %i[page_size next_page_token] # TODO: process recurrence keys based on constants # TODO: process settings keys based on constants - post 'webinar_create', '/users/:host_id/webinars', + post "webinar_create", "/users/:host_id/webinars", permit: [ :topic, :type, :start_time, :duration, :timezone, :password, :agenda, - { recurrence: RECURRENCE_KEYS, settings: SETTINGS_KEYS } + {recurrence: RECURRENCE_KEYS, settings: SETTINGS_KEYS} ] - get 'webinar_get', '/webinars/:id' + get "webinar_get", "/webinars/:id" - patch 'webinar_update', '/webinars/:id', + patch "webinar_update", "/webinars/:id", permit: [ :topic, :type, :start_time, :duration, :timezone, :password, :agenda, - { recurrence: RECURRENCE_KEYS, settings: SETTINGS_KEYS } + {recurrence: RECURRENCE_KEYS, settings: SETTINGS_KEYS} ] - delete 'webinar_delete', '/webinars/:id', + delete "webinar_delete", "/webinars/:id", permit: :occurrence_id - get 'webinar_registrants_list', '/webinars/:id/registrants', + get "webinar_registrants_list", "/webinars/:id/registrants", permit: %i[occurrence_id status page_size page_number] - post 'webinar_registrant_add', '/webinars/:id/registrants', + post "webinar_registrant_add", "/webinars/:id/registrants", require: %i[email first_name last_name], permit: %i[ occurrence_ids address city country zip state phone industry org job_title purchasing_time_frame role_in_purchase_process no_of_employees comments custom_questions ] - put 'webinar_registrants_status_update', '/webinars/:id/registrants/status', + put "webinar_registrants_status_update", "/webinars/:id/registrants/status", require: :action, - permit: [ :occurrence_id, registrants: [] ] + permit: [:occurrence_id, registrants: []] - get 'past_webinar_list', '/past_webinars/:id/instances' + get "past_webinar_list", "/past_webinars/:id/instances" - get 'webinar_registrant_get', '/webinars/:webinar_id/registrants/:id', + get "webinar_registrant_get", "/webinars/:webinar_id/registrants/:id", permit: :occurrence_id - get 'webinar_polls_list', '/webinars/:webinar_id/polls' + get "webinar_polls_list", "/webinars/:webinar_id/polls" - get 'webinar_poll_get', '/webinars/:webinar_id/polls/:poll_id' + get "webinar_poll_get", "/webinars/:webinar_id/polls/:poll_id" - get 'webinar_panelist_list', '/webinars/:webinar_id/panelists' + get "webinar_panelist_list", "/webinars/:webinar_id/panelists" - post 'webinar_panelist_add', '/webinars/:webinar_id/panelists', + post "webinar_panelist_add", "/webinars/:webinar_id/panelists", require: :panelists, - permit: [ panelists: [] ] + permit: [panelists: []] - delete 'webinar_panelist_delete', '/webinars/:webinar_id/panelists/:panelist_id' + delete "webinar_panelist_delete", "/webinars/:webinar_id/panelists/:panelist_id" - delete 'webinar_panelists_delete_all', '/webinars/:webinar_id/panelists' + delete "webinar_panelists_delete_all", "/webinars/:webinar_id/panelists" - get 'past_webinars_absentees', '/past_webinars/:webinar_uuid/absentees', + get "past_webinars_absentees", "/past_webinars/:webinar_uuid/absentees", permit: %i[occurrence_id page_size next_page_token] end end diff --git a/lib/zoom/client.rb b/lib/zoom/client.rb index 1eba043e..20e9262a 100644 --- a/lib/zoom/client.rb +++ b/lib/zoom/client.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'httparty' +require "httparty" module Zoom class Client @@ -22,28 +22,28 @@ class Client include Actions::IM::Chat include Actions::IM::Group - base_uri 'https://api.zoom.us/v2' - headers 'Accept' => 'application/json' - headers 'Content-Type' => 'application/json' + base_uri "https://api.zoom.us/v2" + headers "Accept" => "application/json" + headers "Content-Type" => "application/json" def headers { - 'Accept' => 'application/json', - 'Content-Type' => 'application/json', + "Accept" => "application/json", + "Content-Type" => "application/json" } end def oauth_request_headers { - 'Authorization' => "Basic #{auth_token}", - 'Accept' => 'application/json', - 'Content-Type' => 'application/x-www-form-urlencoded', + "Authorization" => "Basic #{auth_token}", + "Accept" => "application/json", + "Content-Type" => "application/x-www-form-urlencoded" } end def bearer_authorization_header { - 'Authorization' => "Bearer #{access_token}" + "Authorization" => "Bearer #{access_token}" } end @@ -52,11 +52,10 @@ def request_headers end def auth_token - Base64.encode64("#{Zoom.configuration.api_key}:#{Zoom.configuration.api_secret}").delete("\n") + Base64.encode64("#{Zoom.configuration.client_id}:#{Zoom.configuration.client_secret}").delete("\n") end end end -require 'zoom/clients/jwt' -require 'zoom/clients/oauth' -require 'zoom/clients/server_to_server_oauth' +require "zoom/clients/oauth" +require "zoom/clients/server_to_server_oauth" diff --git a/lib/zoom/clients/jwt.rb b/lib/zoom/clients/jwt.rb deleted file mode 100644 index 13f2a333..00000000 --- a/lib/zoom/clients/jwt.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true -require 'jwt' -require 'logger' - -module Zoom - class Client - class JWT < Zoom::Client - - def initialize(config) - ::Logger.new(STDOUT).warn('Zoom::Client::JWT is deprecated. Please use Zoom::Client::ServerToServerOAuth instead. See: https://developers.zoom.us/docs/internal-apps/jwt-faq/') - Zoom::Params.new(config).require(:api_key, :api_secret) - config.each { |k, v| instance_variable_set("@#{k}", v) } - self.class.default_timeout(@timeout || 20) - end - - def access_token - ::JWT.encode({ iss: @api_key, exp: Time.now.to_i + @timeout }, @api_secret, 'HS256', { typ: 'JWT' }) - end - - end - end -end - - diff --git a/lib/zoom/clients/oauth.rb b/lib/zoom/clients/oauth.rb index 158da126..1ac5f5a2 100644 --- a/lib/zoom/clients/oauth.rb +++ b/lib/zoom/clients/oauth.rb @@ -13,10 +13,10 @@ class OAuth < Zoom::Client # Returns (access_token, refresh_token) # def initialize(config) - Zoom::Params.new(config).permit( %i[auth_token auth_code redirect_uri access_token refresh_token timeout code_verifier]) + Zoom::Params.new(config).permit(%i[auth_token auth_code redirect_uri access_token refresh_token timeout code_verifier]) Zoom::Params.new(config).require_one_of(%i[access_token refresh_token auth_code]) if (config.keys & [:auth_code, :redirect_uri]).any? - Zoom::Params.new(config).require( %i[auth_code redirect_uri]) + Zoom::Params.new(config).require(%i[auth_code redirect_uri]) end config.each { |k, v| instance_variable_set("@#{k}", v) } @@ -28,14 +28,14 @@ def auth end def refresh - response = refresh_tokens(grant_type: 'refresh_token', refresh_token: @refresh_token) + response = refresh_tokens(grant_type: "refresh_token", refresh_token: @refresh_token) set_tokens(response) response end def oauth response = access_tokens( - grant_type: 'authorization_code', + grant_type: "authorization_code", auth_code: @auth_code, redirect_uri: @redirect_uri, code_verifier: @code_verifier diff --git a/lib/zoom/clients/server_to_server_oauth.rb b/lib/zoom/clients/server_to_server_oauth.rb index 91a91796..59106e61 100644 --- a/lib/zoom/clients/server_to_server_oauth.rb +++ b/lib/zoom/clients/server_to_server_oauth.rb @@ -22,7 +22,7 @@ def auth def auth_token return Base64.urlsafe_encode64("#{@client_id}:#{@client_secret}") if @client_id && @client_secret - Base64.urlsafe_encode64("#{Zoom.configuration.api_key}:#{Zoom.configuration.api_secret}") + raise Zoom::Error.new("Client ID and Client Secret are required to generate an auth token") end private diff --git a/lib/zoom/constants/account/options/pay_modes.rb b/lib/zoom/constants/account/options/pay_modes.rb index b5533783..8387af67 100644 --- a/lib/zoom/constants/account/options/pay_modes.rb +++ b/lib/zoom/constants/account/options/pay_modes.rb @@ -3,10 +3,10 @@ module Constants module Account module Options PAY_MODES = { - 'master' => 'Master account holder pays', # default - 'sub' => 'Sub account holder pays' + "master" => "Master account holder pays", # default + "sub" => "Sub account holder pays" }.freeze end end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/account/settings/permitted_settings.rb b/lib/zoom/constants/account/settings/permitted_settings.rb index 53edad29..64aa9e26 100644 --- a/lib/zoom/constants/account/settings/permitted_settings.rb +++ b/lib/zoom/constants/account/settings/permitted_settings.rb @@ -107,7 +107,7 @@ module Settings :call_out, :show_international_numbers_link, :display_toll_free_numbers, - { call_out_countries: [] } + {call_out_countries: []} ], integration: %i[ google_calendar @@ -122,4 +122,4 @@ module Settings end end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/constants.rb b/lib/zoom/constants/constants.rb index 405b2ca7..005da392 100644 --- a/lib/zoom/constants/constants.rb +++ b/lib/zoom/constants/constants.rb @@ -1,35 +1,35 @@ # frozen_string_literal: true -require_relative 'account/options/pay_modes' -require_relative 'account/settings/permitted_settings' -require_relative 'meeting/approval_types' -require_relative 'meeting/audio_type' -require_relative 'meeting/auto_recording' -require_relative 'meeting/registration_types' -require_relative 'meeting/types' -require_relative 'recurrence/monthly_weeks' -require_relative 'recurrence/types' -require_relative 'recurrence/weekly_days' -require_relative 'user/create_types' -require_relative 'user/types' -require_relative 'webinar/approval_types' -require_relative 'webinar/audio_type' -require_relative 'webinar/auto_recording' -require_relative 'webinar/registration_types' -require_relative 'webinar/types' +require_relative "account/options/pay_modes" +require_relative "account/settings/permitted_settings" +require_relative "meeting/approval_types" +require_relative "meeting/audio_type" +require_relative "meeting/auto_recording" +require_relative "meeting/registration_types" +require_relative "meeting/types" +require_relative "recurrence/monthly_weeks" +require_relative "recurrence/types" +require_relative "recurrence/weekly_days" +require_relative "user/create_types" +require_relative "user/types" +require_relative "webinar/approval_types" +require_relative "webinar/audio_type" +require_relative "webinar/auto_recording" +require_relative "webinar/registration_types" +require_relative "webinar/types" module Zoom module Constants IM_GROUP_TYPES = { - 'normal' => 'Only members can see the group automatically. Other people can search members in the group.', # default - 'shared' => 'All people in the account can see the group and members automatically', - 'restricted' => 'Nobody can see the group or search members except the members in the group' + "normal" => "Only members can see the group automatically. Other people can search members in the group.", # default + "shared" => "All people in the account can see the group and members automatically", + "restricted" => "Nobody can see the group or search members except the members in the group" }.freeze REGISTRANT_STATUS_ACTIONS = { - 'Approve registrant' => 'approve', - 'Cancel registrant' => 'cancel', - 'Deny registrant' => 'deny' + "Approve registrant" => "approve", + "Cancel registrant" => "cancel", + "Deny registrant" => "deny" }.freeze # no default end end diff --git a/lib/zoom/constants/meeting/approval_types.rb b/lib/zoom/constants/meeting/approval_types.rb index edf9cf9a..99614b0f 100644 --- a/lib/zoom/constants/meeting/approval_types.rb +++ b/lib/zoom/constants/meeting/approval_types.rb @@ -2,10 +2,10 @@ module Zoom module Constants module Meeting APPROVAL_TYPES = { - 'Automatically Approve' => 0, - 'Manually Approve' => 1, - 'No Registration Required' => 2 # default + "Automatically Approve" => 0, + "Manually Approve" => 1, + "No Registration Required" => 2 # default }.freeze end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/meeting/audio_type.rb b/lib/zoom/constants/meeting/audio_type.rb index fd200d55..9f52c297 100644 --- a/lib/zoom/constants/meeting/audio_type.rb +++ b/lib/zoom/constants/meeting/audio_type.rb @@ -2,10 +2,10 @@ module Zoom module Constants module Meeting AUDIO_TYPE = { - 'Both Telephony and VoIP' => 'both', # default - 'Telephony only' => 'telephony', - 'VoIP only' => 'voip' + "Both Telephony and VoIP" => "both", # default + "Telephony only" => "telephony", + "VoIP only" => "voip" }.freeze end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/meeting/auto_recording.rb b/lib/zoom/constants/meeting/auto_recording.rb index 4d8d9957..c2ffde21 100644 --- a/lib/zoom/constants/meeting/auto_recording.rb +++ b/lib/zoom/constants/meeting/auto_recording.rb @@ -2,10 +2,10 @@ module Zoom module Constants module Meeting AUTO_RECORDING = { - 'Record to local device' => 'local', - 'Record to cloud' => 'cloud', - 'No Recording' => 'none' # default + "Record to local device" => "local", + "Record to cloud" => "cloud", + "No Recording" => "none" # default }.freeze end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/meeting/registration_types.rb b/lib/zoom/constants/meeting/registration_types.rb index 000d634a..395f6898 100644 --- a/lib/zoom/constants/meeting/registration_types.rb +++ b/lib/zoom/constants/meeting/registration_types.rb @@ -2,10 +2,10 @@ module Zoom module Constants module Meeting REGISTRATION_TYPES = { - 'Attendees register once and can attend any of the occurrences' => 1, # default - 'Attendees need to register for each occurrence to attend' => 2, - 'Attendees register once and can choose one or more occurrences to attend' => 3 + "Attendees register once and can attend any of the occurrences" => 1, # default + "Attendees need to register for each occurrence to attend" => 2, + "Attendees register once and can choose one or more occurrences to attend" => 3 }.freeze end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/meeting/types.rb b/lib/zoom/constants/meeting/types.rb index f96c75eb..b995ec51 100644 --- a/lib/zoom/constants/meeting/types.rb +++ b/lib/zoom/constants/meeting/types.rb @@ -2,11 +2,11 @@ module Zoom module Constants module Meeting TYPES = { - 1 => 'Instant Meeting', - 2 => 'Scheduled Meeting', # default - 3 => 'Recurring Meeting with no fixed time', - 8 => 'Recurring Meeting with fixed time' + 1 => "Instant Meeting", + 2 => "Scheduled Meeting", # default + 3 => "Recurring Meeting with no fixed time", + 8 => "Recurring Meeting with fixed time" }.freeze end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/recurrence/monthly_weeks.rb b/lib/zoom/constants/recurrence/monthly_weeks.rb index 45a620b2..439843e0 100644 --- a/lib/zoom/constants/recurrence/monthly_weeks.rb +++ b/lib/zoom/constants/recurrence/monthly_weeks.rb @@ -2,12 +2,12 @@ module Zoom module Constants module Recurrence MONTHLY_WEEKS = { - -1 => 'Last week', - 1 => 'First week', - 2 => 'Second week', - 3 => 'Third week', - 4 => 'Fourth week' + -1 => "Last week", + 1 => "First week", + 2 => "Second week", + 3 => "Third week", + 4 => "Fourth week" }.freeze # no default end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/recurrence/types.rb b/lib/zoom/constants/recurrence/types.rb index 64d259f9..a3ef7b47 100644 --- a/lib/zoom/constants/recurrence/types.rb +++ b/lib/zoom/constants/recurrence/types.rb @@ -2,10 +2,10 @@ module Zoom module Constants module Recurrence TYPES = { - 1 => 'Daily', - 2 => 'Weekly', - 3 => 'Monthly' + 1 => "Daily", + 2 => "Weekly", + 3 => "Monthly" }.freeze # no default end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/recurrence/weekly_days.rb b/lib/zoom/constants/recurrence/weekly_days.rb index 8a716ea4..9bbb324e 100644 --- a/lib/zoom/constants/recurrence/weekly_days.rb +++ b/lib/zoom/constants/recurrence/weekly_days.rb @@ -2,14 +2,14 @@ module Zoom module Constants module Recurrence WEEKLY_DAYS = { - 1 => 'Sunday', - 2 => 'Monday', - 3 => 'Tuesday', - 4 => 'Wednesday', - 5 => 'Thursday', - 6 => 'Friday', - 7 => 'Saturday' + 1 => "Sunday", + 2 => "Monday", + 3 => "Tuesday", + 4 => "Wednesday", + 5 => "Thursday", + 6 => "Friday", + 7 => "Saturday" }.freeze # no default end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/user/create_types.rb b/lib/zoom/constants/user/create_types.rb index cb1969f7..84c3c2c1 100644 --- a/lib/zoom/constants/user/create_types.rb +++ b/lib/zoom/constants/user/create_types.rb @@ -2,11 +2,11 @@ module Zoom module Constants module User CREATE_TYPES = { - 'create' => 'User will get an email sent from Zoom. There is a confirmation link in this email. User will then need to click this link to activate their account to the Zoom service. The user can set or change their password in Zoom.', - 'autoCreate' => 'This action is provided for enterprise customer who has a managed domain. This feature is disabled by default because of the security risk involved in creating a user who does not belong to your domain without notifying the user.', - 'custCreate' => 'This action is provided for API partner only. User created in this way has no password and is not able to log into the Zoom web site or client.', - 'ssoCreate' => 'This action is provided for enabled “Pre-provisioning SSO User” option. User created in this way has no password. If it is not a basic user, will generate a Personal Vanity URL using user name (no domain) of the provisioning email. If user name or pmi is invalid or occupied, will use random number/random personal vanity URL.' + "create" => "User will get an email sent from Zoom. There is a confirmation link in this email. User will then need to click this link to activate their account to the Zoom service. The user can set or change their password in Zoom.", + "autoCreate" => "This action is provided for enterprise customer who has a managed domain. This feature is disabled by default because of the security risk involved in creating a user who does not belong to your domain without notifying the user.", + "custCreate" => "This action is provided for API partner only. User created in this way has no password and is not able to log into the Zoom web site or client.", + "ssoCreate" => "This action is provided for enabled “Pre-provisioning SSO User” option. User created in this way has no password. If it is not a basic user, will generate a Personal Vanity URL using user name (no domain) of the provisioning email. If user name or pmi is invalid or occupied, will use random number/random personal vanity URL." }.freeze # no default end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/user/types.rb b/lib/zoom/constants/user/types.rb index a7d3e19a..4d3b5660 100644 --- a/lib/zoom/constants/user/types.rb +++ b/lib/zoom/constants/user/types.rb @@ -2,10 +2,10 @@ module Zoom module Constants module User TYPES = { - 'basic' => 1, - 'pro' => 2, - 'corp' => 3 + "basic" => 1, + "pro" => 2, + "corp" => 3 }.freeze # no default end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/webinar/approval_types.rb b/lib/zoom/constants/webinar/approval_types.rb index 6edaa4bf..d018146b 100644 --- a/lib/zoom/constants/webinar/approval_types.rb +++ b/lib/zoom/constants/webinar/approval_types.rb @@ -2,10 +2,10 @@ module Zoom module Constants module Webinar APPROVAL_TYPES = { - 0 => 'Automatically Approve', - 1 => 'Manually Approve', - 2 => 'No Registration Required' # default + 0 => "Automatically Approve", + 1 => "Manually Approve", + 2 => "No Registration Required" # default }.freeze end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/webinar/audio_type.rb b/lib/zoom/constants/webinar/audio_type.rb index 748c2fab..fb14f65e 100644 --- a/lib/zoom/constants/webinar/audio_type.rb +++ b/lib/zoom/constants/webinar/audio_type.rb @@ -2,10 +2,10 @@ module Zoom module Constants module Webinar AUDIO_TYPE = { - 'Both Telephony and VoIP' => 'both', # default - 'Telephony only' => 'telephony', - 'VoIP only' => 'voip' + "Both Telephony and VoIP" => "both", # default + "Telephony only" => "telephony", + "VoIP only" => "voip" }.freeze end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/webinar/auto_recording.rb b/lib/zoom/constants/webinar/auto_recording.rb index af3a0840..f03005dc 100644 --- a/lib/zoom/constants/webinar/auto_recording.rb +++ b/lib/zoom/constants/webinar/auto_recording.rb @@ -2,10 +2,10 @@ module Zoom module Constants module Webinar AUTO_RECORDING = { - 'Record to local device' => 'local', - 'Record to cloud' => 'cloud', - 'No Recording' => 'none' # default + "Record to local device" => "local", + "Record to cloud" => "cloud", + "No Recording" => "none" # default }.freeze end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/webinar/registration_types.rb b/lib/zoom/constants/webinar/registration_types.rb index 712be57f..f5c5682e 100644 --- a/lib/zoom/constants/webinar/registration_types.rb +++ b/lib/zoom/constants/webinar/registration_types.rb @@ -2,10 +2,10 @@ module Zoom module Constants module Webinar REGISTRATION_TYPES = { - 1 => 'Attendees register once and can attend any of the occurrences', # default - 2 => 'Attendees need to register for each occurrence to attend', - 3 => 'Attendees register once and can choose one or more occurrences to attend' + 1 => "Attendees register once and can attend any of the occurrences", # default + 2 => "Attendees need to register for each occurrence to attend", + 3 => "Attendees register once and can choose one or more occurrences to attend" }.freeze end end -end \ No newline at end of file +end diff --git a/lib/zoom/constants/webinar/types.rb b/lib/zoom/constants/webinar/types.rb index f7e198e2..a2b22484 100644 --- a/lib/zoom/constants/webinar/types.rb +++ b/lib/zoom/constants/webinar/types.rb @@ -2,10 +2,10 @@ module Zoom module Constants module Webinar TYPES = { - 5 => 'Webinar', # default - 6 => 'Recurring Webinar with no fixed time', - 9 => 'Recurring Webinar with fixed time' + 5 => "Webinar", # default + 6 => "Recurring Webinar with no fixed time", + 9 => "Recurring Webinar with fixed time" }.freeze end end -end \ No newline at end of file +end diff --git a/lib/zoom/error.rb b/lib/zoom/error.rb index 7dc9a989..0c7e083e 100644 --- a/lib/zoom/error.rb +++ b/lib/zoom/error.rb @@ -4,22 +4,35 @@ module Zoom class Error < StandardError attr_reader :error_hash - def initialize(msg, error_hash={}) + def initialize(msg, error_hash = {}) @error_hash = error_hash super(msg) end end + class GatewayTimeout < Error; end + class NotImplemented < Error; end + class ParameterMissing < Error; end + class ParameterNotPermitted < Error; end + class ParameterValueNotPermitted < Error; end + class AuthenticationError < Error; end + class BadRequest < Error; end + class Unauthorized < Error; end + class Forbidden < Error; end + class NotFound < Error; end + class Conflict < Error; end + class TooManyRequests < Error; end + class InternalServerError < Error; end end diff --git a/lib/zoom/params.rb b/lib/zoom/params.rb index 71aa530e..61d1a61f 100644 --- a/lib/zoom/params.rb +++ b/lib/zoom/params.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true -require 'delegate' + +require "delegate" module Zoom class Params < SimpleDelegator @@ -18,20 +19,20 @@ def require_one_of(*keys) required_keys = keys keys = find_matching_keys(keys.flatten) unless keys.any? - message = required_keys.length > 1 ? "You are missing atleast one of #{required_keys}" : required_keys + message = (required_keys.length > 1) ? "You are missing atleast one of #{required_keys}" : required_keys raise Zoom::ParameterMissing, message end end def permit(*filters) permitted_keys = filters.flatten.each.with_object([]) do |filter, array| - case filter - when Symbol, String - array << filter - when Hash - array << hash_filter(filter) - end - end + case filter + when Symbol, String + array << filter + when Hash + array << hash_filter(filter) + end + end non_permitted_params = parameters_keys - permitted_keys.flatten raise Zoom::ParameterNotPermitted, non_permitted_params.to_s unless non_permitted_params.empty? end @@ -46,7 +47,7 @@ def except!(keys) end EMPTY_ARRAY = [].freeze - EMPTY_HASH = {}.freeze + EMPTY_HASH = {}.freeze def hash_filter(filter) # Slicing filters out non-declared keys. @@ -86,7 +87,7 @@ def find_missing_entries(*entries) entry.keys.each do |k| array << k && next if self[k].nil? missing_entries = self.class.new(self[k]).find_missing_entries(*entry[k]) - array << { k => missing_entries } unless missing_entries.empty? + array << {k => missing_entries} unless missing_entries.empty? end elsif self[entry].nil? array << entry @@ -108,7 +109,7 @@ def permit_value(key, values) end def parameters_keys - if @parameters.kind_of?(Array) + if @parameters.is_a?(Array) @parameters.map(&:keys).flatten.uniq else @parameters.keys diff --git a/lib/zoom/utils.rb b/lib/zoom/utils.rb index b689bc49..c464a19c 100644 --- a/lib/zoom/utils.rb +++ b/lib/zoom/utils.rb @@ -11,10 +11,10 @@ def exclude_argument_error(name) name ? ArgumentError.new("Unrecognized parameter #{name}") : ArgumentError.new end - def raise_if_error!(response, http_code=200) - return response unless response.is_a?(Hash) && response.key?('code') + def raise_if_error!(response, http_code = 200) + return response unless response.is_a?(Hash) && response.key?("code") - code = response['code'] + code = response["code"] error_hash = build_error(response) raise AuthenticationError, error_hash if code == 124 @@ -29,8 +29,8 @@ def raise_if_error!(response, http_code=200) end def build_error(response) - error_hash = { base: response['message']} - error_hash[response['message']] = response['errors'] if response['errors'] + error_hash = {base: response["message"]} + error_hash[response["message"]] = response["errors"] if response["errors"] error_hash end @@ -45,14 +45,14 @@ def extract_options!(array) def validate_password(password) password_regex = /\A[a-zA-Z0-9@-_*]{0,10}\z/ - raise(Error , 'Invalid Password') unless password[password_regex].nil? + raise(Error, "Invalid Password") unless password[password_regex].nil? end def process_datetime_params!(params) params.each do |key, value| case key when Symbol, String - params[key] = value.is_a?(Time) ? value.strftime('%FT%TZ') : value + params[key] = value.is_a?(Time) ? value.strftime("%FT%TZ") : value when Hash process_datetime_params!(params[key]) end diff --git a/lib/zoom/version.rb b/lib/zoom/version.rb index a941945d..c6166923 100644 --- a/lib/zoom/version.rb +++ b/lib/zoom/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Zoom - VERSION = '1.1.8' + VERSION = "2.0.0" end diff --git a/lib/zoom_rb.rb b/lib/zoom_rb.rb index 5f6badef..9d20c25d 100644 --- a/lib/zoom_rb.rb +++ b/lib/zoom_rb.rb @@ -2,29 +2,29 @@ $:.unshift File.dirname(__FILE__) -require 'zoom/version' -require 'zoom/constants/constants' -require 'zoom/params' -require 'zoom/utils' -require 'zoom/actions' -require 'zoom/actions/account' -require 'zoom/actions/billing' -require 'zoom/actions/dashboard' -require 'zoom/actions/groups' -require 'zoom/actions/m323_device' -require 'zoom/actions/meeting' -require 'zoom/actions/recording' -require 'zoom/actions/report' -require 'zoom/actions/roles' -require 'zoom/actions/token' -require 'zoom/actions/user' -require 'zoom/actions/webinar' -require 'zoom/actions/phone' -require 'zoom/actions/im/chat' -require 'zoom/actions/im/group' -require 'zoom/actions/sip_audio' -require 'zoom/client' -require 'zoom/error' +require "zoom/version" +require "zoom/constants/constants" +require "zoom/params" +require "zoom/utils" +require "zoom/actions" +require "zoom/actions/account" +require "zoom/actions/billing" +require "zoom/actions/dashboard" +require "zoom/actions/groups" +require "zoom/actions/m323_device" +require "zoom/actions/meeting" +require "zoom/actions/recording" +require "zoom/actions/report" +require "zoom/actions/roles" +require "zoom/actions/token" +require "zoom/actions/user" +require "zoom/actions/webinar" +require "zoom/actions/phone" +require "zoom/actions/im/chat" +require "zoom/actions/im/group" +require "zoom/actions/sip_audio" +require "zoom/client" +require "zoom/error" module Zoom class << self @@ -32,9 +32,10 @@ class << self def new @configuration ||= Configuration.new - Zoom::Client::JWT.new( - api_key: @configuration.api_key, - api_secret: @configuration.api_secret, + Zoom::Client::ServerToServerOAuth.new( + account_id: @configuration.account_id, + client_id: @configuration.client_id, + client_secret: @configuration.client_secret, timeout: @configuration.timeout ) end @@ -46,10 +47,10 @@ def configure end class Configuration - attr_accessor :api_key, :api_secret, :timeout, :access_token + attr_accessor :account_id, :client_id, :client_secret, :timeout, :access_token def initialize - @api_key = @api_secret = 'xxx' + @client_id = @api_secret = @account_id = "xxx" @access_token = nil @timeout = 15 end diff --git a/spec/lib/zoom/actions/account/create_spec.rb b/spec/lib/zoom/actions/account/create_spec.rb index 09ff9241..5687421c 100644 --- a/spec/lib/zoom/actions/account/create_spec.rb +++ b/spec/lib/zoom/actions/account/create_spec.rb @@ -1,66 +1,66 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Account do let(:zc) { zoom_client } let(:args) { { - first_name: 'Foo', - last_name: 'Barton', - email: 'foo@bar.com', - password: 'password1' + first_name: "Foo", + last_name: "Barton", + email: "foo@bar.com", + password: "password1" } } let(:options) { { options: { share_rc: true, - room_connectors: '127.0.0.1', + room_connectors: "127.0.0.1", share_mc: true, - meeting_connectors: '127.0.0.1', - pay_mode: 'master' + meeting_connectors: "127.0.0.1", + pay_mode: "master" } } } - describe '#account_create action' do - context 'with a valid response' do + describe "#account_create action" do + context "with a valid response" do before :each do stub_request( :post, - zoom_url('/accounts') - ).to_return(body: json_response('account', 'create'), - headers: { 'Content-Type' => 'application/json' }) + zoom_url("/accounts") + ).to_return(body: json_response("account", "create"), + headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.account_create(args)).to be_kind_of(Hash) end - it 'allows options' do + it "allows options" do expect(zc.account_create(args.merge(options))).to be_kind_of(Hash) end - it 'raises an error when additional params are supplied' do - expect { zc.account_create(args.merge(options.merge(foo: 'bar'))) }.to raise_error(Zoom::ParameterNotPermitted, [:foo].to_s) + it "raises an error when additional params are supplied" do + expect { zc.account_create(args.merge(options.merge(foo: "bar"))) }.to raise_error(Zoom::ParameterNotPermitted, [:foo].to_s) end - it 'raises an error when missing a required param' do + it "raises an error when missing a required param" do expect { zc.account_create(args.slice(*%i[first_name last_name email])) }.to raise_error(Zoom::ParameterMissing, [:password].to_s) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :post, - zoom_url('/accounts') + zoom_url("/accounts") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.account_create(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/account/delete_spec.rb b/spec/lib/zoom/actions/account/delete_spec.rb index b78b59e6..40902ea1 100644 --- a/spec/lib/zoom/actions/account/delete_spec.rb +++ b/spec/lib/zoom/actions/account/delete_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Account do let(:zc) { zoom_client } - let(:args) { { account_id: 1 } } + let(:args) { {account_id: 1} } - describe '#account_delete action' do - context 'with a valid response' do + describe "#account_delete action" do + context "with a valid response" do before :each do stub_request( :delete, zoom_url("/accounts/#{args[:account_id]}") ).to_return(status: 204, - body: json_response('account', 'delete'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("account", "delete"), + headers: {"Content-Type" => "application/json"}) end - it 'requires the account_id params' do + it "requires the account_id params" do expect { zc.account_delete }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.account_delete(args)).to eql(204) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :delete, zoom_url("/accounts/#{args[:account_id]}") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.account_delete(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/account/get_locked_settings_spec.rb b/spec/lib/zoom/actions/account/get_locked_settings_spec.rb index fe363af4..40c78880 100644 --- a/spec/lib/zoom/actions/account/get_locked_settings_spec.rb +++ b/spec/lib/zoom/actions/account/get_locked_settings_spec.rb @@ -1,43 +1,43 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Account do let(:zc) { zoom_client } - let(:args) { { account_id: 1 } } + let(:args) { {account_id: 1} } - describe '#account_get_locked_settings action' do - context 'with a valid response' do + describe "#account_get_locked_settings action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/lock_settings") - ).to_return(body: json_response('account', 'settings_get'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("account", "settings_get"), + headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.account_get_locked_settings(args)).to be_kind_of(Hash) end - it 'raises an error when missing a required param' do + it "raises an error when missing a required param" do expect { zc.account_get_locked_settings }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/lock_settings") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.account_get_locked_settings(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/account/get_spec.rb b/spec/lib/zoom/actions/account/get_spec.rb index 8e631467..33e50e2a 100644 --- a/spec/lib/zoom/actions/account/get_spec.rb +++ b/spec/lib/zoom/actions/account/get_spec.rb @@ -1,41 +1,41 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Account do let(:zc) { zoom_client } - let(:args) { { account_id: 1 } } + let(:args) { {account_id: 1} } - describe '#account_get action' do - context 'with a valid response' do + describe "#account_get action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}") - ).to_return(body: json_response('account', 'get'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("account", "get"), + headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.account_get(args)).to be_kind_of(Hash) end - it 'raises an error when missing a required param' do + it "raises an error when missing a required param" do expect { zc.account_get }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.account_get(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/account/list_spec.rb b/spec/lib/zoom/actions/account/list_spec.rb index 72df8d71..abba1f6e 100644 --- a/spec/lib/zoom/actions/account/list_spec.rb +++ b/spec/lib/zoom/actions/account/list_spec.rb @@ -1,23 +1,23 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Account do let(:zc) { zoom_client } let(:args) { {} } - describe '#account_list action' do - context 'with a valid response' do + describe "#account_list action" do + context "with a valid response" do before :each do stub_request( :get, - zoom_url('/accounts') - ).to_return(body: json_response('account', 'list'), - headers: { 'Content-Type' => 'application/json' }) + zoom_url("/accounts") + ).to_return(body: json_response("account", "list"), + headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.account_list(args)).to be_kind_of(Hash) end @@ -28,29 +28,29 @@ end it "returns 'total_records" do - expect(zc.account_list(args)['total_records']).to eq(1) + expect(zc.account_list(args)["total_records"]).to eq(1) end it "returns 'accounts' Array" do - expect(zc.account_list(args)['accounts']).to be_kind_of(Array) + expect(zc.account_list(args)["accounts"]).to be_kind_of(Array) end - it 'raises an error when passed an invalid option' do - expect { zc.account_list(foo: 'bar') }.to raise_error(Zoom::ParameterNotPermitted, [:foo].to_s) + it "raises an error when passed an invalid option" do + expect { zc.account_list(foo: "bar") }.to raise_error(Zoom::ParameterNotPermitted, [:foo].to_s) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, - zoom_url('/accounts') + zoom_url("/accounts") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.account_list }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/account/managed_domains_spec.rb b/spec/lib/zoom/actions/account/managed_domains_spec.rb index 62a5b766..37a1d813 100644 --- a/spec/lib/zoom/actions/account/managed_domains_spec.rb +++ b/spec/lib/zoom/actions/account/managed_domains_spec.rb @@ -1,41 +1,41 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Zoom::Actions::Account do let(:zc) { zoom_client } - let(:args) { { account_id: 1 } } + let(:args) { {account_id: 1} } - describe '#account_managed_domains action' do - context 'with a valid response' do + describe "#account_managed_domains action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/managed_domains") - ).to_return(body: json_response('account', 'managed_domains'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("account", "managed_domains"), + headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.account_managed_domains(args)).to be_kind_of(Hash) end - it 'raises an error when missing a required param' do + it "raises an error when missing a required param" do expect { zc.account_managed_domains }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/managed_domains") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.account_managed_domains(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/account/options_update_spec.rb b/spec/lib/zoom/actions/account/options_update_spec.rb index ee728f30..7c28fce1 100644 --- a/spec/lib/zoom/actions/account/options_update_spec.rb +++ b/spec/lib/zoom/actions/account/options_update_spec.rb @@ -1,56 +1,56 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Account do let(:zc) { zoom_client } let(:args) { { - account_id: '1', + account_id: "1", share_rc: true, - room_connectors: '127.0.0.1', + room_connectors: "127.0.0.1", share_mc: true, - meeting_connectors: '127.0.0.1', - pay_mode: 'master' + meeting_connectors: "127.0.0.1", + pay_mode: "master" } } - describe '#options_update action' do - context 'with a valid response' do + describe "#options_update action" do + context "with a valid response" do before :each do stub_request( :patch, zoom_url("/accounts/#{args[:account_id]}/options") - ).to_return(body: json_response('account', 'options_update'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("account", "options_update"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do + it "requires id param" do expect { zc.account_options_update }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.account_options_update(args)).to be_kind_of(Hash) end - it 'returns same params' do + it "returns same params" do res = zc.account_options_update(args) expect(res.keys).to match_array(%w[share_rc room_connectors share_mc meeting_connectors pay_mode]) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :patch, zoom_url("/accounts/#{args[:account_id]}/options") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.account_options_update(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/account/settings_get_spec.rb b/spec/lib/zoom/actions/account/settings_get_spec.rb index efc48569..bdb4d108 100644 --- a/spec/lib/zoom/actions/account/settings_get_spec.rb +++ b/spec/lib/zoom/actions/account/settings_get_spec.rb @@ -1,48 +1,48 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Account do let(:zc) { zoom_client } - let(:args) { { account_id: '1' } } + let(:args) { {account_id: "1"} } - describe '#settings_get action' do - context 'with a valid response' do + describe "#settings_get action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/settings") - ).to_return(status: 200, - body: json_response('account', 'settings_get'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(status: 200, + body: json_response("account", "settings_get"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do + it "requires id param" do expect { zc.account_settings_get }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.account_settings_get(args)).to be_kind_of(Hash) end - it 'returns same params' do + it "returns same params" do res = zc.account_settings_get(args) expect(res.keys).to match_array(%w[email_notification feature in_meeting integration recording schedule_meeting security telephony tsp zoom_rooms]) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/settings") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.account_settings_get(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/account/settings_update_spec.rb b/spec/lib/zoom/actions/account/settings_update_spec.rb index 375c502e..0b794cc8 100644 --- a/spec/lib/zoom/actions/account/settings_update_spec.rb +++ b/spec/lib/zoom/actions/account/settings_update_spec.rb @@ -1,53 +1,53 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Account do let(:zc) { zoom_client } let(:args) { { - account_id: '1', + account_id: "1", schedule_meeting: { host_video: true } } } - describe '#settings_update action' do - context 'with a valid response' do + describe "#settings_update action" do + context "with a valid response" do before :each do stub_request( :patch, zoom_url("/accounts/#{args[:account_id]}/settings") - ).to_return(status: 204, - body: json_response('account', 'settings_update'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(status: 204, + body: json_response("account", "settings_update"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do + it "requires id param" do expect { zc.account_settings_update }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end - it 'raises an error when passed an invalid param' do - expect { zc.account_settings_update(args.merge(foo: 'bar')) }.to raise_error(Zoom::ParameterNotPermitted, [:foo].to_s) + it "raises an error when passed an invalid param" do + expect { zc.account_settings_update(args.merge(foo: "bar")) }.to raise_error(Zoom::ParameterNotPermitted, [:foo].to_s) end - it 'returns a 204 successful response' do + it "returns a 204 successful response" do expect(zc.account_settings_update(args)).to eql(204) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :patch, zoom_url("/accounts/#{args[:account_id]}/settings") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.account_settings_update(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/account/trusted_domains_spec.rb b/spec/lib/zoom/actions/account/trusted_domains_spec.rb index 01ccc1a1..4003e397 100644 --- a/spec/lib/zoom/actions/account/trusted_domains_spec.rb +++ b/spec/lib/zoom/actions/account/trusted_domains_spec.rb @@ -1,41 +1,41 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Zoom::Actions::Account do let(:zc) { zoom_client } - let(:args) { { account_id: 1 } } + let(:args) { {account_id: 1} } - describe '#account_trusted_domains action' do - context 'with a valid response' do + describe "#account_trusted_domains action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/trusted_domains") - ).to_return(body: json_response('account', 'trusted_domains'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("account", "trusted_domains"), + headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.account_trusted_domains(args)).to be_kind_of(Hash) end - it 'raises an error when missing a required param' do + it "raises an error when missing a required param" do expect { zc.account_trusted_domains }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/trusted_domains") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.account_trusted_domains(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/billing/get_spec.rb b/spec/lib/zoom/actions/billing/get_spec.rb index 1ccf6f4f..3f6e7be5 100644 --- a/spec/lib/zoom/actions/billing/get_spec.rb +++ b/spec/lib/zoom/actions/billing/get_spec.rb @@ -1,46 +1,46 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Billing do let(:zc) { zoom_client } - let(:args) { { account_id: '1' } } + let(:args) { {account_id: "1"} } - describe '#billing_get action' do - context 'with a valid response' do + describe "#billing_get action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/billing") - ).to_return(body: json_response('billing', 'get'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("billing", "get"), + headers: {"Content-Type" => "application/json"}) end - it 'makes the request' do + it "makes the request" do zc.billing_get(args) expect(WebMock).to have_requested(:get, zoom_url("/accounts/#{args[:account_id]}/billing")).with(headers: request_headers) end - it 'returns a hash' do + it "returns a hash" do expect(zc.billing_get(args)).to be_kind_of(Hash) end - it 'raises an error when missing a required param' do + it "raises an error when missing a required param" do expect { zc.billing_get }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/billing") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.billing_get(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/billing/plans_list_spec.rb b/spec/lib/zoom/actions/billing/plans_list_spec.rb index 68cc2c88..af77b15a 100644 --- a/spec/lib/zoom/actions/billing/plans_list_spec.rb +++ b/spec/lib/zoom/actions/billing/plans_list_spec.rb @@ -1,46 +1,46 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Billing do let(:zc) { zoom_client } - let(:args) { { account_id: '1' } } + let(:args) { {account_id: "1"} } - describe '#billing_plans_list action' do - context 'with a valid response' do + describe "#billing_plans_list action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/plans") - ).to_return(body: json_response('billing', 'plans_list'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("billing", "plans_list"), + headers: {"Content-Type" => "application/json"}) end - it 'makes the request' do + it "makes the request" do zc.billing_plans_list(args) expect(WebMock).to have_requested(:get, zoom_url("/accounts/#{args[:account_id]}/plans")).with(headers: request_headers) end - it 'returns a hash' do + it "returns a hash" do expect(zc.billing_plans_list(args)).to be_kind_of(Hash) end - it 'raises an error when missing a required param' do + it "raises an error when missing a required param" do expect { zc.billing_plans_list }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/plans") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.billing_plans_list(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/billing/plans_subscribe_spec.rb b/spec/lib/zoom/actions/billing/plans_subscribe_spec.rb index 67a3736e..639c7ee5 100644 --- a/spec/lib/zoom/actions/billing/plans_subscribe_spec.rb +++ b/spec/lib/zoom/actions/billing/plans_subscribe_spec.rb @@ -1,67 +1,67 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Billing do let(:zc) { zoom_client } - let(:url_args) { { account_id: '1' } } + let(:url_args) { {account_id: "1"} } let(:required_args) { { contact: { - first_name: 'Foo', - last_name: 'Bar', - email: 'foo@bar.com', - phone_number: '1234567890', - address: '123 Test St', - apt: 'A', - city: 'Vancouver', - state: 'WA', - zip: '98660', - country: 'US' + first_name: "Foo", + last_name: "Bar", + email: "foo@bar.com", + phone_number: "1234567890", + address: "123 Test St", + apt: "A", + city: "Vancouver", + state: "WA", + zip: "98660", + country: "US" }, plan_base: { - type: 'monthly', + type: "monthly", hosts: 10 } } } let(:args) { url_args.merge(required_args) } - describe '#billing_plans_subscribe action' do - context 'with a valid response' do + describe "#billing_plans_subscribe action" do + context "with a valid response" do before :each do stub_request( :post, zoom_url("/accounts/#{args[:account_id]}/plans") - ).to_return(body: json_response('billing', 'plans_subscribe'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("billing", "plans_subscribe"), + headers: {"Content-Type" => "application/json"}) end - it 'makes the request' do + it "makes the request" do zc.billing_plans_subscribe(args) expect(WebMock).to have_requested(:post, zoom_url("/accounts/#{args[:account_id]}/plans")).with(body: required_args.to_json, headers: request_headers) end - it 'returns a hash' do + it "returns a hash" do expect(zc.billing_plans_subscribe(args)).to be_kind_of(Hash) end - it 'raises an error when missing a required param' do + it "raises an error when missing a required param" do expect { zc.billing_plans_subscribe(required_args) }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :post, zoom_url("/accounts/#{args[:account_id]}/plans") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.billing_plans_subscribe(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/billing/plans_usage_spec.rb b/spec/lib/zoom/actions/billing/plans_usage_spec.rb index 423fa2b6..4b84213a 100644 --- a/spec/lib/zoom/actions/billing/plans_usage_spec.rb +++ b/spec/lib/zoom/actions/billing/plans_usage_spec.rb @@ -1,46 +1,46 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Billing do let(:zc) { zoom_client } - let(:args) { { account_id: '1' } } + let(:args) { {account_id: "1"} } - describe '#billing_plans_usage action' do - context 'with a valid response' do + describe "#billing_plans_usage action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/plans/usage") - ).to_return(body: json_response('billing', 'plans_usage'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("billing", "plans_usage"), + headers: {"Content-Type" => "application/json"}) end - it 'makes the request' do + it "makes the request" do zc.billing_plans_usage(args) expect(WebMock).to have_requested(:get, zoom_url("/accounts/#{args[:account_id]}/plans/usage")).with(headers: request_headers) end - it 'returns a hash' do + it "returns a hash" do expect(zc.billing_plans_usage(args)).to be_kind_of(Hash) end - it 'raises an error when missing a required param' do + it "raises an error when missing a required param" do expect { zc.billing_plans_usage }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/plans/usage") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.billing_plans_usage(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/billing/update_spec.rb b/spec/lib/zoom/actions/billing/update_spec.rb index 7183b636..07a4b013 100644 --- a/spec/lib/zoom/actions/billing/update_spec.rb +++ b/spec/lib/zoom/actions/billing/update_spec.rb @@ -1,62 +1,62 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Billing do let(:zc) { zoom_client } - let(:required_args) { { account_id: '1' } } + let(:required_args) { {account_id: "1"} } let(:permitted_args) { { - first_name: 'Foo', - last_name: 'Bar', - email: 'foo@bar.com', - phone_number: '1234567890', - address: '123 Test Street', - apt: '', - city: 'Vancouver', - state: 'WA', - zip: '98660', - country: 'US' + first_name: "Foo", + last_name: "Bar", + email: "foo@bar.com", + phone_number: "1234567890", + address: "123 Test Street", + apt: "", + city: "Vancouver", + state: "WA", + zip: "98660", + country: "US" } } let(:args) { required_args.merge(permitted_args) } - describe '#billing_update action' do - context 'with a valid response' do + describe "#billing_update action" do + context "with a valid response" do before :each do stub_request( :patch, zoom_url("/accounts/#{args[:account_id]}/billing") - ).to_return(status: 204, - body: json_response('billing', 'update'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(status: 204, + body: json_response("billing", "update"), + headers: {"Content-Type" => "application/json"}) end - it 'makes the request' do + it "makes the request" do zc.billing_update(args) expect(WebMock).to have_requested(:patch, zoom_url("/accounts/#{args[:account_id]}/billing")).with(body: permitted_args.to_json, headers: request_headers) end - it 'requires id param' do + it "requires id param" do expect { zc.billing_update }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end - it 'returns a success response' do + it "returns a success response" do expect(zc.billing_update(args)).to eql(204) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :patch, zoom_url("/accounts/#{args[:account_id]}/billing") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.billing_update(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/dashboard/crc_spec.rb b/spec/lib/zoom/actions/dashboard/crc_spec.rb index 4c5b1295..6e55af2d 100644 --- a/spec/lib/zoom/actions/dashboard/crc_spec.rb +++ b/spec/lib/zoom/actions/dashboard/crc_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Dashboard do let(:zc) { zoom_client } - let(:args) { { from: '2013-04-05T15:50:47Z', to: '2013-04-09T19:00:00Z' } } + let(:args) { {from: "2013-04-05T15:50:47Z", to: "2013-04-09T19:00:00Z"} } let(:response) { zc.dashboard_crc(args) } - describe '#dashboard_crc get' do + describe "#dashboard_crc get" do before :each do stub_request( :get, - zoom_url('/metrics/crc') + zoom_url("/metrics/crc") ).to_return(status: 200, - body: json_response('dashboard','crc'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("dashboard", "crc"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'from' argument" do @@ -25,9 +25,8 @@ expect { zc.dashboard_crc(filter_key(args, :to)) }.to raise_error(Zoom::ParameterMissing) end - it 'returns a hash' do + it "returns a hash" do expect(response).to be_kind_of(Hash) end end - end diff --git a/spec/lib/zoom/actions/dashboard/meeting_details_spec.rb b/spec/lib/zoom/actions/dashboard/meeting_details_spec.rb index aba84625..9b094afe 100644 --- a/spec/lib/zoom/actions/dashboard/meeting_details_spec.rb +++ b/spec/lib/zoom/actions/dashboard/meeting_details_spec.rb @@ -1,62 +1,60 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Dashboard do - let(:zc) { zoom_client } - let(:args) { { meeting_id: 't13b6hjVQXybvGKyeHC96w==', type: 1 } } + let(:args) { {meeting_id: "t13b6hjVQXybvGKyeHC96w==", type: 1} } let(:response) { zc.dashboard_meeting_details(args) } - describe '#dashboard_meeting_details action' do - context 'with 200 response' do + describe "#dashboard_meeting_details action" do + context "with 200 response" do before :each do stub_request( :get, zoom_url("/metrics/meetings/#{args[:meeting_id]}") ).to_return(status: 200, - body: json_response('dashboard','meeting', 'detail'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("dashboard", "meeting", "detail"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'meeting_id' argument" do expect { zc.dashboard_meeting_details(filter_key(args, :meeting_id)) }.to raise_error(Zoom::ParameterMissing) end - it 'returns a hash' do + it "returns a hash" do expect(response).to be_kind_of(Hash) end end - context 'with 300 response' do + context "with 300 response" do before :each do stub_request( :get, zoom_url("/metrics/meetings/#{args[:meeting_id]}") ).to_return(status: 300, - body: '{ "code": 1001, "message": "The next page token is invalid or expired." }', - headers: { 'Content-Type' => 'application/json' }) + body: '{ "code": 1001, "message": "The next page token is invalid or expired." }', + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { response }.to raise_error(Zoom::Error) end end - context 'with 404 response' do + context "with 404 response" do before :each do stub_request( :get, zoom_url("/metrics/meetings/#{args[:meeting_id]}") ).to_return(status: 404, - body: '{ "code": 3001, "message": "Meeting ID is invalid or the meeting has not ended yet. This meeting’s details are not available." }', - headers: { 'Content-Type' => 'application/json' }) + body: '{ "code": 3001, "message": "Meeting ID is invalid or the meeting has not ended yet. This meeting’s details are not available." }', + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { response }.to raise_error(Zoom::Error) end end end - end diff --git a/spec/lib/zoom/actions/dashboard/meeting_participants_spec.rb b/spec/lib/zoom/actions/dashboard/meeting_participants_spec.rb index 7c47e7fa..3079bad1 100644 --- a/spec/lib/zoom/actions/dashboard/meeting_participants_spec.rb +++ b/spec/lib/zoom/actions/dashboard/meeting_participants_spec.rb @@ -1,74 +1,72 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Dashboard do - let(:zc) { zoom_client } - let(:args) { { meeting_id: 't13b6hjVQXybvGKyeHC96w==', type: 1 } } + let(:args) { {meeting_id: "t13b6hjVQXybvGKyeHC96w==", type: 1} } let(:response) { zc.dashboard_meeting_participants(args) } - describe '#dashboard_meeting_participants action' do - context 'with 200 response' do + describe "#dashboard_meeting_participants action" do + context "with 200 response" do before :each do stub_request( :get, zoom_url("/metrics/meetings/#{args[:meeting_id]}/participants") ).to_return(status: 200, - body: json_response('dashboard','meeting', 'participants'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("dashboard", "meeting", "participants"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'meeting_id' argument" do expect { zc.dashboard_meeting_participants(filter_key(args, :meeting_id)) }.to raise_error(Zoom::ParameterMissing) end - it 'returns a hash' do + it "returns a hash" do expect(response).to be_kind_of(Hash) end it "returns 'next_page_token'" do - expect(response['next_page_token']).to be_kind_of(String) + expect(response["next_page_token"]).to be_kind_of(String) end it "returns 'total_records'" do - expect(response['total_records']).to eq(2) + expect(response["total_records"]).to eq(2) end it "returns 'participants' Array" do - expect(response['participants']).to be_kind_of(Array) + expect(response["participants"]).to be_kind_of(Array) end end - context 'with 300 response' do + context "with 300 response" do before :each do stub_request( :get, zoom_url("/metrics/meetings/#{args[:meeting_id]}/participants") ).to_return(status: 300, - body: '{ "code": 1001, "message": "Can not access webinar info. {meetingId} or the next page token is either invalid or expired." }', - headers: { 'Content-Type' => 'application/json' }) + body: '{ "code": 1001, "message": "Can not access webinar info. {meetingId} or the next page token is either invalid or expired." }', + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { response }.to raise_error(Zoom::Error) end end - context 'with 404 response' do + context "with 404 response" do before :each do stub_request( :get, zoom_url("/metrics/meetings/#{args[:meeting_id]}/participants") ).to_return(status: 404, - body: '{ "code": 3001, "message": "Meeting ID is invalid or not ended yet." }', - headers: { 'Content-Type' => 'application/json' }) + body: '{ "code": 3001, "message": "Meeting ID is invalid or not ended yet." }', + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { response }.to raise_error(Zoom::Error) end end end - end diff --git a/spec/lib/zoom/actions/dashboard/meetings_spec.rb b/spec/lib/zoom/actions/dashboard/meetings_spec.rb index 676ba1f4..b3c009c0 100644 --- a/spec/lib/zoom/actions/dashboard/meetings_spec.rb +++ b/spec/lib/zoom/actions/dashboard/meetings_spec.rb @@ -1,21 +1,21 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Dashboard do let(:zc) { zoom_client } - let(:args) { { type: 1, from: '2013-04-05T15:50:47Z', to: '2013-04-09T19:00:00Z' } } + let(:args) { {type: 1, from: "2013-04-05T15:50:47Z", to: "2013-04-09T19:00:00Z"} } let(:response) { zc.dashboard_meetings(args) } - describe '#dashboard_meetings action' do - context 'with 200 response' do + describe "#dashboard_meetings action" do + context "with 200 response" do before :each do stub_request( :get, - zoom_url('/metrics/meetings') + zoom_url("/metrics/meetings") ).to_return(status: 200, - body: json_response('dashboard','meetings'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("dashboard", "meetings"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'from' argument" do @@ -26,38 +26,36 @@ expect { zc.dashboard_meetings(filter_key(args, :to)) }.to raise_error(Zoom::ParameterMissing) end - it 'returns a hash' do + it "returns a hash" do expect(zc.dashboard_meetings(args)).to be_kind_of(Hash) end it "returns 'next_page_token'" do - expect(response['next_page_token']).to be_kind_of(String) + expect(response["next_page_token"]).to be_kind_of(String) end it "returns 'total_records'" do - expect(response['total_records']).to eq(1) + expect(response["total_records"]).to eq(1) end it "returns 'meetings' Array" do - expect(response['meetings']).to be_kind_of(Array) + expect(response["meetings"]).to be_kind_of(Array) end end - context 'with 300 response' do + context "with 300 response" do before :each do stub_request( :get, - zoom_url('/metrics/meetings') + zoom_url("/metrics/meetings") ).to_return(status: 300, - body: '{ "code": 300, "message": "Can not access webinar info, {meetingId}" }', - headers: { 'Content-Type' => 'application/json' }) + body: '{ "code": 300, "message": "Can not access webinar info, {meetingId}" }', + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { response }.to raise_error(Zoom::Error) end end - end - end diff --git a/spec/lib/zoom/actions/groups/create_spec.rb b/spec/lib/zoom/actions/groups/create_spec.rb index df7a1e04..15db585d 100644 --- a/spec/lib/zoom/actions/groups/create_spec.rb +++ b/spec/lib/zoom/actions/groups/create_spec.rb @@ -1,98 +1,98 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Groups do let(:zc) { zoom_client } - let(:args) { { name: 'Zoom Group Name' } } + let(:args) { {name: "Zoom Group Name"} } let(:response) { zc.group_create(args) } - describe '#group_create action' do - context 'with 201 response' do + describe "#group_create action" do + context "with 201 response" do before :each do stub_request( :post, zoom_url("/groups") ).to_return( status: 201, - body: json_response('groups','create'), - headers: { 'Content-Type' => 'application/json' } + body: json_response("groups", "create"), + headers: {"Content-Type" => "application/json"} ) end - it 'returns a hash' do + it "returns a hash" do expect(response).to be_kind_of(Hash) end - it 'returns the set params' do - expect(response['name']).to eq(args[:name]) + it "returns the set params" do + expect(response["name"]).to eq(args[:name]) end it "returns 'start_url' and 'join_url'" do - expect(response['name']).to_not be_nil + expect(response["name"]).to_not be_nil end end - context 'with 409 response' do + context "with 409 response" do before :each do stub_request( :post, zoom_url("/groups") ).to_return(status: 409, - body: '{ "code": 409, "message": "Group name Zoom Group Name is already in use." }', - headers: { 'Content-Type' => 'application/json' }) + body: '{ "code": 409, "message": "Group name Zoom Group Name is already in use." }', + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { response }.to raise_error(Zoom::Conflict) end end - context 'with 429 response' do + context "with 429 response" do before :each do stub_request( :post, zoom_url("/groups") ).to_return(status: 429, - 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." }', - headers: { 'Content-Type' => 'application/json' }) + 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." }', + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { response }.to raise_error(Zoom::TooManyRequests) end end - context 'with 300 response' do + context "with 300 response" do before :each do stub_request( :post, zoom_url("/groups") ).to_return(status: 300, - body: '{ "code": 300, "message": "Missing field: name." }', - headers: { 'Content-Type' => 'application/json' }) + body: '{ "code": 300, "message": "Missing field: name." }', + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { response }.to raise_error(Zoom::Error) end end - context 'with 404 response' do + context "with 404 response" do before :each do stub_request( :post, zoom_url("/groups") ).to_return( status: 404, - body: json_response('error', 'group_not_exist'), - headers: { 'Content-Type' => 'application/json' } + body: json_response("error", "group_not_exist"), + headers: {"Content-Type" => "application/json"} ) end - it 'raises an error' do + it "raises an error" do expect { response }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/groups/delete_spec.rb b/spec/lib/zoom/actions/groups/delete_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/groups/delete_spec.rb +++ b/spec/lib/zoom/actions/groups/delete_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/groups/edit_spec.rb b/spec/lib/zoom/actions/groups/edit_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/groups/edit_spec.rb +++ b/spec/lib/zoom/actions/groups/edit_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/groups/get_spec.rb b/spec/lib/zoom/actions/groups/get_spec.rb index 24b575cf..a8f60b3e 100644 --- a/spec/lib/zoom/actions/groups/get_spec.rb +++ b/spec/lib/zoom/actions/groups/get_spec.rb @@ -1,60 +1,60 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Groups do let(:zc) { zoom_client } - let(:args) { { group_id: 2 } } - let(:wrong_args) { { group_id: 999999 } } + let(:args) { {group_id: 2} } + let(:wrong_args) { {group_id: 999999} } - describe '#groups_get action' do - context 'with valid response' do + describe "#groups_get action" do + context "with valid response" do before :each do stub_request( :get, - zoom_url("/groups/#{args['group_id']}") - ).to_return(body: json_response('groups', 'get'), headers: { 'Content-Type' => 'application/json' }) + zoom_url("/groups/#{args["group_id"]}") + ).to_return(body: json_response("groups", "get"), headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.groups_get(args)).to be_kind_of(Hash) end it "return 'name' parameter" do - expect(zc.groups_get(args)['name']).not_to be_nil + expect(zc.groups_get(args)["name"]).not_to be_nil end end - context 'with a 404 response' do + context "with a 404 response" do before :each do stub_request( :get, - zoom_url("/groups/#{wrong_args['group_id']}") + zoom_url("/groups/#{wrong_args["group_id"]}") ).to_return(status: 404, - body: json_response('error', 'group_does_not_exist'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "group_does_not_exist"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception with text' do + it "raises Zoom::Error exception with text" do expect { zc.groups_get(wrong_args) }.to raise_error(Zoom::Error, { - base: 'A group with this 999999 does not exist.' + base: "A group with this 999999 does not exist." }.to_s) end end - context 'with a 400 response' do + context "with a 400 response" do before :each do stub_request( :get, - zoom_url("/groups/#{wrong_args['group_id']}") + zoom_url("/groups/#{wrong_args["group_id"]}") ).to_return(status: 400, - body: json_response('error', 'group_not_belong_to_account'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "group_not_belong_to_account"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception with text' do + it "raises Zoom::Error exception with text" do expect { zc.groups_get(wrong_args) }.to raise_error(Zoom::Error, { - base: 'Group does not belong to your account.' + base: "Group does not belong to your account." }.to_s) end end diff --git a/spec/lib/zoom/actions/groups/list_spec.rb b/spec/lib/zoom/actions/groups/list_spec.rb index 1fb0453e..1b38cd43 100644 --- a/spec/lib/zoom/actions/groups/list_spec.rb +++ b/spec/lib/zoom/actions/groups/list_spec.rb @@ -1,45 +1,45 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Groups do let(:zc) { zoom_client } - describe '#groups_list action' do - context 'with valid response' do + describe "#groups_list action" do + context "with valid response" do before :each do stub_request( :get, - zoom_url('/groups') - ).to_return(body: json_response('groups', 'list'), headers: { 'Content-Type' => 'application/json' }) + zoom_url("/groups") + ).to_return(body: json_response("groups", "list"), headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.groups_list).to be_kind_of(Hash) end it "returns 'total_records'" do - expect(zc.groups_list['total_records']).to eq(2) + expect(zc.groups_list["total_records"]).to eq(2) end it "returns 'groups' Array" do - expect(zc.groups_list['groups']).to be_kind_of(Array) + expect(zc.groups_list["groups"]).to be_kind_of(Array) end end - context 'with a 404 response' do + context "with a 404 response" do before :each do stub_request( :get, zoom_url("/groups") ).to_return(status: 404, - body: json_response('error', 'group_does_not_exist'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "group_does_not_exist"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception with text' do + it "raises Zoom::Error exception with text" do expect { zc.groups_list }.to raise_error(Zoom::Error, { - base: 'A group with this 999999 does not exist.' + base: "A group with this 999999 does not exist." }.to_s) end end diff --git a/spec/lib/zoom/actions/groups/member/add_spec.rb b/spec/lib/zoom/actions/groups/member/add_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/groups/member/add_spec.rb +++ b/spec/lib/zoom/actions/groups/member/add_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/groups/member/delete_spec.rb b/spec/lib/zoom/actions/groups/member/delete_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/groups/member/delete_spec.rb +++ b/spec/lib/zoom/actions/groups/member/delete_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/groups/member/list_spec.rb b/spec/lib/zoom/actions/groups/member/list_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/groups/member/list_spec.rb +++ b/spec/lib/zoom/actions/groups/member/list_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/groups/update_spec.rb b/spec/lib/zoom/actions/groups/update_spec.rb index d9538bed..e6ddf3f2 100644 --- a/spec/lib/zoom/actions/groups/update_spec.rb +++ b/spec/lib/zoom/actions/groups/update_spec.rb @@ -1,57 +1,57 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Groups do let(:zc) { zoom_client } - let(:args) { { group_id: '555' } } + let(:args) { {group_id: "555"} } - describe '#group_update' do - context 'with a valid response' do + describe "#group_update" do + context "with a valid response" do before :each do stub_request( :patch, zoom_url("/groups/#{args[:group_id]}") ).to_return(status: 204, - body: json_response('groups', 'update'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("groups", "update"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do + it "requires id param" do expect { zc.group_update(filter_key(args, :group_id)) }.to raise_error(Zoom::ParameterMissing, [:group_id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.group_update(args)).to eql(204) end end - context 'with a 404 response' do + context "with a 404 response" do before :each do stub_request( :patch, zoom_url("/groups/#{args[:group_id]}") ).to_return(status: 404, - body: '{ "code": 404, "message": "Group name Zoom Group Name is already in use." }', - headers: { 'Content-Type' => 'application/json' }) + body: '{ "code": 404, "message": "Group name Zoom Group Name is already in use." }', + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::NotFound' do + it "raises Zoom::NotFound" do expect { zc.group_update(args) }.to raise_error(Zoom::NotFound) end end - context 'with 409 response' do + context "with 409 response" do before :each do stub_request( :patch, zoom_url("/groups/#{args[:group_id]}") ).to_return(status: 409, - body: '{ "code": 409, "message": "Group name Zoom Group Name is already in use." }', - headers: { 'Content-Type' => 'application/json' }) + body: '{ "code": 409, "message": "Group name Zoom Group Name is already in use." }', + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Conflict' do + it "raises Zoom::Conflict" do expect { zc.group_update(args) }.to raise_error(Zoom::Conflict) end end diff --git a/spec/lib/zoom/actions/im/chat/channels/get_spec.rb b/spec/lib/zoom/actions/im/chat/channels/get_spec.rb index efce1ae4..9f3e1d1c 100644 --- a/spec/lib/zoom/actions/im/chat/channels/get_spec.rb +++ b/spec/lib/zoom/actions/im/chat/channels/get_spec.rb @@ -1,60 +1,60 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::IM::Chat do let(:zc) { zoom_client } - let(:args) { { channel_id: 999999999 } } - let(:missed_channel_args) { { channel_id: 1000000 } } + let(:args) { {channel_id: 999999999} } + let(:missed_channel_args) { {channel_id: 1000000} } let(:missed_channel_response) { zc.get_chat_channels(missed_channel_args) } - describe '#get_chat_channels action' do - context 'with a valid response' do + describe "#get_chat_channels action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/chat/channels/#{args[:channel_id]}") - ).to_return(body: json_response('chat', 'channels', 'get'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("chat", "channels", "get"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'channel_id' argument" do expect { zc.get_chat_channels }.to raise_error(Zoom::ParameterMissing, [:channel_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.get_chat_channels(args)).to be_kind_of(Hash) end end - context 'with a 400 response' do + context "with a 400 response" do before :each do stub_request( :get, zoom_url("/chat/channels/#{args[:channel_id]}") ).to_return(status: 400, - body: json_response('error', 'unauthorized_request'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "unauthorized_request"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.get_chat_channels(args) }.to raise_error(Zoom::BadRequest, { base: "Unauthorized request. You do not have permission to access this user’s channel information." }.to_s) end end - context 'with a 404 response' do + context "with a 404 response" do before :each do stub_request( :get, zoom_url("/chat/channels/#{missed_channel_args[:channel_id]}") ).to_return(status: 404, - body: json_response('error', 'channel_not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "channel_not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'returns a hash 404' do + it "returns a hash 404" do expect { zc.get_chat_channels(missed_channel_args) }.to raise_error(Zoom::Error, { base: "Channel does not exist: #{missed_channel_args[:channel_id]}" }.to_s) diff --git a/spec/lib/zoom/actions/im/chat/get_spec.rb b/spec/lib/zoom/actions/im/chat/get_spec.rb index 86575c3b..b780a245 100644 --- a/spec/lib/zoom/actions/im/chat/get_spec.rb +++ b/spec/lib/zoom/actions/im/chat/get_spec.rb @@ -1,21 +1,23 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" xdescribe Zoom::Actions::IM::Chat do let(:zc) { zoom_client } - let(:args) { { access_token: 'foobar', - session_id: '123456', - from: '2018-08-28', - to: '2018-08-29' } } + let(:args) { + {access_token: "foobar", + session_id: "123456", + from: "2018-08-28", + to: "2018-08-29"} + } let(:response) { zc.chat_get(args) } - xdescribe '#chat_get action' do + xdescribe "#chat_get action" do before :each do stub_request( :post, - zoom_url('/chat/get') - ).to_return(body: json_response('chat','get')) + zoom_url("/chat/get") + ).to_return(body: json_response("chat", "get")) end it "requires a 'access_token' argument" do @@ -34,30 +36,30 @@ expect { zc.chat_get(filter_key(args, :to)) }.to raise_error(ArgumentError) end - it 'returns a hash' do + it "returns a hash" do expect(response).to be_kind_of(Hash) end - it 'returns an Array of chat_messages' do - expect(response['chat_messages']).to be_kind_of(Array) + it "returns an Array of chat_messages" do + expect(response["chat_messages"]).to be_kind_of(Array) end - it 'returns the params' do - expect(response['session_id']).to eql(args[:session_id]) - expect(response['from']).to eql(args[:from]) - expect(response['to']).to eql(args[:to]) + it "returns the params" do + expect(response["session_id"]).to eql(args[:session_id]) + expect(response["from"]).to eql(args[:from]) + expect(response["to"]).to eql(args[:to]) end end - xdescribe '#chat_get! action' do + xdescribe "#chat_get! action" do before :each do stub_request( :post, - zoom_url('/chat/get') - ).to_return(body: json_response('error')) + zoom_url("/chat/get") + ).to_return(body: json_response("error")) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.chat_get!(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/im/chat/list_spec.rb b/spec/lib/zoom/actions/im/chat/list_spec.rb index e38f7868..0ce1e6da 100644 --- a/spec/lib/zoom/actions/im/chat/list_spec.rb +++ b/spec/lib/zoom/actions/im/chat/list_spec.rb @@ -1,20 +1,22 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" xdescribe Zoom::Actions::IM::Chat do let(:zc) { zoom_client } - let(:args) { { access_token: 'foobar', - from: '2018-08-28', - to: '2018-08-29' } } + let(:args) { + {access_token: "foobar", + from: "2018-08-28", + to: "2018-08-29"} + } let(:response) { zc.chat_list(args) } - xdescribe '#chat_list action' do + xdescribe "#chat_list action" do before :each do stub_request( :post, - zoom_url('/chat/list') - ).to_return(body: json_response('chat','list')) + zoom_url("/chat/list") + ).to_return(body: json_response("chat", "list")) end it "requires a 'access_token' argument" do @@ -29,29 +31,29 @@ expect { zc.chat_list(filter_key(args, :to)) }.to raise_error(ArgumentError) end - it 'returns a hash' do + it "returns a hash" do expect(response).to be_kind_of(Hash) end - it 'returns an Array of `chat_list`s' do - expect(response['chat_list']).to be_kind_of(Array) + it "returns an Array of `chat_list`s" do + expect(response["chat_list"]).to be_kind_of(Array) end - it 'returns the params' do - expect(response['from']).to eql(args[:from]) - expect(response['to']).to eql(args[:to]) + it "returns the params" do + expect(response["from"]).to eql(args[:from]) + expect(response["to"]).to eql(args[:to]) end end - xdescribe '#chat_list! action' do + xdescribe "#chat_list! action" do before :each do stub_request( :post, - zoom_url('/chat/list') - ).to_return(body: json_response('error')) + zoom_url("/chat/list") + ).to_return(body: json_response("error")) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.chat_list!(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/im/chat/users/channels/get_spec.rb b/spec/lib/zoom/actions/im/chat/users/channels/get_spec.rb index 3d0800da..55ee71b1 100644 --- a/spec/lib/zoom/actions/im/chat/users/channels/get_spec.rb +++ b/spec/lib/zoom/actions/im/chat/users/channels/get_spec.rb @@ -1,43 +1,43 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::IM::Chat do let(:zc) { zoom_client } - let(:args) { { user_id: 555 } } + let(:args) { {user_id: 555} } - describe '#get_chat_user_channels action' do - context 'with a valid response' do + describe "#get_chat_user_channels action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/chat/users/#{args[:user_id]}/channels") - ).to_return(body: json_response('chat', 'users', 'channels', 'list'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("chat", "users", "channels", "list"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'user_id' argument" do expect { zc.get_chat_user_channels }.to raise_error(Zoom::ParameterMissing, [:user_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.get_chat_user_channels(args)).to be_kind_of(Hash) end end - context 'with a 400 response' do + context "with a 400 response" do before :each do stub_request( :get, zoom_url("/chat/users/#{args[:user_id]}/channels") ).to_return(status: 400, - body: json_response('error', 'next_page_token_invalid'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "next_page_token_invalid"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception with text' do + it "raises Zoom::Error exception with text" do expect { zc.get_chat_user_channels(args) }.to raise_error(Zoom::Error, { - base: 'The next page token is either invalid or has expired.' + base: "The next page token is either invalid or has expired." }.to_s) end end diff --git a/spec/lib/zoom/actions/im/group/create_spec.rb b/spec/lib/zoom/actions/im/group/create_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/im/group/create_spec.rb +++ b/spec/lib/zoom/actions/im/group/create_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/im/group/delete_spec.rb b/spec/lib/zoom/actions/im/group/delete_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/im/group/delete_spec.rb +++ b/spec/lib/zoom/actions/im/group/delete_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/im/group/edit_spec.rb b/spec/lib/zoom/actions/im/group/edit_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/im/group/edit_spec.rb +++ b/spec/lib/zoom/actions/im/group/edit_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/im/group/get_spec.rb b/spec/lib/zoom/actions/im/group/get_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/im/group/get_spec.rb +++ b/spec/lib/zoom/actions/im/group/get_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/im/group/list_spec.rb b/spec/lib/zoom/actions/im/group/list_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/im/group/list_spec.rb +++ b/spec/lib/zoom/actions/im/group/list_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/im/group/member/add_spec.rb b/spec/lib/zoom/actions/im/group/member/add_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/im/group/member/add_spec.rb +++ b/spec/lib/zoom/actions/im/group/member/add_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/im/group/member/delete_spec.rb b/spec/lib/zoom/actions/im/group/member/delete_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/im/group/member/delete_spec.rb +++ b/spec/lib/zoom/actions/im/group/member/delete_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/im/group/member/list_spec.rb b/spec/lib/zoom/actions/im/group/member/list_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/im/group/member/list_spec.rb +++ b/spec/lib/zoom/actions/im/group/member/list_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/m323/device/create_spec.rb b/spec/lib/zoom/actions/m323/device/create_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/m323/device/create_spec.rb +++ b/spec/lib/zoom/actions/m323/device/create_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/m323/device/delete_spec.rb b/spec/lib/zoom/actions/m323/device/delete_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/m323/device/delete_spec.rb +++ b/spec/lib/zoom/actions/m323/device/delete_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/m323/device/list_spec.rb b/spec/lib/zoom/actions/m323/device/list_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/m323/device/list_spec.rb +++ b/spec/lib/zoom/actions/m323/device/list_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/m323/device/update_spec.rb b/spec/lib/zoom/actions/m323/device/update_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/m323/device/update_spec.rb +++ b/spec/lib/zoom/actions/m323/device/update_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/ma/account/billing_update_spec.rb b/spec/lib/zoom/actions/ma/account/billing_update_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/ma/account/billing_update_spec.rb +++ b/spec/lib/zoom/actions/ma/account/billing_update_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/ma/account/create_spec.rb b/spec/lib/zoom/actions/ma/account/create_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/ma/account/create_spec.rb +++ b/spec/lib/zoom/actions/ma/account/create_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/ma/account/delete_spec.rb b/spec/lib/zoom/actions/ma/account/delete_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/ma/account/delete_spec.rb +++ b/spec/lib/zoom/actions/ma/account/delete_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/ma/account/get_spec.rb b/spec/lib/zoom/actions/ma/account/get_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/ma/account/get_spec.rb +++ b/spec/lib/zoom/actions/ma/account/get_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/ma/account/list_spec.rb b/spec/lib/zoom/actions/ma/account/list_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/ma/account/list_spec.rb +++ b/spec/lib/zoom/actions/ma/account/list_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/ma/account/plan/subscribe_spec.rb b/spec/lib/zoom/actions/ma/account/plan/subscribe_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/ma/account/plan/subscribe_spec.rb +++ b/spec/lib/zoom/actions/ma/account/plan/subscribe_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/ma/account/plan/update_spec.rb b/spec/lib/zoom/actions/ma/account/plan/update_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/ma/account/plan/update_spec.rb +++ b/spec/lib/zoom/actions/ma/account/plan/update_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/meeting/add_registrant_spec.rb b/spec/lib/zoom/actions/meeting/add_registrant_spec.rb index 8f93bd86..5061e487 100644 --- a/spec/lib/zoom/actions/meeting/add_registrant_spec.rb +++ b/spec/lib/zoom/actions/meeting/add_registrant_spec.rb @@ -1,30 +1,30 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Meeting do let(:zc) { zoom_client } - let(:args) { { meeting_id: 1, email: 'foo@bar.com', first_name: 'Foo' } } - let(:join_url) { 'https://www.zoom.us/w/869275230' } + let(:args) { {meeting_id: 1, email: "foo@bar.com", first_name: "Foo"} } + let(:join_url) { "https://www.zoom.us/w/869275230" } - describe '#meeting_add_registrant action' do + describe "#meeting_add_registrant action" do before :each do stub_request( :post, zoom_url("/meetings/#{args[:meeting_id]}/registrants") - ).to_return(body: json_response('meeting', 'add_registrant'), headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("meeting", "add_registrant"), headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.meeting_add_registrant(args)).to be_kind_of(Hash) end it "returns the created user's unique registrant_id" do - expect(zc.meeting_add_registrant(args)['registrant_id']).to eql('555') + expect(zc.meeting_add_registrant(args)["registrant_id"]).to eql("555") end - it 'returns a join_url' do - expect(zc.meeting_add_registrant(args)['join_url']).to eql(join_url) + it "returns a join_url" do + expect(zc.meeting_add_registrant(args)["join_url"]).to eql(join_url) end end end diff --git a/spec/lib/zoom/actions/meeting/create_spec.rb b/spec/lib/zoom/actions/meeting/create_spec.rb index 92dee787..3f02f12b 100644 --- a/spec/lib/zoom/actions/meeting/create_spec.rb +++ b/spec/lib/zoom/actions/meeting/create_spec.rb @@ -1,22 +1,22 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Meeting do let(:zc) { zoom_client } - let(:args) { { topic: 'Zoom Meeting Topic', start_time: '2020-05-05T21:00:00Z', timezone: 'America/New_York', duration: 30, type: 2, user_id: 'r55v2FgSTVmDmVot18DX3A', template_id: 'template_id' } } + let(:args) { {topic: "Zoom Meeting Topic", start_time: "2020-05-05T21:00:00Z", timezone: "America/New_York", duration: 30, type: 2, user_id: "r55v2FgSTVmDmVot18DX3A", template_id: "template_id"} } let(:response) { zc.meeting_create(args) } - describe '#meeting_create action' do - context 'with 201 response' do + describe "#meeting_create action" do + context "with 201 response" do before :each do stub_request( :post, zoom_url("/users/#{args[:user_id]}/meetings") ).to_return( status: 201, - body: json_response('meeting','create'), - headers: { 'Content-Type' => 'application/json' } + body: json_response("meeting", "create"), + headers: {"Content-Type" => "application/json"} ) end @@ -26,36 +26,36 @@ }.to raise_error(Zoom::ParameterMissing, [:user_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(response).to be_kind_of(Hash) end - it 'returns the set params' do - expect(response['type']).to eq(args[:type]) - expect(response['topic']).to eq(args[:topic]) - expect(response['start_time']).to eq(args[:start_time]) - expect(response['duration']).to eq(args[:duration]) + it "returns the set params" do + expect(response["type"]).to eq(args[:type]) + expect(response["topic"]).to eq(args[:topic]) + expect(response["start_time"]).to eq(args[:start_time]) + expect(response["duration"]).to eq(args[:duration]) end it "returns 'start_url' and 'join_url'" do - expect(response['start_url']).to_not be_nil - expect(response['join_url']).to_not be_nil + expect(response["start_url"]).to_not be_nil + expect(response["join_url"]).to_not be_nil end end - context 'with 404 response' do + context "with 404 response" do before :each do stub_request( :post, zoom_url("/users/#{args[:user_id]}/meetings") ).to_return( status: 404, - body: json_response('error', 'user_not_exist'), - headers: { 'Content-Type' => 'application/json' } + body: json_response("error", "user_not_exist"), + headers: {"Content-Type" => "application/json"} ) end - it 'raises an error' do + it "raises an error" do expect { response }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/meeting/delete_spec.rb b/spec/lib/zoom/actions/meeting/delete_spec.rb index ae3a0291..216400ed 100644 --- a/spec/lib/zoom/actions/meeting/delete_spec.rb +++ b/spec/lib/zoom/actions/meeting/delete_spec.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Meeting do let(:zc) { zoom_client } - let(:args) { { meeting_id: '91538056781' } } + let(:args) { {meeting_id: "91538056781"} } - describe '#meeting_delete action' do + describe "#meeting_delete action" do before :each do stub_request( :delete, zoom_url("/meetings/#{args[:meeting_id]}") ).to_return( status: 204, - headers: { 'Content-Type': 'application/json' } + headers: {"Content-Type": "application/json"} ) end @@ -23,13 +23,13 @@ }.to raise_error(Zoom::ParameterMissing) end - it 'returns a status code' do + it "returns a status code" do expect(zc.meeting_delete(args)).to eq 204 end end - describe '#meeting_delete! action' do - it 'raises NoMethodError exception' do + describe "#meeting_delete! action" do + it "raises NoMethodError exception" do expect { zc.meeting_delete!(args) }.to raise_error(NoMethodError) diff --git a/spec/lib/zoom/actions/meeting/get_spec.rb b/spec/lib/zoom/actions/meeting/get_spec.rb index 6ac2183b..52ee3d9a 100644 --- a/spec/lib/zoom/actions/meeting/get_spec.rb +++ b/spec/lib/zoom/actions/meeting/get_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Meeting do let(:zc) { zoom_client } - let(:args) { { meeting_id: 91538056781 } } + let(:args) { {meeting_id: 91538056781} } - describe '#meeting_get action' do + describe "#meeting_get action" do before :each do stub_request( :get, zoom_url("/meetings/#{args[:meeting_id]}") ).to_return( status: 200, - body: json_response('meeting','get'), - headers: { 'Content-Type' => 'application/json' } + body: json_response("meeting", "get"), + headers: {"Content-Type" => "application/json"} ) end @@ -24,46 +24,46 @@ }.to raise_error(Zoom::ParameterMissing, [:meeting_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.meeting_get(args)).to be_kind_of(Hash) end - it 'returns id and attributes' do + it "returns id and attributes" do res = zc.meeting_get(args) - expect(res['id']).to eq(args[:meeting_id]) - expect(res['topic']).to eq('Zoom Meeting Topic') - expect(res['start_time']).to eq('2020-05-05T21:00:00Z') - expect(res['join_url']).to eq('https://company.zoom.us/j/91538056781') - expect(res['start_url']).to eq('https://company.zoom.us/s/91538056781?zak=eyJ6bV...') + expect(res["id"]).to eq(args[:meeting_id]) + expect(res["topic"]).to eq("Zoom Meeting Topic") + expect(res["start_time"]).to eq("2020-05-05T21:00:00Z") + expect(res["join_url"]).to eq("https://company.zoom.us/j/91538056781") + expect(res["start_url"]).to eq("https://company.zoom.us/s/91538056781?zak=eyJ6bV...") end end - describe '#meeting_get! action' do - it 'raises NoMethodError exception' do + describe "#meeting_get! action" do + it "raises NoMethodError exception" do expect { zc.meeting_get!(args) }.to raise_error(NoMethodError) end end - describe '#past_meeting_instances' do + describe "#past_meeting_instances" do before :each do stub_request( :get, zoom_url("/past_meetings/#{args[:meeting_id]}/instances") ).to_return( status: 200, - body: json_response('meeting','instances'){}, - headers: { 'Content-Type' => 'application/json' } + body: json_response("meeting", "instances") {}, + headers: {"Content-Type" => "application/json"} ) end - it 'returns meeting instances' do + it "returns meeting instances" do res = zc.past_meeting_instances(args) - expect(res['meetings'][0]['start_time']).to eq('2022-03-26T05:37:59Z') - expect(res['meetings'][0]['uuid']).to eq('Vg8IdgluR5WDeWIkpJlElQ==') + expect(res["meetings"][0]["start_time"]).to eq("2022-03-26T05:37:59Z") + expect(res["meetings"][0]["uuid"]).to eq("Vg8IdgluR5WDeWIkpJlElQ==") end end end diff --git a/spec/lib/zoom/actions/meeting/invitation_spec.rb b/spec/lib/zoom/actions/meeting/invitation_spec.rb index ddfe6a59..62febd2f 100644 --- a/spec/lib/zoom/actions/meeting/invitation_spec.rb +++ b/spec/lib/zoom/actions/meeting/invitation_spec.rb @@ -1,24 +1,24 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Meeting do subject(:meeting_invitation) { zoom_client.meeting_invitation(args) } - let(:args) { { meeting_id: 91538056781 } } + let(:args) { {meeting_id: 91538056781} } - describe '#meeting_invitation action' do + describe "#meeting_invitation action" do before do stub_request( :get, zoom_url("/meetings/#{args[:meeting_id]}/invitation") ).to_return( status: 200, - body: json_response('meeting', 'invitation'), - headers: { 'Content-Type' => 'application/json' } + body: json_response("meeting", "invitation"), + headers: {"Content-Type" => "application/json"} ) end - context 'without :meeting_id parameter provided' do + context "without :meeting_id parameter provided" do let(:args) { {} } it "requires a 'meeting_id' argument" do @@ -28,20 +28,20 @@ end end - context 'when meeting_id parameter provided' do + context "when meeting_id parameter provided" do let(:invitation) do - "Team Member is inviting you to a scheduled Zoom meeting.\r\n\r\n"\ - "Topic: Test meeting\r\nTime: Sep 17, 2020 03:49 PM Kiev\r\n\r\n"\ - "Join Zoom Meeting\r\nhttps://zoom.us/j/9451234446749?pwd=K3AwTGtdUVdqSnNVWnd6MaZxZnZEdz09\r\n\r\n"\ + "Team Member is inviting you to a scheduled Zoom meeting.\r\n\r\n" \ + "Topic: Test meeting\r\nTime: Sep 17, 2020 03:49 PM Kiev\r\n\r\n" \ + "Join Zoom Meeting\r\nhttps://zoom.us/j/9451234446749?pwd=K3AwTGtdUVdqSnNVWnd6MaZxZnZEdz09\r\n\r\n" \ "Meeting ID: 943 1234 6721\r\nPasscode: DgA4yb\r\n\r\n" end - it 'returns a hash' do + it "returns a hash" do expect(meeting_invitation).to be_kind_of(Hash) end - it 'returns id and attributes' do - expect(meeting_invitation['invitation']).to eq(invitation) + it "returns id and attributes" do + expect(meeting_invitation["invitation"]).to eq(invitation) end end end diff --git a/spec/lib/zoom/actions/meeting/list_spec.rb b/spec/lib/zoom/actions/meeting/list_spec.rb index 5e43381a..43fcb0b2 100644 --- a/spec/lib/zoom/actions/meeting/list_spec.rb +++ b/spec/lib/zoom/actions/meeting/list_spec.rb @@ -1,45 +1,45 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" xdescribe Zoom::Actions::Meeting do let(:zc) { zoom_client } - let(:args) { { host_id: 'ufR93M2pRyy8ePFN92dttq' } } + let(:args) { {host_id: "ufR93M2pRyy8ePFN92dttq"} } - xdescribe '#meeting_list action' do + xdescribe "#meeting_list action" do before :each do stub_request( :post, - zoom_url('/meeting/list') - ).to_return(body: json_response('meeting', 'list')) + zoom_url("/meeting/list") + ).to_return(body: json_response("meeting", "list")) end it "requires a 'host_id' argument" do expect { zc.meeting_list }.to raise_error(ArgumentError) end - it 'returns a hash' do + it "returns a hash" do expect(zc.meeting_list(args)).to be_kind_of(Hash) end it "returns 'total_records'" do - expect(zc.meeting_list(args)['total_records']).to eq(235) + expect(zc.meeting_list(args)["total_records"]).to eq(235) end it "returns 'meetings' Array" do - expect(zc.meeting_list(args)['meetings']).to be_kind_of(Array) + expect(zc.meeting_list(args)["meetings"]).to be_kind_of(Array) end end - xdescribe '#meeting_list! action' do + xdescribe "#meeting_list! action" do before :each do stub_request( :post, - zoom_url('/meeting/list') - ).to_return(body: json_response('error')) + zoom_url("/meeting/list") + ).to_return(body: json_response("error")) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.meeting_list!(args) }.to raise_error(Zoom::Error) diff --git a/spec/lib/zoom/actions/meeting/livestream_spec.rb b/spec/lib/zoom/actions/meeting/livestream_spec.rb index b3af601d..328d7d00 100644 --- a/spec/lib/zoom/actions/meeting/livestream_spec.rb +++ b/spec/lib/zoom/actions/meeting/livestream_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Meeting do let(:zc) { zoom_client } - let(:args) { { meeting_id: '3qn1231nd', stream_url: 'owuj2n323hdns', stream_key: 'w02KPjeena' } } + let(:args) { {meeting_id: "3qn1231nd", stream_url: "owuj2n323hdns", stream_key: "w02KPjeena"} } let(:response) { zc.livestream(args) } - describe '#livestream action' do - context 'with 204 response' do + describe "#livestream action" do + context "with 204 response" do before :each do stub_request( :patch, zoom_url("/meetings/#{args[:meeting_id]}/livestream") ).to_return(status: 204, - headers: { 'Content-Type' => 'application/json' }) + headers: {"Content-Type" => "application/json"}) end it "requires meeting_id param" do @@ -23,37 +23,37 @@ }.to raise_error(Zoom::ParameterMissing, [:meeting_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(response).to eq(204) end end - context 'with 300 response' do + context "with 300 response" do before :each do stub_request( :patch, zoom_url("/meetings/#{args[:meeting_id]}/livestream") ).to_return(status: 300, - body: json_response('meeting', 'live_stream', 'errors', 'missing_field'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("meeting", "live_stream", "errors", "missing_field"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { response }.to raise_error(Zoom::Error) end end - context 'with 404 response' do + context "with 404 response" do before :each do stub_request( :patch, zoom_url("/meetings/#{args[:meeting_id]}/livestream") ).to_return(status: 404, - body: json_response('meeting', 'live_stream', 'errors', 'meeting_not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("meeting", "live_stream", "errors", "meeting_not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { response }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/meeting/registrants/update_status_spec.rb b/spec/lib/zoom/actions/meeting/registrants/update_status_spec.rb index 3a5eef2c..2eda37ac 100644 --- a/spec/lib/zoom/actions/meeting/registrants/update_status_spec.rb +++ b/spec/lib/zoom/actions/meeting/registrants/update_status_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { meeting_id: 1, action: 'approve' } } + let(:args) { {meeting_id: 1, action: "approve"} } - describe '#webinar_registrants_status_update' do - context 'with a valid response' do + describe "#webinar_registrants_status_update" do + context "with a valid response" do before :each do stub_request( :put, @@ -24,17 +24,17 @@ end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :put, zoom_url("/meetings/#{args[:meeting_id]}/registrants/status") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.meeting_registrants_status_update(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/meeting/update_spec.rb b/spec/lib/zoom/actions/meeting/update_spec.rb index fec4ac25..77b1ca6a 100644 --- a/spec/lib/zoom/actions/meeting/update_spec.rb +++ b/spec/lib/zoom/actions/meeting/update_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Meeting do let(:zc) { zoom_client } - let(:args) { { meeting_id: 91538056781, topic: 'Updated Topic' } } + let(:args) { {meeting_id: 91538056781, topic: "Updated Topic"} } - describe '#meeting_update action' do - context 'with 204 response' do + describe "#meeting_update action" do + context "with 204 response" do before :each do stub_request( :patch, zoom_url("/meetings/#{args[:meeting_id]}") ).to_return( status: 204, - headers: { 'Content-Type' => 'application/json' } + headers: {"Content-Type" => "application/json"} ) end @@ -24,33 +24,33 @@ }.to raise_error(Zoom::ParameterMissing, [:meeting_id].to_s) end - it 'returns a status code' do + it "returns a status code" do expect(zc.meeting_update(args)).to eq 204 end end - context 'with 404 response' do + context "with 404 response" do before :each do stub_request( :patch, zoom_url("/meetings/invalid-meeting-id") ).to_return( status: 404, - body: json_response('error', 'meeting_not_exist'), - headers: { 'Content-Type' => 'application/json' } + body: json_response("error", "meeting_not_exist"), + headers: {"Content-Type" => "application/json"} ) end - it 'raises an error' do + it "raises an error" do expect { - zc.meeting_update(args.merge(meeting_id: 'invalid-meeting-id')) - }.to raise_error(Zoom::Error, { base: "Invalid meeting id." }.to_s) + zc.meeting_update(args.merge(meeting_id: "invalid-meeting-id")) + }.to raise_error(Zoom::Error, {base: "Invalid meeting id."}.to_s) end end end - describe '#meeting_update! action' do - it 'raises NoMethodError exception' do + describe "#meeting_update! action" do + it "raises NoMethodError exception" do expect { zc.meeting_update!(args) }.to raise_error(NoMethodError) diff --git a/spec/lib/zoom/actions/recording/file_delete_spec.rb b/spec/lib/zoom/actions/recording/file_delete_spec.rb index a3817c6d..41468962 100644 --- a/spec/lib/zoom/actions/recording/file_delete_spec.rb +++ b/spec/lib/zoom/actions/recording/file_delete_spec.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Recording do let(:zc) { zoom_client } - let(:args) { { recording_id: 'kEFomHcIRgqxZT8D086O6A', meeting_id: 933560800 } } + let(:args) { {recording_id: "kEFomHcIRgqxZT8D086O6A", meeting_id: 933560800} } - describe '#meeting_recording_file_delete action' do + describe "#meeting_recording_file_delete action" do before :each do stub_request( :delete, zoom_url("/meetings/#{args[:meeting_id]}/recordings/#{args[:recording_id]}") ).to_return( status: 204, - headers: { 'Content-Type' => 'application/json' } + headers: {"Content-Type" => "application/json"} ) end @@ -26,7 +26,7 @@ }.to raise_error(Zoom::ParameterMissing) end - it 'returns a status code' do + it "returns a status code" do expect(zc.meeting_recording_file_delete(args)).to eq 204 end end diff --git a/spec/lib/zoom/actions/recording/get_spec.rb b/spec/lib/zoom/actions/recording/get_spec.rb index 7906be5a..820b7263 100644 --- a/spec/lib/zoom/actions/recording/get_spec.rb +++ b/spec/lib/zoom/actions/recording/get_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Recording do let(:zc) { zoom_client } - let(:args) { { user_id: 'kEFomHcIRgqxZT8D086O6A', meeting_id: 933560800 } } + let(:args) { {user_id: "kEFomHcIRgqxZT8D086O6A", meeting_id: 933560800} } - describe '#meeting_recording_get action' do + describe "#meeting_recording_get action" do before :each do stub_request( :get, zoom_url("/meetings/#{args[:meeting_id]}/recordings") ).to_return( status: 200, - body: json_response('recording', 'get'), - headers: { 'Content-Type' => 'application/json' } + body: json_response("recording", "get"), + headers: {"Content-Type" => "application/json"} ) end @@ -24,27 +24,27 @@ }.to raise_error(Zoom::ParameterMissing) end - it 'returns a hash' do + it "returns a hash" do expect(zc.meeting_recording_get(args)).to be_kind_of(Hash) end - it 'returns id and attributes' do + it "returns id and attributes" do res = zc.meeting_recording_get(args) - expect(res['uuid']).to eq("ucc69C82Q5mTNyCRWE29Aw==") - expect(res['id']).to eq(args[:meeting_id]) - expect(res['host_id']).to eq('kEFomHcIRgqxZT8D086O6A') - expect(res['account_id']).to eq('NyEqCEoYSNOr4jLMHoO2tA') - expect(res['topic']).to eq('Meeting Topic Name') - expect(res['start_time']).to eq('2015-04-13T01:06:04Z') - expect(res['timezone']).to eq('UTC') - expect(res['duration']).to eq(1) - expect(res['total_size']).to eq(686496) - expect(res['recording_count']).to eq(3) + expect(res["uuid"]).to eq("ucc69C82Q5mTNyCRWE29Aw==") + expect(res["id"]).to eq(args[:meeting_id]) + expect(res["host_id"]).to eq("kEFomHcIRgqxZT8D086O6A") + expect(res["account_id"]).to eq("NyEqCEoYSNOr4jLMHoO2tA") + expect(res["topic"]).to eq("Meeting Topic Name") + expect(res["start_time"]).to eq("2015-04-13T01:06:04Z") + expect(res["timezone"]).to eq("UTC") + expect(res["duration"]).to eq(1) + expect(res["total_size"]).to eq(686496) + expect(res["recording_count"]).to eq(3) end it "returns 'recording_files' Array" do - expect(zc.meeting_recording_get(args)['recording_files']).to be_kind_of(Array) + expect(zc.meeting_recording_get(args)["recording_files"]).to be_kind_of(Array) end end end diff --git a/spec/lib/zoom/actions/recording/list_spec.rb b/spec/lib/zoom/actions/recording/list_spec.rb index 02eaaacf..bfb1d00d 100644 --- a/spec/lib/zoom/actions/recording/list_spec.rb +++ b/spec/lib/zoom/actions/recording/list_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Recording do let(:zc) { zoom_client } - let(:args) { { user_id: 'kEFomHcIRgqxZT8D086O6A' } } + let(:args) { {user_id: "kEFomHcIRgqxZT8D086O6A"} } - describe '#recording_list action' do + describe "#recording_list action" do before :each do stub_request( :get, zoom_url("/users/#{args[:user_id]}/recordings") ).to_return( status: 200, - body: json_response('recording', 'list'), - headers: { 'Content-Type' => 'application/json' } + body: json_response("recording", "list"), + headers: {"Content-Type" => "application/json"} ) end @@ -22,21 +22,21 @@ expect { zc.recording_list }.to raise_error(Zoom::ParameterMissing) end - it 'returns a hash' do + it "returns a hash" do expect(zc.recording_list(args)).to be_kind_of(Hash) end it "returns 'total_records'" do - expect(zc.recording_list(args)['total_records']).to eq(1) + expect(zc.recording_list(args)["total_records"]).to eq(1) end it "returns 'meetings' Array" do - expect(zc.recording_list(args)['meetings']).to be_kind_of(Array) + expect(zc.recording_list(args)["meetings"]).to be_kind_of(Array) end end - describe '#recording_list! action' do - it 'raises NoMethodError exception' do + describe "#recording_list! action" do + it "raises NoMethodError exception" do expect { zc.recording_list!(args) }.to raise_error(NoMethodError) diff --git a/spec/lib/zoom/actions/recording/settings/get_spec.rb b/spec/lib/zoom/actions/recording/settings/get_spec.rb index 2873d9fc..3e739b02 100644 --- a/spec/lib/zoom/actions/recording/settings/get_spec.rb +++ b/spec/lib/zoom/actions/recording/settings/get_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Recording do let(:zc) { zoom_client } - let(:args) { { meeting_id: 91538056781 } } + let(:args) { {meeting_id: 91538056781} } - describe '#meeting_recordings_settings_get action' do + describe "#meeting_recordings_settings_get action" do before :each do stub_request( :get, zoom_url("/meetings/#{args[:meeting_id]}/recordings/settings") ).to_return( status: 200, - body: json_response('recording', 'settings', 'get'), - headers: { 'Content-Type' => 'application/json' } + body: json_response("recording", "settings", "get"), + headers: {"Content-Type" => "application/json"} ) end @@ -24,19 +24,18 @@ }.to raise_error(Zoom::ParameterMissing) end - it 'returns a hash' do + it "returns a hash" do expect(zc.meeting_recording_settings_get(args)).to be_kind_of(Hash) end - it 'returns id and attributes' do + it "returns id and attributes" do res = zc.meeting_recording_settings_get(args) - expect(res['on_demand']).to eq(false) - expect(res['password']).to eq('') - expect(res['recording_authentication']).to eq(false) - expect(res['share_recording']).to eq('publicly') - expect(res['viewer_download']).to eq(false) + expect(res["on_demand"]).to eq(false) + expect(res["password"]).to eq("") + expect(res["recording_authentication"]).to eq(false) + expect(res["share_recording"]).to eq("publicly") + expect(res["viewer_download"]).to eq(false) end - end end diff --git a/spec/lib/zoom/actions/recording/settings/update_spec.rb b/spec/lib/zoom/actions/recording/settings/update_spec.rb index ea988508..2c87d095 100644 --- a/spec/lib/zoom/actions/recording/settings/update_spec.rb +++ b/spec/lib/zoom/actions/recording/settings/update_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Recording do let(:zc) { zoom_client } - let(:args) { { meeting_id: 91538056781, on_demand: false } } + let(:args) { {meeting_id: 91538056781, on_demand: false} } - describe '#meeting_recordings_settings_update action' do - context 'with 204 response' do + describe "#meeting_recordings_settings_update action" do + context "with 204 response" do before :each do stub_request( :patch, zoom_url("/meetings/#{args[:meeting_id]}/recordings/settings") ).to_return( status: 204, - headers: { 'Content-Type' => 'application/json' } + headers: {"Content-Type" => "application/json"} ) end @@ -24,7 +24,7 @@ }.to raise_error(Zoom::ParameterMissing, [:meeting_id].to_s) end - it 'returns a status code' do + it "returns a status code" do expect(zc.meeting_recording_settings_update(args)).to eq 204 end end diff --git a/spec/lib/zoom/actions/report/meeting_details_report_spec.rb b/spec/lib/zoom/actions/report/meeting_details_report_spec.rb index 6ab91007..7f4afa99 100644 --- a/spec/lib/zoom/actions/report/meeting_details_report_spec.rb +++ b/spec/lib/zoom/actions/report/meeting_details_report_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Report do let(:zc) { zoom_client } - let(:args) { { id: '123456789' } } + let(:args) { {id: "123456789"} } - describe '#meeting_details_report' do - context 'with a valid response' do + describe "#meeting_details_report" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/report/meetings/#{args[:id]}") ).to_return(status: 200, - body: json_response('report', 'meeting'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("report", "meeting"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'id' argument" do expect { zc.meeting_details_report(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end - it 'returns an array of participants' do + it "returns an array of participants" do expect(zc.meeting_details_report(args)).to be_kind_of(Hash) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/report/meetings/#{args[:id]}") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.meeting_details_report(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/report/meeting_participants_report_spec.rb b/spec/lib/zoom/actions/report/meeting_participants_report_spec.rb index b4b4dd40..fa8ffdff 100644 --- a/spec/lib/zoom/actions/report/meeting_participants_report_spec.rb +++ b/spec/lib/zoom/actions/report/meeting_participants_report_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Report do let(:zc) { zoom_client } - let(:args) { { id: '123456789' } } + let(:args) { {id: "123456789"} } - describe '#meeting_participants_report' do - context 'with a valid response' do + describe "#meeting_participants_report" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/report/meetings/#{args[:id]}/participants") ).to_return(status: 200, - body: json_response('report', 'meeting', 'participants'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("report", "meeting", "participants"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'id' argument" do expect { zc.meeting_participants_report(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end - it 'returns an array of participants' do - expect(zc.meeting_participants_report(args)['participants']).to be_kind_of(Array) + it "returns an array of participants" do + expect(zc.meeting_participants_report(args)["participants"]).to be_kind_of(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/report/meetings/#{args[:id]}/participants") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.meeting_participants_report(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/report/webinar_participants_report_spec.rb b/spec/lib/zoom/actions/report/webinar_participants_report_spec.rb index 10a381ea..d38d90cf 100644 --- a/spec/lib/zoom/actions/report/webinar_participants_report_spec.rb +++ b/spec/lib/zoom/actions/report/webinar_participants_report_spec.rb @@ -1,44 +1,44 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Report do let(:zc) { zoom_client } - let(:args) { { id: '123456789' } } + let(:args) { {id: "123456789"} } - describe '#webinar_participants_report' do - context 'with a valid response' do + describe "#webinar_participants_report" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/report/webinars/#{args[:id]}/participants") ).to_return(status: 200, - body: json_response('report', 'webinar', 'participants'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("report", "webinar", "participants"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'id' argument" do expect { zc.webinar_participants_report(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end - it 'returns an array of participants' do - expect(zc.webinar_participants_report(args)['participants']).to be_kind_of(Array) + it "returns an array of participants" do + expect(zc.webinar_participants_report(args)["participants"]).to be_kind_of(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/report/webinars/#{args[:id]}/participants") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.webinar_participants_report(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/roles/assign_spec.rb b/spec/lib/zoom/actions/roles/assign_spec.rb index cae0efaa..ee0c3e66 100644 --- a/spec/lib/zoom/actions/roles/assign_spec.rb +++ b/spec/lib/zoom/actions/roles/assign_spec.rb @@ -1,25 +1,25 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Roles do let(:zc) { zoom_client } - let(:args) { { role_id: "RHLWWwtVZRnuq7OctVApqlg", members: [ { id: "sdkjsfdffds" }, { id: "dsfdsgrdgt" } ] } } + let(:args) { {role_id: "RHLWWwtVZRnuq7OctVApqlg", members: [{id: "sdkjsfdffds"}, {id: "dsfdsgrdgt"}]} } - describe '#roles_assign action' do + describe "#roles_assign action" do before :each do stub_request( :post, - zoom_url('/roles/RHLWWwtVZRnuq7OctVApqlg/members') - ).to_return(body: json_response('roles', 'assign'), headers: { 'Content-Type' => 'application/json' }) + zoom_url("/roles/RHLWWwtVZRnuq7OctVApqlg/members") + ).to_return(body: json_response("roles", "assign"), headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.roles_assign(args)).to be_kind_of(Hash) end it "returns 'ids' Array" do - expect(zc.roles_assign(args)['ids']).to be_kind_of(Array) + expect(zc.roles_assign(args)["ids"]).to be_kind_of(Array) end end end diff --git a/spec/lib/zoom/actions/roles/create_spec.rb b/spec/lib/zoom/actions/roles/create_spec.rb index 9b42f55d..7f0d89d1 100644 --- a/spec/lib/zoom/actions/roles/create_spec.rb +++ b/spec/lib/zoom/actions/roles/create_spec.rb @@ -1,27 +1,29 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Roles do let(:zc) { zoom_client } - let(:args) { { - name: 'Group Administrator', - description: 'A person with this role can view and manage groups.', - privileges: [ - "User:Read", - ] - } } + let(:args) { + { + name: "Group Administrator", + description: "A person with this role can view and manage groups.", + privileges: [ + "User:Read" + ] + } + } let(:response) { zc.roles_create(args) } - describe '#roles_create action' do - context 'with 201 response' do + describe "#roles_create action" do + context "with 201 response" do before :each do stub_request( :post, zoom_url("/roles") ).to_return(status: 201, - body: json_response('roles','create'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("roles", "create"), + headers: {"Content-Type" => "application/json"}) end it "requires name param" do @@ -36,19 +38,19 @@ }.not_to raise_error end - it 'returns a hash' do + it "returns a hash" do expect(response).to be_kind_of(Hash) end - it 'returns the set params' do - expect(response['name']).to eq(args[:name]) - expect(response['description']).to eq(args[:description]) - expect(response['privileges']).to eq(args[:privileges]) + it "returns the set params" do + expect(response["name"]).to eq(args[:name]) + expect(response["description"]).to eq(args[:description]) + expect(response["privileges"]).to eq(args[:privileges]) end it "returns 'total_members' and 'id'" do - expect(response['id']).to_not be_nil - expect(response['total_members']).to_not be_nil + expect(response["id"]).to_not be_nil + expect(response["total_members"]).to_not be_nil end end end diff --git a/spec/lib/zoom/actions/roles/get_spec.rb b/spec/lib/zoom/actions/roles/get_spec.rb index 4e57f3f2..c130540f 100644 --- a/spec/lib/zoom/actions/roles/get_spec.rb +++ b/spec/lib/zoom/actions/roles/get_spec.rb @@ -1,37 +1,37 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Roles do let(:zc) { zoom_client } - let(:args) { { role_id: 2 } } + let(:args) { {role_id: 2} } - describe '#roles_get action' do + describe "#roles_get action" do before :each do stub_request( :get, - zoom_url('/roles/2') - ).to_return(body: json_response('roles', 'get'), headers: { 'Content-Type' => 'application/json' }) + zoom_url("/roles/2") + ).to_return(body: json_response("roles", "get"), headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.roles_get(args)).to be_kind_of(Hash) end it "return 'name' parameter" do - expect(zc.roles_get(args)['name']).not_to be_nil + expect(zc.roles_get(args)["name"]).not_to be_nil end it "return 'description' parameter" do - expect(zc.roles_get(args)['description']).not_to be_nil + expect(zc.roles_get(args)["description"]).not_to be_nil end it "return 'total_members' parameter" do - expect(zc.roles_get(args)['total_members']).to eq(2) + expect(zc.roles_get(args)["total_members"]).to eq(2) end it "returns 'privileges' Array" do - expect(zc.roles_get(args)['privileges']).to be_kind_of(Array) + expect(zc.roles_get(args)["privileges"]).to be_kind_of(Array) end end end diff --git a/spec/lib/zoom/actions/roles/list_spec.rb b/spec/lib/zoom/actions/roles/list_spec.rb index 7f3cda5c..d6d93ae7 100644 --- a/spec/lib/zoom/actions/roles/list_spec.rb +++ b/spec/lib/zoom/actions/roles/list_spec.rb @@ -1,28 +1,28 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Roles do let(:zc) { zoom_client } - describe '#roles_list action' do + describe "#roles_list action" do before :each do stub_request( :get, - zoom_url('/roles') - ).to_return(body: json_response('roles', 'list'), headers: { 'Content-Type' => 'application/json' }) + zoom_url("/roles") + ).to_return(body: json_response("roles", "list"), headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.roles_list).to be_kind_of(Hash) end it "returns 'total_records'" do - expect(zc.roles_list['total_records']).to eq(4) + expect(zc.roles_list["total_records"]).to eq(4) end it "returns 'roles' Array" do - expect(zc.roles_list['roles']).to be_kind_of(Array) + expect(zc.roles_list["roles"]).to be_kind_of(Array) end end end diff --git a/spec/lib/zoom/actions/roles/members_spec.rb b/spec/lib/zoom/actions/roles/members_spec.rb index e2a4d780..287daedf 100644 --- a/spec/lib/zoom/actions/roles/members_spec.rb +++ b/spec/lib/zoom/actions/roles/members_spec.rb @@ -1,35 +1,35 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Roles do let(:zc) { zoom_client } - let(:args) { { role_id: 2 } } + let(:args) { {role_id: 2} } - describe '#roles_members action' do + describe "#roles_members action" do before :each do stub_request( :get, - zoom_url('/roles/2/members') - ).to_return(body: json_response('roles', 'members'), headers: { 'Content-Type' => 'application/json' }) + zoom_url("/roles/2/members") + ).to_return(body: json_response("roles", "members"), headers: {"Content-Type" => "application/json"}) end - it 'requires role_id param' do + it "requires role_id param" do expect { zc.roles_members(filter_key(args, :role_id)) }.to raise_error(Zoom::ParameterMissing, [:role_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.roles_members(args)).to be_kind_of(Hash) end it "returns 'total_records'" do - expect(zc.roles_members(args)['total_records']).to eq(1) + expect(zc.roles_members(args)["total_records"]).to eq(1) end it "returns 'roles' Array" do - expect(zc.roles_members(args)['members']).to be_kind_of(Array) + expect(zc.roles_members(args)["members"]).to be_kind_of(Array) end end end diff --git a/spec/lib/zoom/actions/roles/unassign_spec.rb b/spec/lib/zoom/actions/roles/unassign_spec.rb index f0c829ca..760e13c0 100644 --- a/spec/lib/zoom/actions/roles/unassign_spec.rb +++ b/spec/lib/zoom/actions/roles/unassign_spec.rb @@ -1,33 +1,32 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Roles do let(:zc) { zoom_client } - let(:args) { { role_id: "RMWJ20fcKS8Wsgp_Tu4todg", member_id: "x-chC53ZRJ6_fO29-a5WrA" } } + let(:args) { {role_id: "RMWJ20fcKS8Wsgp_Tu4todg", member_id: "x-chC53ZRJ6_fO29-a5WrA"} } - describe '#roles_unassign action' do + describe "#roles_unassign action" do before :each do stub_request( :delete, - zoom_url('/roles/RMWJ20fcKS8Wsgp_Tu4todg/members/x-chC53ZRJ6_fO29-a5WrA') + zoom_url("/roles/RMWJ20fcKS8Wsgp_Tu4todg/members/x-chC53ZRJ6_fO29-a5WrA") ).to_return(status: 204) end - it 'requires role_id param' do + it "requires role_id param" do expect { zc.roles_unassign(filter_key(args, :role_id)) }.to raise_error(Zoom::ParameterMissing, [:role_id].to_s) end - it 'requires member_id param' do + it "requires member_id param" do expect { zc.roles_unassign(filter_key(args, :member_id)) }.to raise_error(Zoom::ParameterMissing, [:member_id].to_s) end - - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.roles_unassign(args)).to eql(204) end end diff --git a/spec/lib/zoom/actions/sip_audio/add_trunks_internal_callout_countries_spec.rb b/spec/lib/zoom/actions/sip_audio/add_trunks_internal_callout_countries_spec.rb index 6df6e1a9..3b17dc10 100644 --- a/spec/lib/zoom/actions/sip_audio/add_trunks_internal_callout_countries_spec.rb +++ b/spec/lib/zoom/actions/sip_audio/add_trunks_internal_callout_countries_spec.rb @@ -1,25 +1,25 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::SipAudio do let(:zc) { zoom_client } - let(:args) { { account_id: '1' } } + let(:args) { {account_id: "1"} } - describe '#sip_trunks_internal_callout_countries_add action' do + describe "#sip_trunks_internal_callout_countries_add action" do before :each do stub_request( :post, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/callout_countries") - ).to_return(body: json_response('sip_audio', 'sip_trunks_internal_callout_countries_add'), headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("sip_audio", "sip_trunks_internal_callout_countries_add"), headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.sip_trunks_internal_callout_countries_add(args)).to be_kind_of(Hash) end - it 'raises an error when missing a required param' do + it "raises an error when missing a required param" do expect { zc.sip_trunks_internal_callout_countries_add }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/sip_audio/add_trunks_internal_numbers_spec.rb b/spec/lib/zoom/actions/sip_audio/add_trunks_internal_numbers_spec.rb index df7e5772..5a353850 100644 --- a/spec/lib/zoom/actions/sip_audio/add_trunks_internal_numbers_spec.rb +++ b/spec/lib/zoom/actions/sip_audio/add_trunks_internal_numbers_spec.rb @@ -1,25 +1,25 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::SipAudio do let(:zc) { zoom_client } - let(:args) { { account_id: '1' } } + let(:args) { {account_id: "1"} } - describe '#sip_trunks_internal_numbers_add action' do + describe "#sip_trunks_internal_numbers_add action" do before :each do stub_request( :post, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/internal_numbers") - ).to_return(body: json_response('sip_audio', 'sip_trunks_internal_numbers_add'), headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("sip_audio", "sip_trunks_internal_numbers_add"), headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.sip_trunks_internal_numbers_add(args)).to be_kind_of(Hash) end - it 'raises an error when missing a required param' do + it "raises an error when missing a required param" do expect { zc.sip_trunks_internal_numbers_add }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/sip_audio/assign_numbers_spec.rb b/spec/lib/zoom/actions/sip_audio/assign_numbers_spec.rb index 5f4e582a..d28d56ae 100644 --- a/spec/lib/zoom/actions/sip_audio/assign_numbers_spec.rb +++ b/spec/lib/zoom/actions/sip_audio/assign_numbers_spec.rb @@ -1,29 +1,29 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::SipAudio do let(:zc) { zoom_client } - let(:args) { { account_id: '1' } } + let(:args) { {account_id: "1"} } - describe '#sip_trunks_numbers_assign action' do + describe "#sip_trunks_numbers_assign action" do before :each do stub_request( :post, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/numbers") - ).to_return(body: json_response('sip_audio', 'sip_trunks_numbers_assign'), headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("sip_audio", "sip_trunks_numbers_assign"), headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.sip_trunks_numbers_assign(args)).to be_kind_of(Hash) end it "returns 'phone_numbers' Array" do - expect(zc.sip_trunks_numbers_assign(args)['phone_numbers']).to be_kind_of(Array) + expect(zc.sip_trunks_numbers_assign(args)["phone_numbers"]).to be_kind_of(Array) end - it 'raises an error when missing a required param' do + it "raises an error when missing a required param" do expect { zc.sip_trunks_numbers_assign }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/sip_audio/delete_internal_callout_countries_spec.rb b/spec/lib/zoom/actions/sip_audio/delete_internal_callout_countries_spec.rb index 78ff73c7..8eb222e4 100644 --- a/spec/lib/zoom/actions/sip_audio/delete_internal_callout_countries_spec.rb +++ b/spec/lib/zoom/actions/sip_audio/delete_internal_callout_countries_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::SipAudio do let(:zc) { zoom_client } - let(:args) { { account_id: 1, country_id: 1 } } + let(:args) { {account_id: 1, country_id: 1} } - describe '#sip_trunks_internal_callout_country_delete action' do - context 'with a valid response' do + describe "#sip_trunks_internal_callout_country_delete action" do + context "with a valid response" do before :each do stub_request( :delete, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/callout_countries/#{args[:country_id]}") ).to_return(status: 204, - body: nil, - headers: { 'Content-Type' => 'application/json' }) + body: nil, + headers: {"Content-Type" => "application/json"}) end - it 'requires the account_id params and country_id params' do - expect { zc.sip_trunks_internal_callout_country_delete }.to raise_error(Zoom::ParameterMissing, [:account_id, :country_id].to_s ) + it "requires the account_id params and country_id params" do + expect { zc.sip_trunks_internal_callout_country_delete }.to raise_error(Zoom::ParameterMissing, [:account_id, :country_id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.sip_trunks_internal_callout_country_delete(args)).to eql(204) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :delete, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/callout_countries/#{args[:country_id]}") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.sip_trunks_internal_callout_country_delete(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/sip_audio/delete_trunk_internal_numbers_spec.rb b/spec/lib/zoom/actions/sip_audio/delete_trunk_internal_numbers_spec.rb index 3c240210..0730da7a 100644 --- a/spec/lib/zoom/actions/sip_audio/delete_trunk_internal_numbers_spec.rb +++ b/spec/lib/zoom/actions/sip_audio/delete_trunk_internal_numbers_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::SipAudio do let(:zc) { zoom_client } - let(:args) { { account_id: 1, number_id: 1 } } + let(:args) { {account_id: 1, number_id: 1} } - describe '#sip_trunks_internal_numbers_delete action' do - context 'with a valid response' do + describe "#sip_trunks_internal_numbers_delete action" do + context "with a valid response" do before :each do stub_request( :delete, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/internal_numbers/#{args[:number_id]}") ).to_return(status: 204, - body: nil, - headers: { 'Content-Type' => 'application/json' }) + body: nil, + headers: {"Content-Type" => "application/json"}) end - it 'requires the account_id params and internal number params' do - expect { zc.sip_trunks_internal_numbers_delete }.to raise_error(Zoom::ParameterMissing, [:account_id, :number_id].to_s ) + it "requires the account_id params and internal number params" do + expect { zc.sip_trunks_internal_numbers_delete }.to raise_error(Zoom::ParameterMissing, [:account_id, :number_id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.sip_trunks_internal_numbers_delete(args)).to eql(204) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :delete, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/internal_numbers/#{args[:number_id]}") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.sip_trunks_internal_numbers_delete(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/sip_audio/delete_trunk_numbers_spec.rb b/spec/lib/zoom/actions/sip_audio/delete_trunk_numbers_spec.rb index 5383206e..f0129e33 100644 --- a/spec/lib/zoom/actions/sip_audio/delete_trunk_numbers_spec.rb +++ b/spec/lib/zoom/actions/sip_audio/delete_trunk_numbers_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::SipAudio do let(:zc) { zoom_client } - let(:args) { { account_id: 1 } } + let(:args) { {account_id: 1} } - describe '#sip_trunk_numbers_delete action' do - context 'with a valid response' do + describe "#sip_trunk_numbers_delete action" do + context "with a valid response" do before :each do stub_request( :delete, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/numbers") ).to_return(status: 204, - body: nil, - headers: { 'Content-Type' => 'application/json' }) + body: nil, + headers: {"Content-Type" => "application/json"}) end - it 'requires the account_id params' do + it "requires the account_id params" do expect { zc.sip_trunk_numbers_delete }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.sip_trunk_numbers_delete(args)).to eql(204) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :delete, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/numbers") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.sip_trunk_numbers_delete(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/sip_audio/delete_trunks_spec.rb b/spec/lib/zoom/actions/sip_audio/delete_trunks_spec.rb index 072006ef..c50bc8dc 100644 --- a/spec/lib/zoom/actions/sip_audio/delete_trunks_spec.rb +++ b/spec/lib/zoom/actions/sip_audio/delete_trunks_spec.rb @@ -1,44 +1,44 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::SipAudio do let(:zc) { zoom_client } - let(:args) { { account_id: 1, trunk_id: 1 } } + let(:args) { {account_id: 1, trunk_id: 1} } - describe '#sip_trunks_delete action' do - context 'with a valid response' do + describe "#sip_trunks_delete action" do + context "with a valid response" do before :each do stub_request( :delete, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/trunks/#{args[:trunk_id]}") ).to_return(status: 204, - body: nil, - headers: { 'Content-Type' => 'application/json' }) + body: nil, + headers: {"Content-Type" => "application/json"}) end - it 'requires the account_id params and trunk_id params' do - expect { zc.sip_trunks_delete }.to raise_error(Zoom::ParameterMissing, /[:account_id, :trunk_id]/ ) + it "requires the account_id params and trunk_id params" do + expect { zc.sip_trunks_delete }.to raise_error(Zoom::ParameterMissing, /[:acount_id, rk]/) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.sip_trunks_delete(args)).to eql(204) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :delete, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/trunks/#{args[:trunk_id]}") ).to_return(status: 400, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.sip_trunks_delete(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/sip_audio/get_trunks_spec.rb b/spec/lib/zoom/actions/sip_audio/get_trunks_spec.rb index 56837d2c..96547f45 100644 --- a/spec/lib/zoom/actions/sip_audio/get_trunks_spec.rb +++ b/spec/lib/zoom/actions/sip_audio/get_trunks_spec.rb @@ -1,48 +1,48 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::SipAudio do let(:zc) { zoom_client } - let(:args) { { account_id: '1' } } + let(:args) { {account_id: "1"} } - describe '#sip_trunks_get action' do - context 'with a valid response' do + describe "#sip_trunks_get action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/trunks") - ).to_return(status: 200, - body: json_response('sip_audio', 'sip_trunks_get'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(status: 200, + body: json_response("sip_audio", "sip_trunks_get"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do + it "requires id param" do expect { zc.sip_trunks_get }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.sip_trunks_get(args)).to be_kind_of(Hash) end - it 'returns same params' do + it "returns same params" do res = zc.sip_trunks_get(args) expect(res.keys).to match_array(%w[sip_trunks total_records]) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/trunks") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.sip_trunks_get(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/sip_audio/list_trunk_numbers_spec.rb b/spec/lib/zoom/actions/sip_audio/list_trunk_numbers_spec.rb index 726ebaf5..ebab23cd 100644 --- a/spec/lib/zoom/actions/sip_audio/list_trunk_numbers_spec.rb +++ b/spec/lib/zoom/actions/sip_audio/list_trunk_numbers_spec.rb @@ -1,46 +1,46 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::SipAudio do let(:zc) { zoom_client } - describe '#sip_trunks_numbers_list action' do - context 'with a valid response' do + describe "#sip_trunks_numbers_list action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/sip_trunk/numbers") - ).to_return(body: json_response('sip_audio', 'sip_trunks_numbers_list'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("sip_audio", "sip_trunks_numbers_list"), + headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.sip_trunks_numbers_list).to be_kind_of(Hash) end it "returns 'numbers' count" do - expect(zc.sip_trunks_numbers_list['phone_numbers'].count).to eq(1) + expect(zc.sip_trunks_numbers_list["phone_numbers"].count).to eq(1) end it "returns 'numbers' Array" do - expect(zc.sip_trunks_numbers_list['phone_numbers']).to be_kind_of(Array) + expect(zc.sip_trunks_numbers_list["phone_numbers"]).to be_kind_of(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/sip_trunk/numbers") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.sip_trunks_numbers_list }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/sip_audio/list_trunks_internal_callout_country_spec.rb b/spec/lib/zoom/actions/sip_audio/list_trunks_internal_callout_country_spec.rb index 58a0d7cb..919678bc 100644 --- a/spec/lib/zoom/actions/sip_audio/list_trunks_internal_callout_country_spec.rb +++ b/spec/lib/zoom/actions/sip_audio/list_trunks_internal_callout_country_spec.rb @@ -1,53 +1,53 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::SipAudio do let(:zc) { zoom_client } - let(:args) { { account_id: '1' } } + let(:args) { {account_id: "1"} } - describe '#sip_trunks_internal_callout_country_list action' do - context 'with a valid response' do + describe "#sip_trunks_internal_callout_country_list action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/callout_countries") - ).to_return(body: json_response('sip_audio', 'sip_trunks_internal_callout_country_list'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("sip_audio", "sip_trunks_internal_callout_country_list"), + headers: {"Content-Type" => "application/json"}) end it "requires account_id param" do expect { zc.sip_trunks_internal_callout_country_list(filter_key(args, :account_id)) - }.to raise_error(Zoom::ParameterMissing, /[:account_id]/) + }.to raise_error(Zoom::ParameterMissing, /[:acount_id]/) end - it 'returns a hash' do + it "returns a hash" do expect(zc.sip_trunks_internal_callout_country_list(args)).to be_kind_of(Hash) end it "returns 'internal_callout_countries' count" do - expect(zc.sip_trunks_internal_callout_country_list(args)['callout_countries'].count).to eq(2) + expect(zc.sip_trunks_internal_callout_country_list(args)["callout_countries"].count).to eq(2) end it "returns 'internal_callout_country' Array" do - expect(zc.sip_trunks_internal_callout_country_list(args)['callout_countries']).to be_kind_of(Array) + expect(zc.sip_trunks_internal_callout_country_list(args)["callout_countries"]).to be_kind_of(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/callout_countries") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.sip_trunks_internal_callout_country_list(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/sip_audio/list_trunks_internal_numbers_spec.rb b/spec/lib/zoom/actions/sip_audio/list_trunks_internal_numbers_spec.rb index 67b2595a..bb9e20a4 100644 --- a/spec/lib/zoom/actions/sip_audio/list_trunks_internal_numbers_spec.rb +++ b/spec/lib/zoom/actions/sip_audio/list_trunks_internal_numbers_spec.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::SipAudio do let(:zc) { zoom_client } - let(:args) { { account_id: '1' } } + let(:args) { {account_id: "1"} } - describe '#sip_trunks_internal_numbers_list action' do - context 'with a valid response' do + describe "#sip_trunks_internal_numbers_list action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/internal_numbers") - ).to_return(body: json_response('sip_audio', 'sip_trunks_internal_numbers_list'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("sip_audio", "sip_trunks_internal_numbers_list"), + headers: {"Content-Type" => "application/json"}) end it "requires account_id param" do @@ -22,32 +22,32 @@ }.to raise_error(Zoom::ParameterMissing, [:account_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.sip_trunks_internal_numbers_list(args)).to be_kind_of(Hash) end it "returns 'internal_numbers' count" do - expect(zc.sip_trunks_internal_numbers_list(args)['internal_numbers'].count).to eq(1) + expect(zc.sip_trunks_internal_numbers_list(args)["internal_numbers"].count).to eq(1) end it "returns 'internal_numbers' Array" do - expect(zc.sip_trunks_internal_numbers_list(args)['internal_numbers']).to be_kind_of(Array) + expect(zc.sip_trunks_internal_numbers_list(args)["internal_numbers"]).to be_kind_of(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/accounts/#{args[:account_id]}/sip_trunk/internal_numbers") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.sip_trunks_internal_numbers_list(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/token/access_token_spec.rb b/spec/lib/zoom/actions/token/access_token_spec.rb index 2c712d47..67402545 100644 --- a/spec/lib/zoom/actions/token/access_token_spec.rb +++ b/spec/lib/zoom/actions/token/access_token_spec.rb @@ -1,38 +1,33 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Token do let(:zc) { oauth_client } - let(:args) { { grant_type: 'authorization_code', auth_code: 'xxx', redirect_uri: 'http://localhost:3000', code_verifier: 'xxx' } } - let(:body) { { grant_type: 'authorization_code', redirect_uri: 'http://localhost:3000', code_verifier: 'xxx', code: 'xxx' } } + let(:args) { {grant_type: "authorization_code", auth_code: "xxx", redirect_uri: "http://localhost:3000", code_verifier: "xxx"} } + let(:body) { {grant_type: "authorization_code", redirect_uri: "http://localhost:3000", code_verifier: "xxx", code: "xxx"} } - describe '#access_tokens action' do - let(:path) { '/oauth/token' } + describe "#access_tokens action" do + let(:path) { "/oauth/token" } let(:params) do { - base_uri: 'https://zoom.us/', + base_uri: "https://zoom.us/", body: URI.encode_www_form(body.to_a), headers: { - 'Accept'=>'application/json', - 'Authorization'=>'Basic eHh4Onh4eA==', - 'Content-Type'=>'application/x-www-form-urlencoded' + "Accept" => "application/json", + "Authorization" => "Basic eHh4Onh4eA==", + "Content-Type" => "application/x-www-form-urlencoded" } } end before :each do - Zoom.configure do |config| - config.api_key = 'xxx' - config.api_secret = 'xxx' - end - allow(Zoom::Utils).to receive(:parse_response).and_return(code: 200) allow(Zoom::Client::OAuth).to( receive(:post).with(path, params) - .and_return(body: json_response('token', 'access_token'), - headers: { 'Content-Type' => 'application/json' }) + .and_return(body: json_response("token", "access_token"), + headers: {"Content-Type" => "application/json"}) ) end @@ -40,11 +35,11 @@ expect { zc.access_tokens }.to raise_error(Zoom::ParameterMissing, [:grant_type, :code, :redirect_uri].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.access_tokens(args)).to be_kind_of(Hash) end - it 'passes args in the body and sends x-www-form-urlencoded header' do + it "passes args in the body and sends x-www-form-urlencoded header" do zc.access_tokens(args) expect(Zoom::Client::OAuth).to have_received(:post).with(path, params) end diff --git a/spec/lib/zoom/actions/token/data_compliance_spec.rb b/spec/lib/zoom/actions/token/data_compliance_spec.rb index c29c35e4..ba60633f 100644 --- a/spec/lib/zoom/actions/token/data_compliance_spec.rb +++ b/spec/lib/zoom/actions/token/data_compliance_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Token do let(:zc) { oauth_client } @@ -21,25 +21,20 @@ } end - describe '#data_compliance action' do + describe "#data_compliance action" do before :each do - Zoom.configure do |config| - config.api_key = 'xxx' - config.api_secret = 'xxx' - end - stub_request( :post, - zoom_auth_url('oauth/data/compliance') - ).to_return(body: json_response('token', 'data_compliance'), - headers: { 'Content-Type' => 'application/json' }) + zoom_auth_url("oauth/data/compliance") + ).to_return(body: json_response("token", "data_compliance"), + headers: {"Content-Type" => "application/json"}) end it "raises an error when args missing" do expect { zc.data_compliance }.to raise_error(Zoom::ParameterMissing, [:client_id, :user_id, :account_id, :deauthorization_event_received, :compliance_completed].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.data_compliance(args)).to be_kind_of(Hash) end end diff --git a/spec/lib/zoom/actions/token/refresh_token_spec.rb b/spec/lib/zoom/actions/token/refresh_token_spec.rb index 99c7d84c..9f350bbd 100644 --- a/spec/lib/zoom/actions/token/refresh_token_spec.rb +++ b/spec/lib/zoom/actions/token/refresh_token_spec.rb @@ -1,37 +1,32 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Token do let(:zc) { oauth_client } - let(:args) { { grant_type: 'refresh_token', refresh_token: 'xxx' } } + let(:args) { {grant_type: "refresh_token", refresh_token: "xxx"} } - describe '#refresh_tokens action' do - let(:path) { '/oauth/token' } + describe "#refresh_tokens action" do + let(:path) { "/oauth/token" } let(:params) do { - base_uri: 'https://zoom.us/', + base_uri: "https://zoom.us/", body: URI.encode_www_form(args.to_a), headers: { - 'Accept'=>'application/json', - 'Authorization'=>'Basic eHh4Onh4eA==', - 'Content-Type'=>'application/x-www-form-urlencoded' + "Accept" => "application/json", + "Authorization" => "Basic eHh4Onh4eA==", + "Content-Type" => "application/x-www-form-urlencoded" } } end before :each do - Zoom.configure do |config| - config.api_key = 'xxx' - config.api_secret = 'xxx' - end - allow(Zoom::Utils).to receive(:parse_response).and_return(code: 200) allow(Zoom::Client::OAuth).to( receive(:post).with(path, params) - .and_return(body: json_response('token', 'access_token'), - headers: { 'Content-Type' => 'application/json' }) + .and_return(body: json_response("token", "access_token"), + headers: {"Content-Type" => "application/json"}) ) end @@ -39,11 +34,11 @@ expect { zc.refresh_tokens }.to raise_error(Zoom::ParameterMissing, [:grant_type, :refresh_token].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.refresh_tokens(args)).to be_kind_of(Hash) end - it 'passes args in the body and sends x-www-form-urlencoded header' do + it "passes args in the body and sends x-www-form-urlencoded header" do zc.refresh_tokens(args) expect(Zoom::Client::OAuth).to have_received(:post).with(path, params) end diff --git a/spec/lib/zoom/actions/token/revoke_token_spec.rb b/spec/lib/zoom/actions/token/revoke_token_spec.rb index 3ceab8dd..82a1ec50 100644 --- a/spec/lib/zoom/actions/token/revoke_token_spec.rb +++ b/spec/lib/zoom/actions/token/revoke_token_spec.rb @@ -1,38 +1,33 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Token do let(:zc) { oauth_client } - let(:args) { { access_token: 'xxx' } } - let(:body) { { token: 'xxx' } } + let(:args) { {access_token: "xxx"} } + let(:body) { {token: "xxx"} } - describe '#revoke_tokens action' do - let(:path) { '/oauth/revoke' } + describe "#revoke_tokens action" do + let(:path) { "/oauth/revoke" } let(:params) do { - base_uri: 'https://zoom.us/', + base_uri: "https://zoom.us/", body: URI.encode_www_form(body.to_a), headers: { - 'Accept'=>'application/json', - 'Authorization'=>'Basic eHh4Onh4eA==', - 'Content-Type'=>'application/x-www-form-urlencoded' + "Accept" => "application/json", + "Authorization" => "Basic eHh4Onh4eA==", + "Content-Type" => "application/x-www-form-urlencoded" } } end before :each do - Zoom.configure do |config| - config.api_key = 'xxx' - config.api_secret = 'xxx' - end - allow(Zoom::Utils).to receive(:parse_response).and_return(code: 200) allow(Zoom::Client::OAuth).to( receive(:post).with(path, params) - .and_return(body: json_response('token', 'access_token'), - headers: { 'Content-Type' => 'application/json' }) + .and_return(body: json_response("token", "access_token"), + headers: {"Content-Type" => "application/json"}) ) end @@ -40,11 +35,11 @@ expect { zc.revoke_tokens }.to raise_error(Zoom::ParameterMissing, [:token].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.revoke_tokens(args)).to be_kind_of(Hash) end - it 'passes args in the body and sends x-www-form-urlencoded header' do + it "passes args in the body and sends x-www-form-urlencoded header" do zc.revoke_tokens(args) expect(Zoom::Client::OAuth).to have_received(:post).with(path, params) end diff --git a/spec/lib/zoom/actions/user/assistant/create_spec.rb b/spec/lib/zoom/actions/user/assistant/create_spec.rb index c3d81b34..b42cfc72 100644 --- a/spec/lib/zoom/actions/user/assistant/create_spec.rb +++ b/spec/lib/zoom/actions/user/assistant/create_spec.rb @@ -1,22 +1,22 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:assistant_foo) { { id: 'foo', email: 'foo@bar.bas' } } - let(:args) { { user_id: 'ufR93M2pRyy8ePFN92dttq', assistants: [assistant_foo] } } + let(:assistant_foo) { {id: "foo", email: "foo@bar.bas"} } + let(:args) { {user_id: "ufR93M2pRyy8ePFN92dttq", assistants: [assistant_foo]} } let(:response) { zc.user_assistants_create(args) } - describe '#user_assistants_create action' do - context 'with 201 response' do + describe "#user_assistants_create action" do + context "with 201 response" do before :each do stub_request( :post, zoom_url("/users/#{args[:user_id]}/assistants") ).to_return(status: 201, - body: json_response('user', 'assistant', 'create'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("user", "assistant", "create"), + headers: {"Content-Type" => "application/json"}) end it "requires user_id param" do @@ -31,29 +31,29 @@ }.not_to raise_error end - it 'returns a hash' do + it "returns a hash" do expect(response).to be_kind_of(Hash) end it "returns 'ids' and 'add_at'" do - expect(response['ids']).to eq "foo" - expect(response['add_at']).to eq "2020-04-08T12:00:00Z" + expect(response["ids"]).to eq "foo" + expect(response["add_at"]).to eq "2020-04-08T12:00:00Z" end end - context 'with 404 response' do + context "with 404 response" do before :each do stub_request( :post, zoom_url("/users/#{args[:user_id]}/assistants") ).to_return(status: 404, - body: json_response('error', 'user_not_exist'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "user_not_exist"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { response }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/user/assistant/delete_all_spec.rb b/spec/lib/zoom/actions/user/assistant/delete_all_spec.rb index 78832463..c718decd 100644 --- a/spec/lib/zoom/actions/user/assistant/delete_all_spec.rb +++ b/spec/lib/zoom/actions/user/assistant/delete_all_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { user_id: 'eIimBAXqSrWOcB_EOIXTog' } } + let(:args) { {user_id: "eIimBAXqSrWOcB_EOIXTog"} } - describe '#user_assistants_delete_all' do - context 'with a 204 response' do + describe "#user_assistants_delete_all" do + context "with a 204 response" do before :each do stub_request( :delete, @@ -15,30 +15,30 @@ ).to_return(status: 204) end - it 'requires user_id param' do + it "requires user_id param" do expect do zc.user_assistants_delete_all(filter_key(args, :user_id)) end.to raise_error(Zoom::ParameterMissing, [:user_id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.user_assistants_delete_all(args)).to eql(204) end end - context 'with a 4xx when the user is not found' do + context "with a 4xx when the user is not found" do before :each do stub_request( :delete, zoom_url("/users/#{args[:user_id]}/assistants") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.user_assistants_delete_all(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/user/assistant/delete_spec.rb b/spec/lib/zoom/actions/user/assistant/delete_spec.rb index 7f5faa66..ab50fe53 100644 --- a/spec/lib/zoom/actions/user/assistant/delete_spec.rb +++ b/spec/lib/zoom/actions/user/assistant/delete_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { user_id: 'eIimBAXqSrWOcB_EOIXTog', assistant_id: '555' } } + let(:args) { {user_id: "eIimBAXqSrWOcB_EOIXTog", assistant_id: "555"} } - describe '#user_assistants_delete' do - context 'with a 204 response' do + describe "#user_assistants_delete" do + context "with a 204 response" do before :each do stub_request( :delete, @@ -15,36 +15,36 @@ ).to_return(status: 204) end - it 'requires user_id param' do + it "requires user_id param" do expect do zc.user_assistants_delete(filter_key(args, :user_id)) end.to raise_error(Zoom::ParameterMissing, [:user_id].to_s) end - it 'requires assistant_id param' do + it "requires assistant_id param" do expect do zc.user_assistants_delete(filter_key(args, :assistant_id)) end.to raise_error(Zoom::ParameterMissing, [:assistant_id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.user_assistants_delete(args)).to eql(204) end end - context 'with a 4xx when the user is not found' do + context "with a 4xx when the user is not found" do before :each do stub_request( :delete, zoom_url("/users/#{args[:user_id]}/assistants/#{args[:assistant_id]}") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.user_assistants_delete(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/user/assistant/list_spec.rb b/spec/lib/zoom/actions/user/assistant/list_spec.rb index 109f86a3..f496eee3 100644 --- a/spec/lib/zoom/actions/user/assistant/list_spec.rb +++ b/spec/lib/zoom/actions/user/assistant/list_spec.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { user_id: 'ufR93M2pRyy8ePFN92dttq' } } + let(:args) { {user_id: "ufR93M2pRyy8ePFN92dttq"} } - describe '#user_assistants_list action' do - context 'with a valid response' do + describe "#user_assistants_list action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/users/#{args[:user_id]}/assistants") - ).to_return(body: json_response('user', 'assistant', 'list'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("user", "assistant", "list"), + headers: {"Content-Type" => "application/json"}) end it "requires user_id param" do @@ -22,32 +22,32 @@ }.to raise_error(Zoom::ParameterMissing, [:user_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.user_assistants_list(args)).to be_kind_of(Hash) end it "returns 'assistants' count" do - expect(zc.user_assistants_list(args)['assistants'].count).to eq(1) + expect(zc.user_assistants_list(args)["assistants"].count).to eq(1) end it "returns 'assistants' Array" do - expect(zc.user_assistants_list(args)['assistants']).to be_kind_of(Array) + expect(zc.user_assistants_list(args)["assistants"]).to be_kind_of(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/users/#{args[:user_id]}/assistants") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.user_assistants_list(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/user/assistant/set_spec.rb b/spec/lib/zoom/actions/user/assistant/set_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/user/assistant/set_spec.rb +++ b/spec/lib/zoom/actions/user/assistant/set_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/user/autocreate2_spec.rb b/spec/lib/zoom/actions/user/autocreate2_spec.rb index fddbb077..cb5a80d6 100644 --- a/spec/lib/zoom/actions/user/autocreate2_spec.rb +++ b/spec/lib/zoom/actions/user/autocreate2_spec.rb @@ -1,59 +1,61 @@ -require 'spec_helper' +require "spec_helper" xdescribe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { email: 'foo@bar.com', - password: 'somepassword123', - first_name: 'Zoomie', - last_name: 'Userton', - type: 1 } } + let(:args) { + {email: "foo@bar.com", + password: "somepassword123", + first_name: "Zoomie", + last_name: "Userton", + type: 1} + } let(:response) { zc.user_autocreate2(args) } - xdescribe '#user_autocreate2 action' do + xdescribe "#user_autocreate2 action" do before :each do stub_request( :post, - zoom_url('/user/autocreate2') - ).to_return(body: json_response('user', 'autocreate2')) + zoom_url("/user/autocreate2") + ).to_return(body: json_response("user", "autocreate2")) # the api for autocreate2 is basically all the same end - it 'requires email param' do + it "requires email param" do expect { zc.user_autocreate2(filter_key(args, :email)) }.to raise_error(ArgumentError) end - it 'requires type param' do + it "requires type param" do expect { zc.user_autocreate2(filter_key(args, :type)) }.to raise_error(ArgumentError) end - it 'requires password param' do - expect{ zc.user_autocreate2(filter_key(args, :password)) }.to raise_error(ArgumentError) + it "requires password param" do + expect { zc.user_autocreate2(filter_key(args, :password)) }.to raise_error(ArgumentError) end - it 'returns a hash' do + it "returns a hash" do expect(response).to be_kind_of(Hash) end - it 'returns same params' do - expect(response['email']).to eq(args[:email]) - expect(response['first_name']).to eq(args[:first_name]) - expect(response['last_name']).to eq(args[:last_name]) - expect(response['type']).to eq(args[:type]) + it "returns same params" do + expect(response["email"]).to eq(args[:email]) + expect(response["first_name"]).to eq(args[:first_name]) + expect(response["last_name"]).to eq(args[:last_name]) + expect(response["type"]).to eq(args[:type]) end end - xdescribe '#user_autocreate2! action' do + xdescribe "#user_autocreate2! action" do before :each do stub_request( :post, - zoom_url('/user/autocreate2') - ).to_return(body: json_response('error')) + zoom_url("/user/autocreate2") + ).to_return(body: json_response("error")) end - it 'raises Zoomus::Error exception' do + it "raises Zoomus::Error exception" do expect { zc.user_autocreate2!(args) }.to raise_error(Zoom::Error) end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/user/autocreate_spec.rb b/spec/lib/zoom/actions/user/autocreate_spec.rb index ca1196cc..b48b3bcd 100644 --- a/spec/lib/zoom/actions/user/autocreate_spec.rb +++ b/spec/lib/zoom/actions/user/autocreate_spec.rb @@ -1,58 +1,60 @@ -require 'spec_helper' +require "spec_helper" xdescribe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { email: 'foo@bar.com', - password: 'somepassword123', - first_name: 'Zoomie', - last_name: 'Userton', - type: 1 } } + let(:args) { + {email: "foo@bar.com", + password: "somepassword123", + first_name: "Zoomie", + last_name: "Userton", + type: 1} + } let(:response) { zc.user_autocreate(args) } - xdescribe '#user_autocreate action' do + xdescribe "#user_autocreate action" do before :each do stub_request( :post, - zoom_url('/user/autocreate') - ).to_return(body: json_response('user', 'autocreate')) + zoom_url("/user/autocreate") + ).to_return(body: json_response("user", "autocreate")) end - it 'requires email param' do + it "requires email param" do expect { zc.user_autocreate(filter_key(args, :email)) }.to raise_error(ArgumentError) end - it 'requires type param' do + it "requires type param" do expect { zc.user_autocreate(filter_key(args, :type)) }.to raise_error(ArgumentError) end - it 'requires password param' do - expect{ zc.user_autocreate(filter_key(args, :password)) }.to raise_error(ArgumentError) + it "requires password param" do + expect { zc.user_autocreate(filter_key(args, :password)) }.to raise_error(ArgumentError) end - it 'returns a hash' do + it "returns a hash" do expect(response).to be_kind_of(Hash) end - it 'returns same params' do - expect(response['email']).to eq(args[:email]) - expect(response['first_name']).to eq(args[:first_name]) - expect(response['last_name']).to eq(args[:last_name]) - expect(response['type']).to eq(args[:type]) + it "returns same params" do + expect(response["email"]).to eq(args[:email]) + expect(response["first_name"]).to eq(args[:first_name]) + expect(response["last_name"]).to eq(args[:last_name]) + expect(response["type"]).to eq(args[:type]) end end - xdescribe '#user_autocreate! action' do + xdescribe "#user_autocreate! action" do before :each do stub_request( :post, - zoom_url('/user/autocreate') - ).to_return(body: json_response('error')) + zoom_url("/user/autocreate") + ).to_return(body: json_response("error")) end - it 'raises Zoomus::Error exception' do + it "raises Zoomus::Error exception" do expect { zc.user_autocreate!(args) }.to raise_error(Zoom::Error) end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/user/create_spec.rb b/spec/lib/zoom/actions/user/create_spec.rb index fb4371f9..8f55ab37 100644 --- a/spec/lib/zoom/actions/user/create_spec.rb +++ b/spec/lib/zoom/actions/user/create_spec.rb @@ -1,72 +1,72 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } let(:args) do { - action: 'create', + action: "create", user_info: { - email: 'foo@bar.com', + email: "foo@bar.com", type: 1, - first_name: 'Zoomie', - last_name: 'Userton', - password: 'testerino' + first_name: "Zoomie", + last_name: "Userton", + password: "testerino" } } end - describe '#user_create' do - context 'with 201 response' do + describe "#user_create" do + context "with 201 response" do before :each do stub_request( :post, - zoom_url('/users') + zoom_url("/users") ).to_return(status: 201, - body: json_response('user', 'create'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("user", "create"), + headers: {"Content-Type" => "application/json"}) end - it 'requires action param' do + it "requires action param" do expect { zc.user_create(filter_key(args, :action)) }.to raise_error(Zoom::ParameterMissing, [:action].to_s) end - it 'requires email param' do + it "requires email param" do args[:user_info].delete(:email) expect { zc.user_create(args) }.to raise_error(Zoom::ParameterMissing, [{user_info: [:email]}].to_s) end - it 'requires type param' do + it "requires type param" do args[:user_info].delete(:type) expect { zc.user_create(args) }.to raise_error(Zoom::ParameterMissing, [{user_info: [:type]}].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.user_create(args)).to be_kind_of(Hash) end - it 'returns same params' do + it "returns same params" do res = zc.user_create(args) - expect(res['email']).to eq(args[:user_info][:email]) - expect(res['first_name']).to eq(args[:user_info][:first_name]) - expect(res['last_name']).to eq(args[:user_info][:last_name]) - expect(res['type']).to eq(args[:user_info][:type]) + expect(res["email"]).to eq(args[:user_info][:email]) + expect(res["first_name"]).to eq(args[:user_info][:first_name]) + expect(res["last_name"]).to eq(args[:user_info][:last_name]) + expect(res["type"]).to eq(args[:user_info][:type]) end end - context 'with 409 response' do + context "with 409 response" do before :each do stub_request( :post, - zoom_url('/users') + zoom_url("/users") ).to_return(status: 409, - body: json_response('error', 'already_exists'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "already_exists"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.user_create(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/user/custcreate_spec.rb b/spec/lib/zoom/actions/user/custcreate_spec.rb index 2bab3e1b..0faae874 100644 --- a/spec/lib/zoom/actions/user/custcreate_spec.rb +++ b/spec/lib/zoom/actions/user/custcreate_spec.rb @@ -1,56 +1,55 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" xdescribe Zoom::Actions::User do - before :all do @zc = zoom_client - @args = { email: 'foo@bar.com', - first_name: 'Foo', - last_name: 'Bar', - type: 1 } + @args = {email: "foo@bar.com", + first_name: "Foo", + last_name: "Bar", + type: 1} end - xdescribe '#user_custcreate action' do + xdescribe "#user_custcreate action" do before :each do stub_request( :post, - zoom_url('/user/custcreate') - ).to_return(body: json_response('user', 'custcreate')) + zoom_url("/user/custcreate") + ).to_return(body: json_response("user", "custcreate")) end - it 'requires email param' do + it "requires email param" do expect { @zc.user_custcreate(filter_key(@args, :email)) }.to raise_error(ArgumentError) end - it 'requires type param' do + it "requires type param" do expect { @zc.user_custcreate(filter_key(@args, :type)) }.to raise_error(ArgumentError) end - it 'returns a hash' do + it "returns a hash" do expect(@zc.user_custcreate(@args)).to be_kind_of(Hash) end - it 'returns same params' do + it "returns same params" do res = @zc.user_custcreate(@args) - expect(res['email']).to eq(@args[:email]) - expect(res['first_name']).to eq(@args[:first_name]) - expect(res['last_name']).to eq(@args[:last_name]) - expect(res['type']).to eq(@args[:type]) + expect(res["email"]).to eq(@args[:email]) + expect(res["first_name"]).to eq(@args[:first_name]) + expect(res["last_name"]).to eq(@args[:last_name]) + expect(res["type"]).to eq(@args[:type]) end end - xdescribe '#user_custcreate! action' do + xdescribe "#user_custcreate! action" do before :each do stub_request( :post, - zoom_url('/user/custcreate') - ).to_return(body: json_response('error')) + zoom_url("/user/custcreate") + ).to_return(body: json_response("error")) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { @zc.user_custcreate!(@args) }.to raise_error(Zoom::Error) diff --git a/spec/lib/zoom/actions/user/delete_spec.rb b/spec/lib/zoom/actions/user/delete_spec.rb index 21ab5b93..91493710 100644 --- a/spec/lib/zoom/actions/user/delete_spec.rb +++ b/spec/lib/zoom/actions/user/delete_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { id: 'eIimBAXqSrWOcB_EOIXTog' } } + let(:args) { {id: "eIimBAXqSrWOcB_EOIXTog"} } - describe '#user_delete' do - context 'with a 204 response' do + describe "#user_delete" do + context "with a 204 response" do before :each do stub_request( :delete, zoom_url("/users/#{args[:id]}") ).to_return(status: 204, - body: json_response('user', 'delete'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("user", "delete"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do + it "requires id param" do expect { zc.user_delete(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.user_delete(args)).to eql(204) end end - context 'with a 4xx when the user is not found' do + context "with a 4xx when the user is not found" do before :each do stub_request( :delete, zoom_url("/users/#{args[:id]}") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.user_delete(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/user/email_check_spec.rb b/spec/lib/zoom/actions/user/email_check_spec.rb index bf5ef739..b329ccc6 100644 --- a/spec/lib/zoom/actions/user/email_check_spec.rb +++ b/spec/lib/zoom/actions/user/email_check_spec.rb @@ -1,41 +1,41 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { email: 'test@example.com' } } + let(:args) { {email: "test@example.com"} } - describe '#user_email_check action' do - context 'with a valid response' do + describe "#user_email_check action" do + context "with a valid response" do before :each do stub_request( :get, - zoom_url('/users/email') - ).to_return(body: json_response('user', 'email_check'), - headers: { 'Content-Type' => 'application/json' }) + zoom_url("/users/email") + ).to_return(body: json_response("user", "email_check"), + headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.user_email_check(args)).to be_kind_of(Hash) end it "returns 'existed_email'" do - expect(zc.user_email_check(args)['existed_email']).to be_truthy + expect(zc.user_email_check(args)["existed_email"]).to be_truthy end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, - zoom_url('/users/email') + zoom_url("/users/email") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.user_email_check(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/user/get_spec.rb b/spec/lib/zoom/actions/user/get_spec.rb index 319b219a..e0508c07 100644 --- a/spec/lib/zoom/actions/user/get_spec.rb +++ b/spec/lib/zoom/actions/user/get_spec.rb @@ -1,61 +1,61 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { id: 'z8dsdsdsdsdCfp8uQ' } } + let(:args) { {id: "z8dsdsdsdsdCfp8uQ"} } - describe '#user_get action' do - context 'with a valid response' do + describe "#user_get action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/users/#{args[:id]}") - ).to_return(status: 200, - body: json_response('user', 'get'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(status: 200, + body: json_response("user", "get"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do - expect { zc.user_get(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, '[:id]') + it "requires id param" do + expect { zc.user_get(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, "[:id]") end - it 'allows login type' do - args[:login_type] = '100' + it "allows login type" do + args[:login_type] = "100" expect { zc.user_get(args) }.not_to raise_error end - it 'returns a hash' do + it "returns a hash" do expect(zc.user_get(args)).to be_kind_of(Hash) end - it 'returns same params' do + it "returns same params" do res = zc.user_get(args) - expect(res['id']).to eq(args[:id]) - expect(res).to have_key('first_name') - expect(res).to have_key('last_name') - expect(res).to have_key('email') - expect(res).to have_key('type') - expect(res['custom_attributes']).to be_an(Array) - expect(res['custom_attributes']).to all(be_a(Hash)) - expect(res['group_ids']).to be_an(Array) - expect(res['im_group_ids']).to be_an(Array) + expect(res["id"]).to eq(args[:id]) + expect(res).to have_key("first_name") + expect(res).to have_key("last_name") + expect(res).to have_key("email") + expect(res).to have_key("type") + expect(res["custom_attributes"]).to be_an(Array) + expect(res["custom_attributes"]).to all(be_a(Hash)) + expect(res["group_ids"]).to be_an(Array) + expect(res["im_group_ids"]).to be_an(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/users/#{args[:id]}") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.user_get(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/user/getbyemail_spec.rb b/spec/lib/zoom/actions/user/getbyemail_spec.rb index 43d9762a..f0ff5bbd 100644 --- a/spec/lib/zoom/actions/user/getbyemail_spec.rb +++ b/spec/lib/zoom/actions/user/getbyemail_spec.rb @@ -1,51 +1,50 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" xdescribe Zoom::Actions::User do - before :all do @zc = zoom_client - @args = { email: 'foo@bar.com', - login_type: 99 } + @args = {email: "foo@bar.com", + login_type: 99} end - xdescribe '#user_getbyemail action' do + xdescribe "#user_getbyemail action" do before :each do stub_request( :post, - zoom_url('/user/getbyemail') - ).to_return(body: json_response('user', 'getbyemail')) + zoom_url("/user/getbyemail") + ).to_return(body: json_response("user", "getbyemail")) end - it 'requires email param' do + it "requires email param" do expect { @zc.user_getbyemail(filter_key(@args, :email)) }.to raise_error(ArgumentError) end - it 'returns a hash' do + it "returns a hash" do expect(@zc.user_getbyemail(@args)).to be_kind_of(Hash) end - it 'returns same params' do + it "returns same params" do res = @zc.user_getbyemail(@args) - expect(res).to have_key('id') - expect(res).to have_key('first_name') - expect(res).to have_key('last_name') - expect(res['email']).to eq(@args[:email]) - expect(res['type']).to eq(@args[:login_type]) + expect(res).to have_key("id") + expect(res).to have_key("first_name") + expect(res).to have_key("last_name") + expect(res["email"]).to eq(@args[:email]) + expect(res["type"]).to eq(@args[:login_type]) end end - xdescribe '#user_getbyemail! action' do + xdescribe "#user_getbyemail! action" do before :each do stub_request( :post, - zoom_url('/user/getbyemail') - ).to_return(body: json_response('error')) + zoom_url("/user/getbyemail") + ).to_return(body: json_response("error")) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { @zc.user_getbyemail!(@args) }.to raise_error(Zoom::Error) diff --git a/spec/lib/zoom/actions/user/list_recordings_spec.rb b/spec/lib/zoom/actions/user/list_recordings_spec.rb index 603d240d..b92c8839 100644 --- a/spec/lib/zoom/actions/user/list_recordings_spec.rb +++ b/spec/lib/zoom/actions/user/list_recordings_spec.rb @@ -1,55 +1,55 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { id: 'ufR9342pRyf8ePFN92dttQ' } } + let(:args) { {id: "ufR9342pRyf8ePFN92dttQ"} } - describe '#user_recordings_list action' do - context 'with a valid response' do + describe "#user_recordings_list action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/users/#{args[:id]}/recordings") - ).to_return(status: 200, - body: json_response('user', 'recording', 'list'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(status: 200, + body: json_response("user", "recording", "list"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do - expect { zc.user_recordings_list(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, '[:id]') + it "requires id param" do + expect { zc.user_recordings_list(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, "[:id]") end - it 'returns a hash' do + it "returns a hash" do expect(zc.user_recordings_list(args)).to be_kind_of(Hash) end - it 'returns same params' do + it "returns same params" do res = zc.user_recordings_list(args) - expect(res).to have_key('from') - expect(res).to have_key('to') - expect(res).to have_key('total_records') - expect(res).to have_key('meetings') - expect(res['meetings'][0]).to have_key('host_id') - expect(res['meetings'][0]).to have_key('topic') - expect(res['meetings'][0]).to have_key('start_time') - expect(res['meetings'][0]).to have_key('recording_count') + expect(res).to have_key("from") + expect(res).to have_key("to") + expect(res).to have_key("total_records") + expect(res).to have_key("meetings") + expect(res["meetings"][0]).to have_key("host_id") + expect(res["meetings"][0]).to have_key("topic") + expect(res["meetings"][0]).to have_key("start_time") + expect(res["meetings"][0]).to have_key("recording_count") end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/users/#{args[:id]}/recordings") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.user_recordings_list(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/user/list_spec.rb b/spec/lib/zoom/actions/user/list_spec.rb index 7c48037e..d293f8b4 100644 --- a/spec/lib/zoom/actions/user/list_spec.rb +++ b/spec/lib/zoom/actions/user/list_spec.rb @@ -1,79 +1,79 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } let(:args) { {} } - describe '#user_list action' do - context 'with a valid response' do + describe "#user_list action" do + context "with a valid response" do before :each do stub_request( :get, - zoom_url('/users') - ).to_return(body: json_response('user', 'list'), - headers: { 'Content-Type' => 'application/json' }) + zoom_url("/users") + ).to_return(body: json_response("user", "list"), + headers: {"Content-Type" => "application/json"}) end - it 'returns a hash' do + it "returns a hash" do expect(zc.user_list).to be_kind_of(Hash) end it "returns 'total_records" do - expect(zc.user_list['total_records']).to eq(1) + expect(zc.user_list["total_records"]).to eq(1) end it "returns 'users' Array" do - expect(zc.user_list['users']).to be_kind_of(Array) + expect(zc.user_list["users"]).to be_kind_of(Array) end - it 'allows status' do - args[:status] = 'active' + it "allows status" do + args[:status] = "active" expect { zc.user_list(args) }.not_to raise_error end - it 'allows page_size' do + it "allows page_size" do args[:page_size] = 30 expect { zc.user_list(args) }.not_to raise_error end - it 'allows role_id' do - args[:role_id] = '1' + it "allows role_id" do + args[:role_id] = "1" expect { zc.user_list(args) }.not_to raise_error end - it 'allows page_number' do + it "allows page_number" do args[:page_number] = 1 expect { zc.user_list(args) }.not_to raise_error end - it 'allows include_fields' do - args[:include_fields] = 'host_key' + it "allows include_fields" do + args[:include_fields] = "host_key" expect { zc.user_list(args) }.not_to raise_error end - it 'next_page_token' do - args[:next_page_token] = 'some_token' + it "next_page_token" do + args[:next_page_token] = "some_token" expect { zc.user_list(args) }.not_to raise_error end - it 'raises an error when passed an invalid parameter' do - expect { zc.user_list(foo: 'bar', status: 'active') }.to raise_error(Zoom::ParameterNotPermitted, [:foo].to_s) + it "raises an error when passed an invalid parameter" do + expect { zc.user_list(foo: "bar", status: "active") }.to raise_error(Zoom::ParameterNotPermitted, [:foo].to_s) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, - zoom_url('/users') + zoom_url("/users") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.user_list }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/user/permissions_spec.rb b/spec/lib/zoom/actions/user/permissions_spec.rb index e636eeee..24adceae 100644 --- a/spec/lib/zoom/actions/user/permissions_spec.rb +++ b/spec/lib/zoom/actions/user/permissions_spec.rb @@ -1,50 +1,50 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { user_id: 'ufR9342pRyf8ePFN92dttQ' } } + let(:args) { {user_id: "ufR9342pRyf8ePFN92dttQ"} } - describe '#user_permissions action' do - context 'with a valid response' do + describe "#user_permissions action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/users/#{args[:user_id]}/permissions") ).to_return(status: 200, - body: json_response('user', 'permissions'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("user", "permissions"), + headers: {"Content-Type" => "application/json"}) end - it 'requires user_id param' do - expect { zc.user_permissions(filter_key(args, :user_id)) }.to raise_error(Zoom::ParameterMissing, '[:user_id]') + it "requires user_id param" do + expect { zc.user_permissions(filter_key(args, :user_id)) }.to raise_error(Zoom::ParameterMissing, "[:user_id]") end - it 'returns a hash' do + it "returns a hash" do expect(zc.user_permissions(args)).to be_kind_of(Hash) end - it 'returns same params' do + it "returns same params" do res = zc.user_permissions(args) - expect(res['permissions']).to be_an(Array) - expect(res['permissions']).to all(be_a(String)) - expect(res['permissions'].size).to equal(61) + expect(res["permissions"]).to be_an(Array) + expect(res["permissions"]).to all(be_a(String)) + expect(res["permissions"].size).to equal(61) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/users/#{args[:user_id]}/permissions") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.user_permissions(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/user/scheduler/delete_all_spec.rb b/spec/lib/zoom/actions/user/scheduler/delete_all_spec.rb index 01114388..382fb899 100644 --- a/spec/lib/zoom/actions/user/scheduler/delete_all_spec.rb +++ b/spec/lib/zoom/actions/user/scheduler/delete_all_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { user_id: 'eIimBAXqSrWOcB_EOIXTog' } } + let(:args) { {user_id: "eIimBAXqSrWOcB_EOIXTog"} } - describe '#user_schedulers_delete_all' do - context 'with a 204 response' do + describe "#user_schedulers_delete_all" do + context "with a 204 response" do before :each do stub_request( :delete, @@ -15,30 +15,30 @@ ).to_return(status: 204) end - it 'requires user_id param' do + it "requires user_id param" do expect do zc.user_schedulers_delete_all(filter_key(args, :user_id)) end.to raise_error(Zoom::ParameterMissing, [:user_id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.user_schedulers_delete_all(args)).to eql(204) end end - context 'with a 4xx when the user is not found' do + context "with a 4xx when the user is not found" do before :each do stub_request( :delete, zoom_url("/users/#{args[:user_id]}/schedulers") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.user_schedulers_delete_all(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/user/scheduler/delete_spec.rb b/spec/lib/zoom/actions/user/scheduler/delete_spec.rb index 8145d20c..ced66ef0 100644 --- a/spec/lib/zoom/actions/user/scheduler/delete_spec.rb +++ b/spec/lib/zoom/actions/user/scheduler/delete_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { user_id: 'eIimBAXqSrWOcB_EOIXTog', scheduler_id: '555' } } + let(:args) { {user_id: "eIimBAXqSrWOcB_EOIXTog", scheduler_id: "555"} } - describe '#user_schedulers_delete' do - context 'with a 204 response' do + describe "#user_schedulers_delete" do + context "with a 204 response" do before :each do stub_request( :delete, @@ -15,36 +15,36 @@ ).to_return(status: 204) end - it 'requires user_id param' do + it "requires user_id param" do expect do zc.user_schedulers_delete(filter_key(args, :user_id)) end.to raise_error(Zoom::ParameterMissing, [:user_id].to_s) end - it 'requires scheduler_id param' do + it "requires scheduler_id param" do expect do zc.user_schedulers_delete(filter_key(args, :scheduler_id)) end.to raise_error(Zoom::ParameterMissing, [:scheduler_id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.user_schedulers_delete(args)).to eql(204) end end - context 'with a 4xx when the user is not found' do + context "with a 4xx when the user is not found" do before :each do stub_request( :delete, zoom_url("/users/#{args[:user_id]}/schedulers/#{args[:scheduler_id]}") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.user_schedulers_delete(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/user/scheduler/list_spec.rb b/spec/lib/zoom/actions/user/scheduler/list_spec.rb index 182b4c9e..770052d5 100644 --- a/spec/lib/zoom/actions/user/scheduler/list_spec.rb +++ b/spec/lib/zoom/actions/user/scheduler/list_spec.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { user_id: 'ufR93M2pRyy8ePFN92dttq' } } + let(:args) { {user_id: "ufR93M2pRyy8ePFN92dttq"} } - describe '#user_schedulers_list action' do - context 'with a valid response' do + describe "#user_schedulers_list action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/users/#{args[:user_id]}/schedulers") - ).to_return(body: json_response('user', 'scheduler', 'list'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("user", "scheduler", "list"), + headers: {"Content-Type" => "application/json"}) end it "requires user_id param" do @@ -22,32 +22,32 @@ }.to raise_error(Zoom::ParameterMissing, [:user_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.user_schedulers_list(args)).to be_kind_of(Hash) end it "returns 'schedulers' count" do - expect(zc.user_schedulers_list(args)['schedulers'].count).to eq(2) + expect(zc.user_schedulers_list(args)["schedulers"].count).to eq(2) end it "returns 'schedulers' Array" do - expect(zc.user_schedulers_list(args)['schedulers']).to be_kind_of(Array) + expect(zc.user_schedulers_list(args)["schedulers"]).to be_kind_of(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/users/#{args[:user_id]}/schedulers") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.user_schedulers_list(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/user/settings_get_spec.rb b/spec/lib/zoom/actions/user/settings_get_spec.rb index 420d577a..9a10ca01 100644 --- a/spec/lib/zoom/actions/user/settings_get_spec.rb +++ b/spec/lib/zoom/actions/user/settings_get_spec.rb @@ -1,54 +1,53 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { id: 'ufR9342pRyf8ePFN92dttQ' } } + let(:args) { {id: "ufR9342pRyf8ePFN92dttQ"} } - describe '#settings_get action' do - context 'with a valid response' do + describe "#settings_get action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/users/#{args[:id]}/settings") - ).to_return(status: 200, - body: json_response('user', 'settings_get'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(status: 200, + body: json_response("user", "settings_get"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do - expect { zc.user_settings_get(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, '[:id]') + it "requires id param" do + expect { zc.user_settings_get(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, "[:id]") end - it 'allowes login_type' do + it "allowes login_type" do args[:login_type] = 0 expect { zc.user_settings_get(args) }.not_to raise_error end - - it 'returns a hash' do + it "returns a hash" do expect(zc.user_settings_get(args)).to be_kind_of(Hash) end - it 'returns same params' do + it "returns same params" do res = zc.user_settings_get(args) - expect(res.keys).to match_array(['scheduled_meeting', 'in_meeting', 'email_notification', 'recording', 'telephony', 'tsp', 'feature']) + expect(res.keys).to match_array(["scheduled_meeting", "in_meeting", "email_notification", "recording", "telephony", "tsp", "feature"]) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/users/#{args[:id]}/settings") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.user_settings_get(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/user/settings_update_spec.rb b/spec/lib/zoom/actions/user/settings_update_spec.rb index 87e7b8bb..af7e2202 100644 --- a/spec/lib/zoom/actions/user/settings_update_spec.rb +++ b/spec/lib/zoom/actions/user/settings_update_spec.rb @@ -1,48 +1,47 @@ -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } let(:args) { - { id: 'eIimBAXqSrWOcB_EOIXTog', - in_meeting: { - e2e_encryption: 1 - }, - schedule_meeting: { - host_video: 1 - } - } + {id: "eIimBAXqSrWOcB_EOIXTog", + in_meeting: { + e2e_encryption: 1 + }, + schedule_meeting: { + host_video: 1 + }} } - describe '#user_settings_update' do - context 'with a valid response' do + describe "#user_settings_update" do + context "with a valid response" do before :each do stub_request( - :patch, - zoom_url("/users/#{args[:id]}/settings") + :patch, + zoom_url("/users/#{args[:id]}/settings") ).to_return(status: 204, - body: json_response('user', 'update'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("user", "update"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do + it "requires id param" do expect { zc.user_settings_update(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.user_settings_update(args)).to eql(204) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( - :patch, - zoom_url("/users/#{args[:id]}/settings") + :patch, + zoom_url("/users/#{args[:id]}/settings") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.user_settings_update(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/user/token_spec.rb b/spec/lib/zoom/actions/user/token_spec.rb index a522705c..2abd4bf0 100644 --- a/spec/lib/zoom/actions/user/token_spec.rb +++ b/spec/lib/zoom/actions/user/token_spec.rb @@ -1,59 +1,59 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { user_id: 'ufR9342pRyf8ePFN92dttQ' } } + let(:args) { {user_id: "ufR9342pRyf8ePFN92dttQ"} } - describe '#user_token action' do - context 'with a valid response' do + describe "#user_token action" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/users/#{args[:user_id]}/token") ).to_return(status: 200, - body: json_response('user', 'token'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("user", "token"), + headers: {"Content-Type" => "application/json"}) end - it 'requires user_id param' do + it "requires user_id param" do expect { zc.user_token(filter_key(args, :user_id)) } - .to raise_error(Zoom::ParameterMissing, '[:user_id]') + .to raise_error(Zoom::ParameterMissing, "[:user_id]") end - it 'allows type' do - args[:type] = 'token' + it "allows type" do + args[:type] = "token" expect { zc.user_token(args) }.not_to raise_error end - it 'allows time to live' do + it "allows time to live" do args[:ttl] = 30 expect { zc.user_token(args) }.not_to raise_error end - it 'returns a hash' do + it "returns a hash" do expect(zc.user_token(args)).to be_kind_of(Hash) end - it 'returns same params' do + it "returns same params" do res = zc.user_token(args) - expect(res['token']).to eql('string') + expect(res["token"]).to eql("string") end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/users/#{args[:user_id]}/token") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.user_token(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/user/update_email_spec.rb b/spec/lib/zoom/actions/user/update_email_spec.rb index 8b298c7c..25b733a2 100644 --- a/spec/lib/zoom/actions/user/update_email_spec.rb +++ b/spec/lib/zoom/actions/user/update_email_spec.rb @@ -1,57 +1,57 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { id: 'eIimBAXqSrWOcB_EOIXTog', email: 'new.email@example.com' } } + let(:args) { {id: "eIimBAXqSrWOcB_EOIXTog", email: "new.email@example.com"} } - describe '#user_email_update' do - context 'with a valid response' do + describe "#user_email_update" do + context "with a valid response" do before :each do stub_request( :patch, zoom_url("/users/#{args[:id]}/email") ).to_return(status: 204, - body: json_response('user', 'update_email'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("user", "update_email"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do + it "requires id param" do expect { zc.user_email_update(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.user_email_update(args)).to eql(204) end end - context 'with a 400 response' do + context "with a 400 response" do before :each do stub_request( - :patch, - zoom_url("/users/#{args[:id]}/email") + :patch, + zoom_url("/users/#{args[:id]}/email") ).to_return(status: 400, - body: json_response('error', 'not_found_administrator'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found_administrator"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.user_email_update(args) }.to raise_error(Zoom::BadRequest) end end - context 'with a 404 response' do + context "with a 404 response" do before :each do stub_request( - :patch, - zoom_url("/users/#{args[:id]}/email") + :patch, + zoom_url("/users/#{args[:id]}/email") ).to_return(status: 404, - body: json_response('error', 'user_not_exist'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "user_not_exist"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.user_email_update(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/user/update_password_spec.rb b/spec/lib/zoom/actions/user/update_password_spec.rb index edffc601..6d23641f 100644 --- a/spec/lib/zoom/actions/user/update_password_spec.rb +++ b/spec/lib/zoom/actions/user/update_password_spec.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { id: 'eIimBAXqSrWOcB_EOIXTog', password: 'new_pass' } } + let(:args) { {id: "eIimBAXqSrWOcB_EOIXTog", password: "new_pass"} } - describe '#user_password_update' do - context 'with a valid response' do + describe "#user_password_update" do + context "with a valid response" do before :each do stub_request( :patch, zoom_url("/users/#{args[:id]}/password") ).to_return(status: 204, - body: json_response('user', 'update_password'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("user", "update_password"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do + it "requires id param" do expect { zc.user_password_update(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.user_password_update(args)).to eql(204) end end diff --git a/spec/lib/zoom/actions/user/update_spec.rb b/spec/lib/zoom/actions/user/update_spec.rb index 118253d1..3956b7ac 100644 --- a/spec/lib/zoom/actions/user/update_spec.rb +++ b/spec/lib/zoom/actions/user/update_spec.rb @@ -1,43 +1,45 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { id: 'eIimBAXqSrWOcB_EOIXTog', - first_name: 'Bar', - last_name: 'Foo' } } + let(:args) { + {id: "eIimBAXqSrWOcB_EOIXTog", + first_name: "Bar", + last_name: "Foo"} + } - describe '#user_update' do - context 'with a valid response' do + describe "#user_update" do + context "with a valid response" do before :each do stub_request( :patch, zoom_url("/users/#{args[:id]}") ).to_return(status: 204, - body: json_response('user', 'update'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("user", "update"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do + it "requires id param" do expect { zc.user_update(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.user_update(args)).to eql(204) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :patch, zoom_url("/users/#{args[:id]}") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.user_update(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/user/update_status_spec.rb b/spec/lib/zoom/actions/user/update_status_spec.rb index 036ebd8e..9bf8d331 100644 --- a/spec/lib/zoom/actions/user/update_status_spec.rb +++ b/spec/lib/zoom/actions/user/update_status_spec.rb @@ -1,57 +1,57 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { id: 'eIimBAXqSrWOcB_EOIXTog', status: 'activate' } } + let(:args) { {id: "eIimBAXqSrWOcB_EOIXTog", status: "activate"} } - describe '#user_status_update' do - context 'with a valid response' do + describe "#user_status_update" do + context "with a valid response" do before :each do stub_request( :patch, zoom_url("/users/#{args[:id]}/status") ).to_return(status: 204, - body: json_response('user', 'update_status'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("user", "update_status"), + headers: {"Content-Type" => "application/json"}) end - it 'requires id param' do + it "requires id param" do expect { zc.user_status_update(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.user_status_update(args)).to eql(204) end end - context 'with a 400 response' do + context "with a 400 response" do before :each do stub_request( - :patch, - zoom_url("/users/#{args[:id]}/status") + :patch, + zoom_url("/users/#{args[:id]}/status") ).to_return(status: 400, - body: json_response('error', 'admin_cannot_activated'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "admin_cannot_activated"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.user_status_update(args) }.to raise_error(Zoom::BadRequest) end end - context 'with a 404 response' do + context "with a 404 response" do before :each do stub_request( - :patch, - zoom_url("/users/#{args[:id]}/status") + :patch, + zoom_url("/users/#{args[:id]}/status") ).to_return(status: 404, - body: json_response('error', 'user_not_exist'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "user_not_exist"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.user_status_update(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/user/vanity_name_spec.rb b/spec/lib/zoom/actions/user/vanity_name_spec.rb index 9621365f..7dd3fa73 100644 --- a/spec/lib/zoom/actions/user/vanity_name_spec.rb +++ b/spec/lib/zoom/actions/user/vanity_name_spec.rb @@ -1,50 +1,50 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::User do let(:zc) { zoom_client } - let(:args) { { vanity_name: 'foobar' } } + let(:args) { {vanity_name: "foobar"} } - describe '#user_vanity_name action' do - context 'with a valid response' do + describe "#user_vanity_name action" do + context "with a valid response" do before :each do stub_request( :get, - zoom_url('/users/vanity_name') + zoom_url("/users/vanity_name") ).to_return(status: 200, - body: json_response('user', 'vanity_name'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("user", "vanity_name"), + headers: {"Content-Type" => "application/json"}) end - it 'requires vanity_name param' do + it "requires vanity_name param" do expect { zc.user_vanity_name(filter_key(args, :vanity_name)) } - .to raise_error(Zoom::ParameterMissing, '[:vanity_name]') + .to raise_error(Zoom::ParameterMissing, "[:vanity_name]") end - it 'returns a hash' do + it "returns a hash" do expect(zc.user_vanity_name(args)).to be_kind_of(Hash) end - it 'returns expected value' do + it "returns expected value" do res = zc.user_vanity_name(args) - expect(res['existed']).to be true + expect(res["existed"]).to be true end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, - zoom_url('/users/vanity_name') + zoom_url("/users/vanity_name") ).to_return(status: 400, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do - expect { zc.user_vanity_name({ vanity_name: '' }) }.to raise_error(Zoom::Error) + it "raises Zoom::Error exception" do + expect { zc.user_vanity_name({vanity_name: ""}) }.to raise_error(Zoom::Error) end end end diff --git a/spec/lib/zoom/actions/webinar/attendees_list_spec.rb b/spec/lib/zoom/actions/webinar/attendees_list_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/webinar/attendees_list_spec.rb +++ b/spec/lib/zoom/actions/webinar/attendees_list_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/webinar/create_spec.rb b/spec/lib/zoom/actions/webinar/create_spec.rb index 4d36f893..e77608c7 100644 --- a/spec/lib/zoom/actions/webinar/create_spec.rb +++ b/spec/lib/zoom/actions/webinar/create_spec.rb @@ -1,55 +1,54 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Zoom::Actions::Webinar do - - [:jwt_client, :oauth_client].each do |client| - describe "#{client}" do + %i[oauth_client server_to_server_oauth_client].each do |client| + describe client.to_s do let(:zc) { send(client) } - let(:args) { { host_id: 'test_user_id' } } + let(:args) { {host_id: "test_user_id"} } - describe '#webinar_create' do - context 'with a valid response' do + describe "#webinar_create" do + context "with a valid response" do before :each do stub_request( :post, zoom_url("/users/#{args[:host_id]}/webinars") - ).to_return(body: json_response('webinar', 'create'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("webinar", "create"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'host_id' argument" do expect { zc.webinar_create(filter_key(args, :host_id)) }.to raise_error(Zoom::ParameterMissing, [:host_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.webinar_create(args)).to be_kind_of(Hash) end - it 'returns the setted params' do + it "returns the setted params" do res = zc.webinar_create(args) - expect(res['host_id']).to eq(args[:host_id]) + expect(res["host_id"]).to eq(args[:host_id]) end it "returns 'start_url' and 'join_url'" do res = zc.webinar_create(args) - expect(res['start_url']).to_not be_nil - expect(res['join_url']).to_not be_nil + expect(res["start_url"]).to_not be_nil + expect(res["join_url"]).to_not be_nil end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :post, zoom_url("/users/#{args[:host_id]}/webinars") - ).to_return(body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.webinar_create(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/webinar/delete_spec.rb b/spec/lib/zoom/actions/webinar/delete_spec.rb index 9a19144a..54472bd3 100644 --- a/spec/lib/zoom/actions/webinar/delete_spec.rb +++ b/spec/lib/zoom/actions/webinar/delete_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { id: '123456789' } } + let(:args) { {id: "123456789"} } - describe '#webinar_delete' do - context 'with a valid response' do + describe "#webinar_delete" do + context "with a valid response" do before :each do stub_request( :delete, zoom_url("/webinars/#{args[:id]}") ).to_return(status: 204, - body: json_response('webinar', 'delete'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("webinar", "delete"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'id' argument" do expect { zc.webinar_delete(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.webinar_delete(args)).to eql(204) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :delete, zoom_url("/webinars/#{args[:id]}") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.webinar_delete(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/webinar/end_spec.rb b/spec/lib/zoom/actions/webinar/end_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/webinar/end_spec.rb +++ b/spec/lib/zoom/actions/webinar/end_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/webinar/get_spec.rb b/spec/lib/zoom/actions/webinar/get_spec.rb index 43d8f93f..7e7b4afc 100644 --- a/spec/lib/zoom/actions/webinar/get_spec.rb +++ b/spec/lib/zoom/actions/webinar/get_spec.rb @@ -1,24 +1,23 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" xdescribe Zoom::Actions::Webinar do - before :all do @zc = zoom_client @args = { - host_id: 'dh23hdu23gd', - id: '123456789' + host_id: "dh23hdu23gd", + id: "123456789" } end - xdescribe '#webinar_get action' do + xdescribe "#webinar_get action" do before :each do stub_request( :post, - zoom_url('/webinar/get') - ).to_return(body: json_response('webinar_get'), - headers: { 'Content-Type' => 'application/json' }) + zoom_url("/webinar/get") + ).to_return(body: json_response("webinar_get"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'host_id' argument" do @@ -33,31 +32,31 @@ }.to raise_error(ArgumentError) end - it 'returns a hash' do + it "returns a hash" do expect(@zc.webinar_get(@args)).to be_kind_of(Hash) end - it 'returns id and attributes' do + it "returns id and attributes" do res = @zc.webinar_get(@args) - expect(res['id']).to eq(@args[:id]) - expect(res['host_id']).to eq(@args[:host_id]) - expect(res['topic']).to eq('Topic for this meeting') - expect(res['start_time']).to eq('2012-11-25T12:00:00Z') - expect(res['join_url']).to eq('https://zoom.us/j/123456789') - expect(res['start_url']).to eq('https://zoom.us/s/123456789?zpk=hs65q23kd9sqliy612h23k') + expect(res["id"]).to eq(@args[:id]) + expect(res["host_id"]).to eq(@args[:host_id]) + expect(res["topic"]).to eq("Topic for this meeting") + expect(res["start_time"]).to eq("2012-11-25T12:00:00Z") + expect(res["join_url"]).to eq("https://zoom.us/j/123456789") + expect(res["start_url"]).to eq("https://zoom.us/s/123456789?zpk=hs65q23kd9sqliy612h23k") end end - xdescribe '#webinar_get! action' do + xdescribe "#webinar_get! action" do before :each do stub_request( :post, - zoom_url('/webinar/get') - ).to_return(body: json_response('error')) + zoom_url("/webinar/get") + ).to_return(body: json_response("error")) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { @zc.webinar_get!(@args) }.to raise_error(Zoom::Error) diff --git a/spec/lib/zoom/actions/webinar/list_registration_spec.rb b/spec/lib/zoom/actions/webinar/list_registration_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/webinar/list_registration_spec.rb +++ b/spec/lib/zoom/actions/webinar/list_registration_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/webinar/list_spec.rb b/spec/lib/zoom/actions/webinar/list_spec.rb index 94bdf58a..58e10526 100644 --- a/spec/lib/zoom/actions/webinar/list_spec.rb +++ b/spec/lib/zoom/actions/webinar/list_spec.rb @@ -1,48 +1,48 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { host_id: 'test_user_id' } } + let(:args) { {host_id: "test_user_id"} } - describe '#webinar_list' do - context 'with a valid response' do + describe "#webinar_list" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/users/#{args[:host_id]}/webinars") - ).to_return(body: json_response('webinar', 'list'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("webinar", "list"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'host_id' argument" do expect { zc.webinar_list }.to raise_error(Zoom::ParameterMissing, [:host_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.webinar_list(args)).to be_kind_of(Hash) end it "returns 'total_records'" do - expect(zc.webinar_list(args)['total_records']).to eq(1) + expect(zc.webinar_list(args)["total_records"]).to eq(1) end it "returns 'webinars' Array" do - expect(zc.webinar_list(args)['webinars']).to be_kind_of(Array) + expect(zc.webinar_list(args)["webinars"]).to be_kind_of(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/users/#{args[:host_id]}/webinars") - ).to_return(body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.webinar_list(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/webinar/panelist_add_spec.rb b/spec/lib/zoom/actions/webinar/panelist_add_spec.rb index 806ba324..f6b8ab4e 100644 --- a/spec/lib/zoom/actions/webinar/panelist_add_spec.rb +++ b/spec/lib/zoom/actions/webinar/panelist_add_spec.rb @@ -1,21 +1,23 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { webinar_id: '123456789', - panelists: [{email: "foo@bar.com", name: "Foo Bar"}] } } + let(:args) { + {webinar_id: "123456789", + panelists: [{email: "foo@bar.com", name: "Foo Bar"}]} + } - describe '#webinar_panelist_add' do - context 'with a valid response' do + describe "#webinar_panelist_add" do + context "with a valid response" do before :each do stub_request( :post, zoom_url("/webinars/#{args[:webinar_id]}/panelists") ).to_return(status: 201, - body: json_response('webinar', 'panelist_add'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("webinar", "panelist_add"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'webinar id' argument" do @@ -25,30 +27,30 @@ it "requires a 'panelists' argument" do expect { zc.webinar_panelist_add(filter_key(args, :panelists)) }.to raise_error(Zoom::ParameterMissing, [:panelists].to_s) end - - it 'returns an Hash' do + + it "returns an Hash" do expect(zc.webinar_panelist_add(args)).to be_kind_of(Hash) end it 'returns an "id"' do res = zc.webinar_panelist_add(args) - expect(res['id']).not_to be nil + expect(res["id"]).not_to be nil end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :post, zoom_url("/webinars/#{args[:webinar_id]}/panelists") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.webinar_panelist_add(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/webinar/panelist_delete_spec.rb b/spec/lib/zoom/actions/webinar/panelist_delete_spec.rb index 1578743b..a822270d 100644 --- a/spec/lib/zoom/actions/webinar/panelist_delete_spec.rb +++ b/spec/lib/zoom/actions/webinar/panelist_delete_spec.rb @@ -1,21 +1,23 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { webinar_id: '123456789', - panelist_id: '12345' } } + let(:args) { + {webinar_id: "123456789", + panelist_id: "12345"} + } - describe '#webinar_panelist_delete' do - context 'with a valid response' do + describe "#webinar_panelist_delete" do + context "with a valid response" do before :each do stub_request( :delete, zoom_url("/webinars/#{args[:webinar_id]}/panelists/#{args[:panelist_id]}") ).to_return(status: 204, - body: json_response('webinar', 'panelist_delete'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("webinar", "panelist_delete"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'webinar id' argument" do @@ -26,25 +28,24 @@ expect { zc.webinar_panelist_delete(filter_key(args, :panelist_id)) }.to raise_error(Zoom::ParameterMissing, [:panelist_id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.webinar_panelist_delete(args)).to eql(204) end - end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :delete, zoom_url("/webinars/#{args[:webinar_id]}/panelists/#{args[:panelist_id]}") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.webinar_panelist_delete(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/webinar/panelist_list_spec.rb b/spec/lib/zoom/actions/webinar/panelist_list_spec.rb index e0ff9dd6..f41f4f96 100644 --- a/spec/lib/zoom/actions/webinar/panelist_list_spec.rb +++ b/spec/lib/zoom/actions/webinar/panelist_list_spec.rb @@ -1,44 +1,44 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { webinar_id: '123456789' } } + let(:args) { {webinar_id: "123456789"} } - describe '#webinar_panelist_list' do - context 'with a valid response' do + describe "#webinar_panelist_list" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/webinars/#{args[:webinar_id]}/panelists") ).to_return(status: 200, - body: json_response('webinar', 'panelist_list'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("webinar", "panelist_list"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'id' argument" do expect { zc.webinar_panelist_list(filter_key(args, :webinar_id)) }.to raise_error(Zoom::ParameterMissing, [:webinar_id].to_s) end - it 'returns a list of panelists as an array' do - expect(zc.webinar_panelist_list(args)['panelists']).to be_kind_of(Array) + it "returns a list of panelists as an array" do + expect(zc.webinar_panelist_list(args)["panelists"]).to be_kind_of(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/webinars/#{args[:webinar_id]}/panelists") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.webinar_panelist_list(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/webinar/panelists_delete_all_spec.rb b/spec/lib/zoom/actions/webinar/panelists_delete_all_spec.rb index 891f3739..650d5314 100644 --- a/spec/lib/zoom/actions/webinar/panelists_delete_all_spec.rb +++ b/spec/lib/zoom/actions/webinar/panelists_delete_all_spec.rb @@ -1,45 +1,44 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { webinar_id: '123456789' } } + let(:args) { {webinar_id: "123456789"} } - describe '#webinar_panelists_delete_all' do - context 'with a valid response' do + describe "#webinar_panelists_delete_all" do + context "with a valid response" do before :each do stub_request( :delete, zoom_url("/webinars/#{args[:webinar_id]}/panelists") ).to_return(status: 204, - body: json_response('webinar', 'panelist_delete_all'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("webinar", "panelist_delete_all"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'webinar id' argument" do expect { zc.webinar_panelists_delete_all(filter_key(args, :webinar_id)) }.to raise_error(Zoom::ParameterMissing, [:webinar_id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.webinar_panelists_delete_all(args)).to eql(204) end - end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :delete, zoom_url("/webinars/#{args[:webinar_id]}/panelists") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.webinar_panelist_delete(args) }.to raise_error(Zoom::Error) end end end -end \ No newline at end of file +end diff --git a/spec/lib/zoom/actions/webinar/past_webinar_absentees_spec.rb b/spec/lib/zoom/actions/webinar/past_webinar_absentees_spec.rb index 736e3fbe..ebeebc12 100644 --- a/spec/lib/zoom/actions/webinar/past_webinar_absentees_spec.rb +++ b/spec/lib/zoom/actions/webinar/past_webinar_absentees_spec.rb @@ -1,40 +1,40 @@ -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { webinar_uuid: '123456789' } } + let(:args) { {webinar_uuid: "123456789"} } - describe '#past_webinars_absentees' do - context 'with a valid response' do + describe "#past_webinars_absentees" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/past_webinars/#{args[:webinar_uuid]}/absentees") ).to_return(status: 200, - body: json_response('webinar', 'past_webinars_absentees'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("webinar", "past_webinars_absentees"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'uuid' argument" do expect { zc.past_webinars_absentees(filter_key(args, :webinar_uuid)) }.to raise_error(Zoom::ParameterMissing, [:webinar_uuid].to_s) end - it 'returns a webinar instance with registrants as an array' do - expect(zc.past_webinars_absentees(args)['registrants']).to be_kind_of(Array) + it "returns a webinar instance with registrants as an array" do + expect(zc.past_webinars_absentees(args)["registrants"]).to be_kind_of(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/past_webinars/#{args[:webinar_uuid]}/absentees") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.past_webinars_absentees(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/webinar/past_webinar_list_spec.rb b/spec/lib/zoom/actions/webinar/past_webinar_list_spec.rb index 55169544..ba6038a9 100644 --- a/spec/lib/zoom/actions/webinar/past_webinar_list_spec.rb +++ b/spec/lib/zoom/actions/webinar/past_webinar_list_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { id: '123456789' } } + let(:args) { {id: "123456789"} } - describe '#past_webinar_list' do - context 'with a valid response' do + describe "#past_webinar_list" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/past_webinars/#{args[:id]}/instances") ).to_return(status: 200, - body: json_response('webinar', 'past_webinar_list'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("webinar", "past_webinar_list"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'id' argument" do expect { zc.past_webinar_list(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end - it 'returns a list of webinar instances as an array' do - expect(zc.past_webinar_list(args)['webinars']).to be_kind_of(Array) + it "returns a list of webinar instances as an array" do + expect(zc.past_webinar_list(args)["webinars"]).to be_kind_of(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/past_webinars/#{args[:id]}/instances") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.past_webinar_list(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/webinar/poll_get_spec.rb b/spec/lib/zoom/actions/webinar/poll_get_spec.rb index 98c3e5a3..b849687d 100644 --- a/spec/lib/zoom/actions/webinar/poll_get_spec.rb +++ b/spec/lib/zoom/actions/webinar/poll_get_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { webinar_id: 'foo', poll_id: 'bar' } } + let(:args) { {webinar_id: "foo", poll_id: "bar"} } - describe '#webinar_poll_get' do - context 'with a valid response' do + describe "#webinar_poll_get" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/webinars/#{args[:webinar_id]}/polls/#{args[:poll_id]}") ).to_return(status: :ok, - body: json_response('webinar', 'poll_get'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("webinar", "poll_get"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'webinar_id' argument" do @@ -25,21 +25,21 @@ expect { zc.webinar_poll_get(filter_key(args, :poll_id)) }.to raise_error(Zoom::ParameterMissing, [:poll_id].to_s) end - it 'returns a hash' do + it "returns a hash" do expect(zc.webinar_poll_get(args)).to be_a(Hash) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/webinars/#{args[:webinar_id]}/polls/#{args[:poll_id]}") - ).to_return(body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.webinar_poll_get(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/webinar/polls_list_spec.rb b/spec/lib/zoom/actions/webinar/polls_list_spec.rb index c50cca64..94b85eda 100644 --- a/spec/lib/zoom/actions/webinar/polls_list_spec.rb +++ b/spec/lib/zoom/actions/webinar/polls_list_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { webinar_id: '123456789' } } + let(:args) { {webinar_id: "123456789"} } - describe '#webinar_polls_list' do - context 'with a valid response' do + describe "#webinar_polls_list" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/webinars/#{args[:webinar_id]}/polls") ).to_return(status: :ok, - body: json_response('webinar', 'polls_list'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("webinar", "polls_list"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'webinar_id' argument" do expect { zc.webinar_polls_list(filter_key(args, :webinar_id)) }.to raise_error(Zoom::ParameterMissing, [:webinar_id].to_s) end - it 'returns the http status code as a number' do - expect(zc.webinar_polls_list(args)['polls']).to be_an(Array) + it "returns the http status code as a number" do + expect(zc.webinar_polls_list(args)["polls"]).to be_an(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/webinars/#{args[:webinar_id]}/polls") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.webinar_polls_list(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/webinar/questions_spec.rb b/spec/lib/zoom/actions/webinar/questions_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/webinar/questions_spec.rb +++ b/spec/lib/zoom/actions/webinar/questions_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/webinar/register_spec.rb b/spec/lib/zoom/actions/webinar/register_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/webinar/register_spec.rb +++ b/spec/lib/zoom/actions/webinar/register_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/webinar/registrants/add_spec.rb b/spec/lib/zoom/actions/webinar/registrants/add_spec.rb index 809529d8..dc2e7a3f 100644 --- a/spec/lib/zoom/actions/webinar/registrants/add_spec.rb +++ b/spec/lib/zoom/actions/webinar/registrants/add_spec.rb @@ -1,23 +1,25 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { id: 'webinar_id', - first_name: 'Zoomie', - last_name: 'Userton', - email: 'foo@bar.com' } } + let(:args) { + {id: "webinar_id", + first_name: "Zoomie", + last_name: "Userton", + email: "foo@bar.com"} + } - describe '#webinar_registrant_add' do - context 'with a valid response' do + describe "#webinar_registrant_add" do + context "with a valid response" do before :each do stub_request( :post, zoom_url("/webinars/#{args[:id]}/registrants") ).to_return(status: 201, - body: json_response('webinar', 'registrant', 'add'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("webinar", "registrant", "add"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'id' argument" do @@ -36,27 +38,27 @@ expect { zc.webinar_registrant_add(filter_key(args, :email)) }.to raise_error(Zoom::ParameterMissing, [:email].to_s) end - it 'returns an Hash' do + it "returns an Hash" do expect(zc.webinar_registrant_add(args)).to be_kind_of(Hash) end it 'returns a "join_url"' do res = zc.webinar_registrant_add(args) - expect(res['join_url']).not_to be nil + expect(res["join_url"]).not_to be nil end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :post, zoom_url("/webinars/#{args[:id]}/registrants") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.webinar_registrant_add(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/webinar/registrants/get_spec.rb b/spec/lib/zoom/actions/webinar/registrants/get_spec.rb index 4e3db08c..f895f38c 100644 --- a/spec/lib/zoom/actions/webinar/registrants/get_spec.rb +++ b/spec/lib/zoom/actions/webinar/registrants/get_spec.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { webinar_id: 'webinar_id', id: 'registrant_id' } } + let(:args) { {webinar_id: "webinar_id", id: "registrant_id"} } - describe '#webinar_registrant_get' do - context 'with a valid response' do + describe "#webinar_registrant_get" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/webinars/#{args[:webinar_id]}/registrants/#{args[:id]}") - ).to_return(body: json_response('webinar', 'registrant', 'get'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("webinar", "registrant", "get"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'webinar_id' argument" do @@ -23,25 +23,25 @@ expect { zc.webinar_registrant_get(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end it "allows occurrence_id" do - expect { zc.webinar_registrant_get(args.merge(:occurrence_id => '5')) }.not_to raise_error + expect { zc.webinar_registrant_get(args.merge(occurrence_id: "5")) }.not_to raise_error end - it 'returns an Hash' do + it "returns an Hash" do expect(zc.webinar_registrant_get(args)).to be_kind_of(Hash) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/webinars/#{args[:webinar_id]}/registrants/#{args[:id]}") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.webinar_registrant_get(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/webinar/registrants/list_spec.rb b/spec/lib/zoom/actions/webinar/registrants/list_spec.rb index f439abb4..10e5b4b5 100644 --- a/spec/lib/zoom/actions/webinar/registrants/list_spec.rb +++ b/spec/lib/zoom/actions/webinar/registrants/list_spec.rb @@ -1,41 +1,41 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { id: 'webinar_id' } } + let(:args) { {id: "webinar_id"} } - describe '#webinar_registrants_list' do - context 'with a valid response' do + describe "#webinar_registrants_list" do + context "with a valid response" do before :each do stub_request( :get, zoom_url("/webinars/#{args[:id]}/registrants") - ).to_return(body: json_response('webinar', 'registrant', 'list'), - headers: { 'Content-Type' => 'application/json' }) + ).to_return(body: json_response("webinar", "registrant", "list"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'id' argument" do expect { zc.webinar_registrants_list(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end - it 'returns an Array of registrants' do - expect(zc.webinar_registrants_list(args)['registrants']).to be_kind_of(Array) + it "returns an Array of registrants" do + expect(zc.webinar_registrants_list(args)["registrants"]).to be_kind_of(Array) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :get, zoom_url("/webinars/#{args[:id]}/registrants") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.webinar_registrants_list(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/webinar/registrants/update_status_spec.rb b/spec/lib/zoom/actions/webinar/registrants/update_status_spec.rb index acfe0930..248db014 100644 --- a/spec/lib/zoom/actions/webinar/registrants/update_status_spec.rb +++ b/spec/lib/zoom/actions/webinar/registrants/update_status_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { id: 'webinar_id', action: 'approve' } } + let(:args) { {id: "webinar_id", action: "approve"} } - describe '#webinar_registrants_status_update' do - context 'with a valid response' do + describe "#webinar_registrants_status_update" do + context "with a valid response" do before :each do stub_request( :put, @@ -24,17 +24,17 @@ end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :put, zoom_url("/webinars/#{args[:id]}/registrants/status") ).to_return(status: 404, - body: json_response('error', 'validation'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "validation"), + headers: {"Content-Type" => "application/json"}) end - it 'raises Zoom::Error exception' do + it "raises Zoom::Error exception" do expect { zc.webinar_registrants_status_update(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/webinar/registration_cancel_spec.rb b/spec/lib/zoom/actions/webinar/registration_cancel_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/webinar/registration_cancel_spec.rb +++ b/spec/lib/zoom/actions/webinar/registration_cancel_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/webinar/registration_spec.rb b/spec/lib/zoom/actions/webinar/registration_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/webinar/registration_spec.rb +++ b/spec/lib/zoom/actions/webinar/registration_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions/webinar/update_spec.rb b/spec/lib/zoom/actions/webinar/update_spec.rb index 9d0b20ab..2395c07f 100644 --- a/spec/lib/zoom/actions/webinar/update_spec.rb +++ b/spec/lib/zoom/actions/webinar/update_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions::Webinar do let(:zc) { zoom_client } - let(:args) { { id: '123456789' } } + let(:args) { {id: "123456789"} } - describe '#webinar_update' do - context 'with a valid response' do + describe "#webinar_update" do + context "with a valid response" do before :each do stub_request( :patch, zoom_url("/webinars/#{args[:id]}") ).to_return(status: 204, - body: json_response('webinar', 'update'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("webinar", "update"), + headers: {"Content-Type" => "application/json"}) end it "requires a 'id' argument" do expect { zc.webinar_update(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s) end - it 'returns the http status code as a number' do + it "returns the http status code as a number" do expect(zc.webinar_update(args)).to eql(204) end end - context 'with a 4xx response' do + context "with a 4xx response" do before :each do stub_request( :patch, zoom_url("/webinars/#{args[:id]}") ).to_return(status: 404, - body: json_response('error', 'not_found'), - headers: { 'Content-Type' => 'application/json' }) + body: json_response("error", "not_found"), + headers: {"Content-Type" => "application/json"}) end - it 'raises an error' do + it "raises an error" do expect { zc.webinar_update(args) }.to raise_error(Zoom::Error) end end diff --git a/spec/lib/zoom/actions/webinar/uuid_list_spec.rb b/spec/lib/zoom/actions/webinar/uuid_list_spec.rb index 833fee58..6ef4f13b 100644 --- a/spec/lib/zoom/actions/webinar/uuid_list_spec.rb +++ b/spec/lib/zoom/actions/webinar/uuid_list_spec.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spec_helper' \ No newline at end of file +require "spec_helper" diff --git a/spec/lib/zoom/actions_spec.rb b/spec/lib/zoom/actions_spec.rb index 5cb9379c..14a6e195 100644 --- a/spec/lib/zoom/actions_spec.rb +++ b/spec/lib/zoom/actions_spec.rb @@ -1,28 +1,28 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Actions do - let(:client) { Zoom::Client::OAuth.new(access_token: 'xxx', timeout: 15) } - let(:path) { '/:id/foo/:bar' } + let(:client) { Zoom::Client::OAuth.new(access_token: "xxx", timeout: 15) } + let(:path) { "/:id/foo/:bar" } let(:path_keys) { [:id, :bar] } - let(:params) { { id: 100, bar: 'baz' } } + let(:params) { {id: 100, bar: "baz"} } let(:oauth) { false } - let(:parsed_path) { '/100/foo/baz' } + let(:parsed_path) { "/100/foo/baz" } - describe 'self.extract_path_keys' do + describe "self.extract_path_keys" do subject { described_class.extract_path_keys(path) } it { is_expected.to match_array(path_keys) } end - describe 'self.parse_path' do + describe "self.parse_path" do subject { described_class.parse_path(path, path_keys, params) } it { is_expected.to eq(parsed_path) } end - describe 'self.make_request' do + describe "self.make_request" do subject do described_class.make_request({ client: client, method: method, parsed_path: parsed_path, @@ -32,81 +32,74 @@ let(:request_options) { Zoom::Actions.determine_request_options(client, oauth) } - before :each do - Zoom.configure do |config| - config.api_key = 'xxx' - config.api_secret = 'xxx' - end - end - - context 'when get' do + context "when get" do let(:method) { :get } - it 'calls get method on client with get request_options' do + it "calls get method on client with get request_options" do request_options[:query] = params expect(client.class).to receive(method).with(parsed_path, **request_options) subject end end - context 'when post' do + context "when post" do let(:method) { :post } - it 'calls post method on client with post request_options' do + it "calls post method on client with post request_options" do request_options[:body] = params.to_json expect(client.class).to receive(method).with(parsed_path, **request_options) subject end end - context 'when put' do + context "when put" do let(:method) { :put } - it 'calls put method on client with put request_options' do + it "calls put method on client with put request_options" do request_options[:body] = params.to_json expect(client.class).to receive(method).with(parsed_path, **request_options) subject end end - context 'when patch' do + context "when patch" do let(:method) { :patch } - it 'calls patch method on client with patch request_options' do + it "calls patch method on client with patch request_options" do request_options[:body] = params.to_json expect(client.class).to receive(method).with(parsed_path, **request_options) subject end end - context 'when delete' do + context "when delete" do let(:method) { :delete } - it 'calls delete method on client with delete request_options' do + it "calls delete method on client with delete request_options" do request_options[:query] = params expect(client.class).to receive(method).with(parsed_path, **request_options) subject end end - context 'when oauth' do + context "when oauth" do let(:method) { :get } let(:oauth) { true } - it 'passes oauth request options' do + it "passes oauth request options" do request_options[:query] = params expect(request_options[:headers]).to eq(client.oauth_request_headers) - expect(request_options[:base_uri]).to eq('https://zoom.us/') + expect(request_options[:base_uri]).to eq("https://zoom.us/") expect(client.class).to receive(method).with(parsed_path, **request_options) subject end end - context 'when not oauth' do + context "when not oauth" do let(:method) { :get } let(:oauth) { false } - it 'passes standard request options' do + it "passes standard request options" do request_options[:query] = params expect(request_options[:headers]).to eq(client.request_headers) expect(request_options[:base_uri]).to be_nil diff --git a/spec/lib/zoom/client_spec.rb b/spec/lib/zoom/client_spec.rb index 9c50bf89..63f8afc1 100644 --- a/spec/lib/zoom/client_spec.rb +++ b/spec/lib/zoom/client_spec.rb @@ -1,154 +1,126 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Zoom::Client do + describe "default attributes" do + after :each do + Zoom.configuration = nil + end - describe 'default attributes' do - it 'must include httparty methods' do + it "must include httparty methods" do expect(Zoom::Client).to include(HTTParty) - expect(Zoom::Client::JWT).to include(HTTParty) + expect(Zoom::Client::ServerToServerOAuth).to include(HTTParty) end - it 'must have the base url set to Zoom API endpoint' do - expect(Zoom::Client.base_uri).to eq('https://api.zoom.us/v2') + it "must have the base url set to Zoom API endpoint" do + expect(Zoom::Client.base_uri).to eq("https://api.zoom.us/v2") end - it 'must have a default timeout set to 15 seconds' do - Zoom.configure do |config| - config.api_key = 'xxx' - config.api_secret = 'xxx' - end + it "must have a default timeout set to 15 seconds" do Zoom.new - expect(Zoom::Client::JWT.default_options[:timeout]).to eq(15) - Zoom.configuration = nil + expect(Zoom::Client::ServerToServerOAuth.default_options[:timeout]).to eq(15) end - it 'must get the timeout from the configuration' do + it "must get the timeout from the configuration" do Zoom.configure do |config| - config.api_key = 'xxx' - config.api_secret = 'xxx' config.timeout = 20 end Zoom.new - expect(Zoom::Client::JWT.default_options[:timeout]).to eq(20) - Zoom.configuration = nil + expect(Zoom::Client::ServerToServerOAuth.default_options[:timeout]).to eq(20) end end - describe 'JWT client' do - let(:client) { - Zoom::Client::JWT.new(api_key: 'xxx', api_secret: 'xxx', timeout: 15) - } - it 'requires api_key and api_secret for a new instance' do - expect { Zoom::Client::JWT.new(api_key: 'xxx') }.to raise_error(Zoom::ParameterMissing) - expect { Zoom::Client::JWT.new(api_key: 'xxx', api_secret: 'xxx') }.not_to raise_error - end - - it 'creates instance of Zoom::Client if api_key and api_secret is provided' do - expect(client).to be_kind_of(Zoom::Client) - end - - it 'has the bearer token in the auth header' do - fake_token = 'NotTheRealToken' - allow(client).to receive(:access_token) {fake_token} - expect(client.request_headers['Authorization']).to eq("Bearer #{fake_token}") - end - - end - - describe 'OAuth client' do - let(:access_token) {'xxx'} - let(:refresh_token) {'xxx'} - let(:auth_token) {'xxx'} + describe "OAuth client" do + let(:access_token) { "xxx" } + let(:refresh_token) { "xxx" } + let(:auth_token) { "xxx" } let(:client) { Zoom::Client::OAuth.new(access_token: access_token, timeout: 30) } - it 'raises an error if there is no token' do + it "raises an error if there is no token" do expect { Zoom::Client::OAuth.new(timeout: 30) }.to raise_error(Zoom::ParameterMissing) end - it 'raises an error if there is no complete auth token, auth code and redirect_uri' do - expect { Zoom::Client::OAuth.new(auth_token: 'xxx', auth_code: 'xxx', redirect_uri: 'xxx') }.not_to raise_error + it "raises an error if there is no complete auth token, auth code and redirect_uri" do + expect { Zoom::Client::OAuth.new(auth_token: "xxx", auth_code: "xxx", redirect_uri: "xxx") }.not_to raise_error end - it 'requires atleast an access token' do + it "requires atleast an access token" do expect { Zoom::Client::OAuth.new(access_token: access_token) }.not_to raise_error end - it 'requires atleast a refresh token' do + it "requires atleast a refresh token" do expect { Zoom::Client::OAuth.new(refresh_token: refresh_token) }.not_to raise_error end - it 'creates instance of Zoom::Client if api_key and api_secret is provided' do + it "creates instance of Zoom::Client if api_key and api_secret is provided" do expect(client).to be_kind_of(Zoom::Client) end - it 'has the bearer token in the auth header' do - expect(client.request_headers['Authorization']).to eq("Bearer #{access_token}") + it "has the bearer token in the auth header" do + expect(client.request_headers["Authorization"]).to eq("Bearer #{access_token}") end - describe 'set_tokens' do + describe "set_tokens" do let(:zc) { oauth_client } - let(:args) { { auth_code: 'xxx', redirect_uri: 'http://localhost:3000' } } + let(:args) { {auth_code: "xxx", redirect_uri: "http://localhost:3000"} } before :each do Zoom.configure do |config| - config.api_key = 'xxx' - config.api_secret = 'xxx' config.timeout = 20 end stub_request( :post, - zoom_auth_url('oauth/token') - ).to_return(body: json_response('token', 'access_token'), - headers: { 'Content-Type' => 'application/json' }) + zoom_auth_url("oauth/token") + ).to_return(body: json_response("token", "access_token"), + headers: {"Content-Type" => "application/json"}) end - it 'sets the refresh_token, access_token, expires_in and expires_at' do - expected_values = JSON.parse(json_response('token', 'access_token')) + it "sets the refresh_token, access_token, expires_in and expires_at" do + expected_values = JSON.parse(json_response("token", "access_token")) zc.auth - expect(zc.access_token).to eq(expected_values['access_token']) - expect(zc.refresh_token).to eq(expected_values['refresh_token']) - expect(zc.expires_in).to eq(expected_values['expires_in']) - expect(zc.expires_at).to eq((Time.now + expected_values['expires_in']).to_i) + expect(zc.access_token).to eq(expected_values["access_token"]) + expect(zc.refresh_token).to eq(expected_values["refresh_token"]) + expect(zc.expires_in).to eq(expected_values["expires_in"]) + expect(zc.expires_at).to eq((Time.now + expected_values["expires_in"]).to_i) end - it 'has the basic auth authorization header' do - expect(zc.oauth_request_headers['Authorization']).to eq("Basic eHh4Onh4eA==") + it "has the basic auth authorization header" do + expect(zc.oauth_request_headers["Authorization"]).to eq("Basic eHh4Onh4eA==") end end end - describe 'ServerToServerOAuth client' do - let(:access_token) {'xxx'} + describe "ServerToServerOAuth client" do + let(:access_token) { "xxx" } let(:client) do Zoom::Client::ServerToServerOAuth.new(access_token: access_token, timeout: 30) end - it 'raises an error if there is no arguments' do + it "raises an error if there is no arguments" do expect { Zoom::Client::ServerToServerOAuth.new(timeout: 30) }.to raise_error(Zoom::ParameterMissing) end - it 'requires at least an access token' do + it "requires at least an access token" do expect { Zoom::Client::ServerToServerOAuth.new(access_token: access_token) }.not_to raise_error end - it 'requires at least an account_id' do + it "requires at least an account_id" do expect { Zoom::Client::ServerToServerOAuth.new(access_token: access_token) }.not_to raise_error end - it 'creates instance of Zoom::Client if api_key and api_secret is provided' do + it "creates instance of Zoom::Client if api_key and api_secret is provided" do expect(client).to be_kind_of(Zoom::Client) end - it 'has the bearer token in the auth header' do - expect(client.request_headers['Authorization']).to eq("Bearer #{access_token}") + it "has the bearer token in the auth header" do + expect(client.request_headers["Authorization"]).to eq("Bearer #{access_token}") end - describe 'set_tokens' do - let(:client) { Zoom::Client::ServerToServerOAuth.new(account_id: 'xxx') } + describe "set_tokens" do + let(:client) { Zoom::Client::ServerToServerOAuth.new(account_id: "xxx") } before :each do Zoom.configure do |config| @@ -157,30 +129,30 @@ stub_request( :post, - zoom_auth_url('oauth/token') - ).to_return(body: json_response('token', 'access_token'), - headers: { 'Content-Type' => 'application/json' }) + zoom_auth_url("oauth/token") + ).to_return(body: json_response("token", "access_token"), + headers: {"Content-Type" => "application/json"}) end - it 'sets the access_token, expires_in and expires_at' do - expected_values = JSON.parse(json_response('token', 'access_token')) + it "sets the access_token, expires_in and expires_at" do + expected_values = JSON.parse(json_response("token", "access_token")) client.auth - expect(client.access_token).to eq(expected_values['access_token']) - expect(client.expires_in).to eq(expected_values['expires_in']) - expect(client.expires_at).to eq((Time.now + expected_values['expires_in']).to_i) + expect(client.access_token).to eq(expected_values["access_token"]) + expect(client.expires_in).to eq(expected_values["expires_in"]) + expect(client.expires_at).to eq((Time.now + expected_values["expires_in"]).to_i) end - context 'when client_id and client_secret is not provided' do - it 'has the basic auth authorization header based on api_key and api_secret' do - expect(client.oauth_request_headers['Authorization']).to eq("Basic eHh4Onh4eA==") + context "when client_id and client_secret is not provided" do + it "has the basic auth authorization header based on api_key and api_secret" do + expect(client.oauth_request_headers["Authorization"]).to eq("Basic eHh4Onh4eA==") end end - context 'when client_id and client_secret are provided' do - let(:client) { Zoom::Client::ServerToServerOAuth.new(account_id: 'xxx', client_id: 'yyy', client_secret: 'yyy') } + context "when client_id and client_secret are provided" do + let(:client) { Zoom::Client::ServerToServerOAuth.new(account_id: "xxx", client_id: "yyy", client_secret: "yyy") } - it 'has the basic auth authorization header based on client_id and client_secret' do - expect(client.oauth_request_headers['Authorization']).to eq("Basic eXl5Onl5eQ==") + it "has the basic auth authorization header based on client_id and client_secret" do + expect(client.oauth_request_headers["Authorization"]).to eq("Basic eXl5Onl5eQ==") end end end diff --git a/spec/lib/zoom/errors_spec.rb b/spec/lib/zoom/errors_spec.rb index 36f3685f..1e0b6e9b 100644 --- a/spec/lib/zoom/errors_spec.rb +++ b/spec/lib/zoom/errors_spec.rb @@ -1,30 +1,28 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Zoom::Error do let(:rescue?) { false } subject do - begin - raise Zoom::ParameterMissing, "msg" - rescue Zoom::Error => error - if rescue? - true - else - raise error - end + raise Zoom::ParameterMissing, "msg" + rescue Zoom::Error => error + if rescue? + true + else + raise error end end - it 'raises specific errors' do + it "raises specific errors" do expect { subject }.to raise_error(Zoom::ParameterMissing, "msg") end - context 'with errors rescued' do + context "with errors rescued" do let(:rescue?) { true } - it 'descends from Zoom::Error' do + it "descends from Zoom::Error" do expect(subject).to be true end end diff --git a/spec/lib/zoom/params_spec.rb b/spec/lib/zoom/params_spec.rb index 3005e6b7..dd5d72be 100644 --- a/spec/lib/zoom/params_spec.rb +++ b/spec/lib/zoom/params_spec.rb @@ -1,117 +1,116 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Zoom::Params do - - describe '#require' do + describe "#require" do let(:params) { Zoom::Params.new(foo: :bar, baz: :bang) } - it 'does not raise an error when required keys are present' do + it "does not raise an error when required keys are present" do expect { params.require(:foo) }.not_to raise_error end - it 'does raise an error when required keys are missing' do + it "does raise an error when required keys are missing" do expect { params.require(:bar) }.to raise_error(Zoom::ParameterMissing, [:bar].to_s) end - it 'returns the rest of the params' do + it "returns the rest of the params" do expect(params.require(:foo)).to eql(baz: :bang) end end - describe '#require_one_of' do + describe "#require_one_of" do let(:params) { Zoom::Params.new(foo: :bar, baz: :bang) } - it 'does raise an error when required keys are missing' do + it "does raise an error when required keys are missing" do expect { params.require_one_of(:bar) }.to raise_error(Zoom::ParameterMissing, [:bar].to_s) end - it 'does raise an error when there is a missing required keys out of many' do - expect { params.require_one_of(:bar, :fooey, :fooa) }.to raise_error(Zoom::ParameterMissing, "You are missing atleast one of #{[:bar, :fooey, :fooa].to_s}") + it "does raise an error when there is a missing required keys out of many" do + expect { params.require_one_of(:bar, :fooey, :fooa) }.to raise_error(Zoom::ParameterMissing, "You are missing atleast one of [:bar, :fooey, :fooa]") end - it 'does not raise an error when one of the required keys are missing' do + it "does not raise an error when one of the required keys are missing" do expect { params.require_one_of(:foo) }.not_to raise_error end - it 'does not raise an error when one of the required keys are missing' do + it "does not raise an error when one of the required keys are missing" do expect { params.require_one_of(:foo, :bebop) }.not_to raise_error end end - describe '#permit' do - let(:params) { Zoom::Params.new(foo: true, bar: :baz ) } + describe "#permit" do + let(:params) { Zoom::Params.new(foo: true, bar: :baz) } - it 'does not raise an error when permitted keys are present' do + it "does not raise an error when permitted keys are present" do expect { params.require(:foo).permit(:bar) }.not_to raise_error end - it 'does not raise an error when permitted keys are not present' do + it "does not raise an error when permitted keys are not present" do expect { params.require(:foo).permit(:bar, :bang) }.not_to raise_error end - context 'raises an error' do + context "raises an error" do let(:bad_params) { Zoom::Params.new(foo: true, bar: :baz, bang: :boom) } let(:other_bad_params) do - Zoom::Params.new(foo: true, bar: { baz: :bang, - boom: :pow, - asdf: :test, - testerino: :other }) + Zoom::Params.new(foo: true, bar: {baz: :bang, + boom: :pow, + asdf: :test, + testerino: :other}) end let(:really_bad_params) do Zoom::Params.new(foo: true, - bar: { - baz: { - bang: { - nested: true, - this: :thing, - is: { very: :deep }, - bad_param: :asdf - } - } - }) + bar: { + baz: { + bang: { + nested: true, + this: :thing, + is: {very: :deep}, + bad_param: :asdf + } + } + }) end - it 'when non-permitted keys are present' do + it "when non-permitted keys are present" do expect { bad_params.require(:foo).permit(:bar) }.to raise_error(Zoom::ParameterNotPermitted, [:bang].to_s) end - it 'when nested non-permitted keys are present' do + it "when nested non-permitted keys are present" do expect { other_bad_params.require(:foo).permit(bar: [:baz, :boom]) }.to raise_error(Zoom::ParameterNotPermitted, [:asdf, :testerino].to_s) end - it 'when deeply nested non-permitted keys are present' do - expect { really_bad_params.require(:foo).permit(bar: { baz: { bang: [ :nested, :this, { is: :very } ] } }) }.to raise_error(Zoom::ParameterNotPermitted, [:bad_param].to_s) + it "when deeply nested non-permitted keys are present" do + expect { really_bad_params.require(:foo).permit(bar: {baz: {bang: [:nested, :this, {is: :very}]}}) }.to raise_error(Zoom::ParameterNotPermitted, [:bad_param].to_s) end end end - describe '#permit_value' do + describe "#permit_value" do let(:params) { Zoom::Params.new(foo: :bar, baz: :bang) } - let(:values) { %i(bar baz) } + let(:values) { %i[bar baz] } - it 'does not raise an error when required value are present in values' do + it "does not raise an error when required value are present in values" do expect { params.permit_value(:foo, values) }.not_to raise_error end - it 'does raise an error when required keys are missing' do - expect { params.permit_value(:baz, values) }.to raise_error(Zoom::ParameterValueNotPermitted, "#{:baz.to_s}: #{:bang.to_s}") + it "does raise an error when required keys are missing" do + expect { params.permit_value(:baz, values) }.to raise_error(Zoom::ParameterValueNotPermitted, "baz: bang") end end - describe '#parameters_keys' do - context 'when param is array ' do + describe "#parameters_keys" do + context "when param is array " do let(:params) { Zoom::Params.new([{foo: :bar, baz: :bang}, {foo: :bar1, baz: :bang1}]) } - - it 'get each object keys and return unique of them' do + + it "get each object keys and return unique of them" do expect(params.parameters_keys).to eq([:foo, :baz]) end end - - context 'when param is Hash ' do + + context "when param is Hash " do let(:params) { Zoom::Params.new({foo: :bar, baz: :bang}) } - - it 'return hash keys' do + + it "return hash keys" do expect(params.parameters_keys).to eq([:foo, :baz]) end end diff --git a/spec/lib/zoom/utils_spec.rb b/spec/lib/zoom/utils_spec.rb index 5ed15264..ac3057b1 100644 --- a/spec/lib/zoom/utils_spec.rb +++ b/spec/lib/zoom/utils_spec.rb @@ -1,93 +1,90 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" -describe Zoom::Utils do - - before(:all) do - class Utils < Zoom::Utils; end - end +class Utils < Zoom::Utils; end - describe '#argument_error' do - it 'raises ArgumentError' do - expect(Utils.argument_error('foo')).to be_instance_of(ArgumentError) +describe Zoom::Utils do + describe "#argument_error" do + it "raises ArgumentError" do + expect(Utils.argument_error("foo")).to be_instance_of(ArgumentError) end end - describe '#raise_if_error!' do - it 'raises Zoom::AuthenticationError if error is present and code = 124' do - response = { 'code' => 124, 'message' => 'Authentication error.' } + describe "#raise_if_error!" do + it "raises Zoom::AuthenticationError if error is present and code = 124" do + response = {"code" => 124, "message" => "Authentication error."} expect { Utils.raise_if_error!(response) }.to raise_error(Zoom::AuthenticationError) end - it 'raises Zoom::BadRequest if error is present and code = 400' do - response = { 'code' => 400, 'message' => 'Bas request.' } + it "raises Zoom::BadRequest if error is present and code = 400" do + response = {"code" => 400, "message" => "Bas request."} expect { Utils.raise_if_error!(response) }.to raise_error(Zoom::BadRequest) end - it 'raises Zoom::Unauthorized if error is present and code = 401' do - response = { 'code' => 401, 'message' => 'Unauthorized.' } + it "raises Zoom::Unauthorized if error is present and code = 401" do + response = {"code" => 401, "message" => "Unauthorized."} expect { Utils.raise_if_error!(response) }.to raise_error(Zoom::Unauthorized) end - it 'raises Zoom::Forbidden if error is present and code = 403' do - response = { 'code' => 403, 'message' => 'Forbidden.' } + it "raises Zoom::Forbidden if error is present and code = 403" do + response = {"code" => 403, "message" => "Forbidden."} expect { Utils.raise_if_error!(response) }.to raise_error(Zoom::Forbidden) end - it 'raises Zoom::NotFound if error is present and code = 404' do - response = { 'code' => 404, 'message' => 'NotFound.' } + it "raises Zoom::NotFound if error is present and code = 404" do + response = {"code" => 404, "message" => "NotFound."} expect { Utils.raise_if_error!(response) }.to raise_error(Zoom::NotFound) end - it 'raises Zoom::Conflict if error is present and code = 409' do - response = { 'code' => 409, 'message' => 'Conflict.' } + it "raises Zoom::Conflict if error is present and code = 409" do + response = {"code" => 409, "message" => "Conflict."} expect { Utils.raise_if_error!(response) }.to raise_error(Zoom::Conflict) end - it 'raises Zoom::TooManyRequests if error is present and code = 429' do - response = { 'code' => 429, 'message' => 'Too many requests.' } + it "raises Zoom::TooManyRequests if error is present and code = 429" do + response = {"code" => 429, "message" => "Too many requests."} expect { Utils.raise_if_error!(response) }.to raise_error(Zoom::TooManyRequests) end - it 'raises Zoom::InternalServerError if error is present and code = 500' do - response = { 'code' => 500, 'message' => 'Internal server error.' } + it "raises Zoom::InternalServerError if error is present and code = 500" do + response = {"code" => 500, "message" => "Internal server error."} expect { Utils.raise_if_error!(response) }.to raise_error(Zoom::InternalServerError) end - it 'does not raise Zoom::Error if error is not present' do + it "does not raise Zoom::Error if error is not present" do response = {} expect { Utils.raise_if_error!(response) }.to_not raise_error end - it 'does not raise Zoom::Error if response is not a Hash' do - response = 'xxx' + it "does not raise Zoom::Error if response is not a Hash" do + response = "xxx" expect { Utils.raise_if_error!(response) }.to_not raise_error end - it 'raises Zoom::Error if http code is not in [124, 400, 401, 403, 404, 429, 500]' do - response = { 'code' => 180, 'message' => 'lol error' } + it "raises Zoom::Error if http code is not in [124, 400, 401, 403, 404, 429, 500]" do + response = {"code" => 180, "message" => "lol error"} expect { Utils.raise_if_error!(response, 400) }.to raise_error(Zoom::Error) end end - describe '#extract_options!' do - it 'converts array to hash options' do - args = [{ foo: 'foo' }, { bar: 'bar' }, { zemba: 'zemba' }] + describe "#extract_options!" do + it "converts array to hash options" do + args = [{foo: "foo"}, {bar: "bar"}, {zemba: "zemba"}] expect(Utils.extract_options!(args)).to be_kind_of(Hash) end end - describe '#process_datetime_params' do - it 'converts the Time objects to formatted strings' do + describe "#process_datetime_params" do + it "converts the Time objects to formatted strings" do args = { - foo: 'foo', - bar: Time.utc(2000, 'jan', 1, 20, 15, 1) + foo: "foo", + bar: Time.utc(2000, "jan", 1, 20, 15, 1) } expect( Utils.process_datetime_params!(args) - ).to eq({ foo: 'foo', - bar: '2000-01-01T20:15:01Z' }) + ).to eq({foo: "foo", + bar: "2000-01-01T20:15:01Z"}) end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d1cb1fc9..fb62ba0b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,43 +1,43 @@ # frozen_string_literal: true -require 'simplecov' +require "simplecov" SimpleCov.start do - if ENV['CI'] - require 'simplecov-lcov' + if ENV["CI"] + require "simplecov-lcov" SimpleCov::Formatter::LcovFormatter.config do |c| c.report_with_single_file = true - c.single_report_path = 'coverage/lcov.info' + c.single_report_path = "coverage/lcov.info" end formatter SimpleCov::Formatter::LcovFormatter end - add_filter %w[version.rb] + add_filter %w[version.rb spec] end -require 'rubygems' -require 'bundler/setup' -require 'zoom_rb' -require 'webmock/rspec' +require "rubygems" +require "bundler/setup" +require "zoom_rb" +require "webmock/rspec" RSpec.configure do |config| # some (optional) config here end def fixture(*path, filename) - File.join('spec', 'fixtures', path, filename) + File.join("spec", "fixtures", path, filename) end def json_response(*path, endpoint) - open(fixture(path, endpoint + '.json')).read + open(fixture(path, endpoint + ".json")).read end def request_headers { - 'Accept' => 'application/json', - 'Content-Type' => 'application/json', - 'Authorization' => /Bearer .+/ + "Accept" => "application/json", + "Content-Type" => "application/json", + "Authorization" => /Bearer .+/ } end @@ -45,25 +45,21 @@ def zoom_url(url) /https:\/\/api.zoom.us\/v2#{url}.*/ end -#OAuth endpoints have a different base_uri +# OAuth endpoints have a different base_uri def zoom_auth_url(url) /https:\/\/zoom.us\/#{url}.*/ end -def jwt_client - Zoom.new -end - def oauth_client - Zoom::Client::OAuth.new(auth_token: 'xxx', auth_code: 'xxx', redirect_uri: 'xxx', timeout: 15) + Zoom::Client::OAuth.new(auth_token: "xxx", auth_code: "xxx", redirect_uri: "xxx", timeout: 15) end def server_to_server_oauth_client - Zoom::Client::ServerToServerOAuth.new(account_id: 'xxx') + Zoom.new end def zoom_client - jwt_client + server_to_server_oauth_client end def filter_key(hash, key) diff --git a/zoom_rb.gemspec b/zoom_rb.gemspec index c69d45fc..6cd7cd6d 100644 --- a/zoom_rb.gemspec +++ b/zoom_rb.gemspec @@ -2,33 +2,31 @@ lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'zoom/version' +require "zoom/version" Gem::Specification.new do |gem| + gem.add_dependency "httparty", ">= 0.13" + gem.add_dependency "json", ">= 1.8" - gem.add_dependency 'httparty', '>= 0.13' - gem.add_dependency 'json', '>= 1.8' - gem.add_dependency 'jwt' + gem.add_development_dependency "pry-byebug" + gem.add_development_dependency "standard", ">= 1.25.0" + gem.add_development_dependency "rubocop-rspec", ">= 2.19.0" + gem.add_development_dependency "rspec", ">= 3.8" + gem.add_development_dependency "rspec_junit_formatter", ">= 0.4.1" + gem.add_development_dependency "simplecov", ">= 0.22.0" + gem.add_development_dependency "simplecov-lcov", ">= 0.8.0" + gem.add_development_dependency "webmock", ">= 3.4" - gem.add_development_dependency 'pry-byebug' - gem.add_development_dependency 'hint-rubocop_style' - gem.add_development_dependency 'rspec', '>= 3.8' - gem.add_development_dependency 'rspec_junit_formatter', '>= 0.4.1' - gem.add_development_dependency 'simplecov', '>= 0.22.0' - gem.add_development_dependency 'simplecov-lcov', '>= 0.8.0' - gem.add_development_dependency 'webmock', '>= 3.4' + gem.authors = ["Kyle Boe"] + gem.email = ["kyle@boe.codes"] + gem.description = "A Ruby API wrapper for zoom.us API" + gem.summary = "zoom.us API wrapper" + gem.homepage = "https://github.com/kyleboe/zoom_rb" + gem.licenses = ["MIT"] - gem.authors = ['Kyle Boe'] - gem.email = ['kyle@boe.codes'] - gem.description = 'A Ruby API wrapper for zoom.us API' - gem.summary = 'zoom.us API wrapper' - gem.homepage = 'https://github.com/hintmedia/zoom_rb' - gem.licenses = ['MIT'] - - gem.files = `git ls-files`.split($\) - gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) } - gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) - gem.name = 'zoom_rb' - gem.require_paths = ['lib'] - gem.version = Zoom::VERSION + gem.files = `git ls-files`.split($\) + gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) } + gem.name = "zoom_rb" + gem.require_paths = ["lib"] + gem.version = Zoom::VERSION end