From 8caa3543ecef1825dc978a4bc22a05565ec0af68 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 3 Sep 2021 16:56:39 -0700 Subject: [PATCH 01/29] Attempt refactor Creates lib/zoom/actions.rb (Zoom::ActionDefinitions). Reworks Zoom::Actions::Account to use new define_action method. --- lib/zoom/actions.rb | 42 +++++++++++++ lib/zoom/actions/account.rb | 117 +++++++++++++++++++++--------------- lib/zoom_rb.rb | 1 + 3 files changed, 110 insertions(+), 50 deletions(-) create mode 100644 lib/zoom/actions.rb diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb new file mode 100644 index 00000000..f5c5127e --- /dev/null +++ b/lib/zoom/actions.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Zoom + module ActionDefinitions + def self.parse_url(url, params) + parsed_url = url.dup + url.scan(/:\w+/).each do |match| + key = match[1..].to_sym + value = params[key].to_s + parsed_url = parsed_url.gsub(match, value) + end + parsed_url + end + + def self.make_request(obj, method, url, params, required_params) + request_options = { + headers: obj.request_headers + } + case method + when :get + request_options[:query] = required_params + when :post, :patch + request_options[:body] = required_params.to_json + end + parsed_url = Zoom::ActionDefinitions.parse_url(url, params) + obj.class.public_send(method, parsed_url, **request_options) + end + + def define_action(name, method, url, required: [], permitted: []) + required = [required] if required.is_a?(Symbol) + permitted = [permitted] if permitted.is_a?(Symbol) + + define_method(name) do |*args| + params = Zoom::Params.new(Utils.extract_options!(args)) + required_params = required.empty? ? params : params.require(required) + required_params.permit(permitted) unless permitted.empty? + response = Zoom::ActionDefinitions.make_request(self, method, url, params, required_params) + Utils.parse_response(response) + end + end + end +end diff --git a/lib/zoom/actions/account.rb b/lib/zoom/actions/account.rb index 7ebda142..5de7fbf7 100644 --- a/lib/zoom/actions/account.rb +++ b/lib/zoom/actions/account.rb @@ -3,65 +3,82 @@ module Zoom module Actions module Account - def account_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.permit(%i[page_size page_number]) - Utils.parse_response self.class.get('/accounts', query: params, headers: request_headers) - end + extend Zoom::ActionDefinitions - def account_create(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[first_name last_name email password]).permit(options: %i[share_rc room_connectors share_mc meeting_connectors pay_mode]) - Utils.parse_response self.class.post('/accounts', body: params.to_json, headers: request_headers) - end + def self.included(base) + define_action( + 'account_list', + :get, + '/accounts', + permitted: %i[page_size page_number] + ) - def account_get(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - Utils.parse_response self.class.get("/accounts/#{params[:account_id]}", headers: request_headers) - end + define_action( + 'account_create', + :post, + '/accounts', + required: %i[first_name last_name email password], + permitted: { options: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] } + ) - def account_delete(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - Utils.parse_response self.class.delete("/accounts/#{params[:account_id]}", headers: request_headers) - end + define_action( + 'account_get', + :get, + '/accounts/:account_id', + required: :account_id + ) - def account_options_update(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id).permit(%i[share_rc room_connectors share_mc meeting_connectors pay_mode]) - Utils.parse_response self.class.patch("/accounts/#{params[:account_id]}/options", body: params.except(:account_id).to_json, headers: request_headers) - end + define_action( + 'account_delete', + :delete, + '/accounts/:account_id', + required: :account_id + ) - def account_settings_get(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id).permit(:option) - Utils.parse_response self.class.get("/accounts/#{params[:account_id]}/settings", query: params.except(:account_id), headers: request_headers) - end + define_action( + 'account_options_update', + :patch, + '/accounts/:account_id/options', + required: :account_id, + permitted: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] + ) - def account_settings_update(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id).permit(:option, Zoom::Constants::Account::Settings::PERMITTED_KEYS) - params.permit_value(:option, Zoom::Constants::Account::Settings::PERMITTED_OPTIONS) - Utils.parse_response self.class.patch("/accounts/#{params[:account_id]}/settings", query: params.slice(:option), body: params.except(%i[account_id option]).to_json, headers: request_headers) - end + define_action( + 'account_settings_get', + :get, + '/accounts/:account_id/settings', + required: :account_id, + permitted: :option + ) - def account_managed_domains(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - Utils.parse_response self.class.get("/accounts/#{params[:account_id]}/managed_domains", headers: request_headers) - end + define_action( + 'account_settings_update', + :patch, + '/accounts/:account_id/settings', + required: :account_id, + permitted: [:option, Zoom::Constants::Account::Settings::PERMITTED_KEYS] + ) - def account_get_locked_settings(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - Utils.parse_response self.class.get("/accounts/#{params[:account_id]}/lock_settings", headers: request_headers) - end + define_action( + 'account_managed_domains', + :get, + '/accounts/:account_id/managed_domains', + required: :account_id + ) + + define_action( + 'account_get_locked_settings', + :get, + '/accounts/:account_id/lock_settings', + required: :account_id + ) - def account_trusted_domains(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - Utils.parse_response self.class.get("/accounts/#{params[:account_id]}/trusted_domains", headers: request_headers) + define_action( + 'account_trusted_domains', + :get, + '/accounts/:account_id/trusted_domains', + required: :account_id + ) end end end diff --git a/lib/zoom_rb.rb b/lib/zoom_rb.rb index e2a00067..5f6badef 100644 --- a/lib/zoom_rb.rb +++ b/lib/zoom_rb.rb @@ -6,6 +6,7 @@ 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' From 6e850e46a57c23e4dc807809f891dbbd10b18ee8 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 17 Sep 2021 14:21:37 -0700 Subject: [PATCH 02/29] Rename ActionDefinitions to Actions Makes more sense. --- lib/zoom/actions.rb | 6 +++--- lib/zoom/actions/account.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index f5c5127e..a8ef62f9 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Zoom - module ActionDefinitions + module Actions def self.parse_url(url, params) parsed_url = url.dup url.scan(/:\w+/).each do |match| @@ -22,7 +22,7 @@ def self.make_request(obj, method, url, params, required_params) when :post, :patch request_options[:body] = required_params.to_json end - parsed_url = Zoom::ActionDefinitions.parse_url(url, params) + parsed_url = Zoom::Actions.parse_url(url, params) obj.class.public_send(method, parsed_url, **request_options) end @@ -34,7 +34,7 @@ def define_action(name, method, url, required: [], permitted: []) params = Zoom::Params.new(Utils.extract_options!(args)) required_params = required.empty? ? params : params.require(required) required_params.permit(permitted) unless permitted.empty? - response = Zoom::ActionDefinitions.make_request(self, method, url, params, required_params) + response = Zoom::Actions.make_request(self, method, url, params, required_params) Utils.parse_response(response) end end diff --git a/lib/zoom/actions/account.rb b/lib/zoom/actions/account.rb index 5de7fbf7..5a894170 100644 --- a/lib/zoom/actions/account.rb +++ b/lib/zoom/actions/account.rb @@ -3,7 +3,7 @@ module Zoom module Actions module Account - extend Zoom::ActionDefinitions + extend Zoom::Actions def self.included(base) define_action( From 3359e77002b8a8aecda3dbdfa1fce49d6eef685c Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 17 Sep 2021 14:28:27 -0700 Subject: [PATCH 03/29] Use keyword arguments It's more verbose, but I think it's useful here and cleaner to understand. --- lib/zoom/actions.rb | 2 +- lib/zoom/actions/account.rb | 60 ++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index a8ef62f9..006c12de 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -26,7 +26,7 @@ def self.make_request(obj, method, url, params, required_params) obj.class.public_send(method, parsed_url, **request_options) end - def define_action(name, method, url, required: [], permitted: []) + def define_action(name:, method:, url:, required: [], permitted: []) required = [required] if required.is_a?(Symbol) permitted = [permitted] if permitted.is_a?(Symbol) diff --git a/lib/zoom/actions/account.rb b/lib/zoom/actions/account.rb index 5a894170..7b440013 100644 --- a/lib/zoom/actions/account.rb +++ b/lib/zoom/actions/account.rb @@ -7,76 +7,76 @@ module Account def self.included(base) define_action( - 'account_list', - :get, - '/accounts', + name: 'account_list', + method: :get, + url: '/accounts', permitted: %i[page_size page_number] ) define_action( - 'account_create', - :post, - '/accounts', + name: 'account_create', + method: :post, + url: '/accounts', required: %i[first_name last_name email password], permitted: { options: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] } ) define_action( - 'account_get', - :get, - '/accounts/:account_id', + name: 'account_get', + method: :get, + url: '/accounts/:account_id', required: :account_id ) define_action( - 'account_delete', - :delete, - '/accounts/:account_id', + name: 'account_delete', + method: :delete, + url: '/accounts/:account_id', required: :account_id ) define_action( - 'account_options_update', - :patch, - '/accounts/:account_id/options', + name: 'account_options_update', + method: :patch, + url: '/accounts/:account_id/options', required: :account_id, permitted: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] ) define_action( - 'account_settings_get', - :get, - '/accounts/:account_id/settings', + name: 'account_settings_get', + method: :get, + url: '/accounts/:account_id/settings', required: :account_id, permitted: :option ) define_action( - 'account_settings_update', - :patch, - '/accounts/:account_id/settings', + name: 'account_settings_update', + method: :patch, + url: '/accounts/:account_id/settings', required: :account_id, permitted: [:option, Zoom::Constants::Account::Settings::PERMITTED_KEYS] ) define_action( - 'account_managed_domains', - :get, - '/accounts/:account_id/managed_domains', + name: 'account_managed_domains', + method: :get, + url: '/accounts/:account_id/managed_domains', required: :account_id ) define_action( - 'account_get_locked_settings', - :get, - '/accounts/:account_id/lock_settings', + name: 'account_get_locked_settings', + method: :get, + url: '/accounts/:account_id/lock_settings', required: :account_id ) define_action( - 'account_trusted_domains', - :get, - '/accounts/:account_id/trusted_domains', + name: 'account_trusted_domains', + method: :get, + url: '/accounts/:account_id/trusted_domains', required: :account_id ) end From e2015b861e5aee9f9d8bbf1c6214ef9d9b6baf05 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 17 Sep 2021 14:35:01 -0700 Subject: [PATCH 04/29] Simplify syntax The "define_action" calls don't need to be inside a "self.included" method. I also don't need "Zoom::Actions" explicitly declared within make_request. --- lib/zoom/actions.rb | 2 +- lib/zoom/actions/account.rb | 130 ++++++++++++++++++------------------ 2 files changed, 65 insertions(+), 67 deletions(-) diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index 006c12de..dab39a5c 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -22,7 +22,7 @@ def self.make_request(obj, method, url, params, required_params) when :post, :patch request_options[:body] = required_params.to_json end - parsed_url = Zoom::Actions.parse_url(url, params) + parsed_url = parse_url(url, params) obj.class.public_send(method, parsed_url, **request_options) end diff --git a/lib/zoom/actions/account.rb b/lib/zoom/actions/account.rb index 7b440013..dfb2ea7f 100644 --- a/lib/zoom/actions/account.rb +++ b/lib/zoom/actions/account.rb @@ -5,81 +5,79 @@ module Actions module Account extend Zoom::Actions - def self.included(base) - define_action( - name: 'account_list', - method: :get, - url: '/accounts', - permitted: %i[page_size page_number] - ) + define_action( + name: 'account_list', + method: :get, + url: '/accounts', + permitted: %i[page_size page_number] + ) - define_action( - name: 'account_create', - method: :post, - url: '/accounts', - required: %i[first_name last_name email password], - permitted: { options: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] } - ) + define_action( + name: 'account_create', + method: :post, + url: '/accounts', + required: %i[first_name last_name email password], + permitted: { options: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] } + ) - define_action( - name: 'account_get', - method: :get, - url: '/accounts/:account_id', - required: :account_id - ) + define_action( + name: 'account_get', + method: :get, + url: '/accounts/:account_id', + required: :account_id + ) - define_action( - name: 'account_delete', - method: :delete, - url: '/accounts/:account_id', - required: :account_id - ) + define_action( + name: 'account_delete', + method: :delete, + url: '/accounts/:account_id', + required: :account_id + ) - define_action( - name: 'account_options_update', - method: :patch, - url: '/accounts/:account_id/options', - required: :account_id, - permitted: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] - ) + define_action( + name: 'account_options_update', + method: :patch, + url: '/accounts/:account_id/options', + required: :account_id, + permitted: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] + ) - define_action( - name: 'account_settings_get', - method: :get, - url: '/accounts/:account_id/settings', - required: :account_id, - permitted: :option - ) + define_action( + name: 'account_settings_get', + method: :get, + url: '/accounts/:account_id/settings', + required: :account_id, + permitted: :option + ) - define_action( - name: 'account_settings_update', - method: :patch, - url: '/accounts/:account_id/settings', - required: :account_id, - permitted: [:option, Zoom::Constants::Account::Settings::PERMITTED_KEYS] - ) + define_action( + name: 'account_settings_update', + method: :patch, + url: '/accounts/:account_id/settings', + required: :account_id, + permitted: [:option, Zoom::Constants::Account::Settings::PERMITTED_KEYS] + ) - define_action( - name: 'account_managed_domains', - method: :get, - url: '/accounts/:account_id/managed_domains', - required: :account_id - ) + define_action( + name: 'account_managed_domains', + method: :get, + url: '/accounts/:account_id/managed_domains', + required: :account_id + ) - define_action( - name: 'account_get_locked_settings', - method: :get, - url: '/accounts/:account_id/lock_settings', - required: :account_id - ) + define_action( + name: 'account_get_locked_settings', + method: :get, + url: '/accounts/:account_id/lock_settings', + required: :account_id + ) - define_action( - name: 'account_trusted_domains', - method: :get, - url: '/accounts/:account_id/trusted_domains', - required: :account_id - ) - end + define_action( + name: 'account_trusted_domains', + method: :get, + url: '/accounts/:account_id/trusted_domains', + required: :account_id + ) end end end From 0941f7af5b4ca86cbd4bcb835d6359a8a47c25ee Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 10:31:22 -0700 Subject: [PATCH 05/29] Automatically detect and require URL params --- lib/zoom/actions.rb | 22 ++++++++++++++-------- lib/zoom/actions/account.rb | 18 +++++------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index dab39a5c..affd1f91 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -2,17 +2,20 @@ module Zoom module Actions - def self.parse_url(url, params) + def self.extract_url_param_keys(url) + url.scan(/:\w+/).map { |match| match[1..].to_sym } + end + + def self.parse_url(url, url_param_keys, params) parsed_url = url.dup - url.scan(/:\w+/).each do |match| - key = match[1..].to_sym + url_param_keys.each do |key| value = params[key].to_s - parsed_url = parsed_url.gsub(match, value) + parsed_url = parsed_url.gsub(":#{key}", value) end parsed_url end - def self.make_request(obj, method, url, params, required_params) + def self.make_request(obj, method, url, url_param_keys, params, required_params) request_options = { headers: obj.request_headers } @@ -22,7 +25,7 @@ def self.make_request(obj, method, url, params, required_params) when :post, :patch request_options[:body] = required_params.to_json end - parsed_url = parse_url(url, params) + parsed_url = parse_url(url, url_param_keys, params) obj.class.public_send(method, parsed_url, **request_options) end @@ -32,9 +35,12 @@ def define_action(name:, method:, url:, required: [], permitted: []) define_method(name) do |*args| params = Zoom::Params.new(Utils.extract_options!(args)) - required_params = required.empty? ? params : params.require(required) + url_param_keys = Zoom::Actions.extract_url_param_keys(url) + required_params = params + required_params = url_param_keys.empty? ? required_params : required_params.require(url_param_keys) + required_params = required.empty? ? required_params : required_params.require(required) required_params.permit(permitted) unless permitted.empty? - response = Zoom::Actions.make_request(self, method, url, params, required_params) + response = Zoom::Actions.make_request(self, method, url, url_param_keys, params, required_params) Utils.parse_response(response) end end diff --git a/lib/zoom/actions/account.rb b/lib/zoom/actions/account.rb index dfb2ea7f..87c65444 100644 --- a/lib/zoom/actions/account.rb +++ b/lib/zoom/actions/account.rb @@ -23,22 +23,19 @@ module Account define_action( name: 'account_get', method: :get, - url: '/accounts/:account_id', - required: :account_id + url: '/accounts/:account_id' ) define_action( name: 'account_delete', method: :delete, - url: '/accounts/:account_id', - required: :account_id + url: '/accounts/:account_id' ) define_action( name: 'account_options_update', method: :patch, url: '/accounts/:account_id/options', - required: :account_id, permitted: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] ) @@ -46,7 +43,6 @@ module Account name: 'account_settings_get', method: :get, url: '/accounts/:account_id/settings', - required: :account_id, permitted: :option ) @@ -54,29 +50,25 @@ module Account name: 'account_settings_update', method: :patch, url: '/accounts/:account_id/settings', - required: :account_id, permitted: [:option, Zoom::Constants::Account::Settings::PERMITTED_KEYS] ) define_action( name: 'account_managed_domains', method: :get, - url: '/accounts/:account_id/managed_domains', - required: :account_id + url: '/accounts/:account_id/managed_domains' ) define_action( name: 'account_get_locked_settings', method: :get, - url: '/accounts/:account_id/lock_settings', - required: :account_id + url: '/accounts/:account_id/lock_settings' ) define_action( name: 'account_trusted_domains', method: :get, - url: '/accounts/:account_id/trusted_domains', - required: :account_id + url: '/accounts/:account_id/trusted_domains' ) end end From 1e5dfdfc58a65180279f8c33bd3a99e61f7bfd52 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 10:35:18 -0700 Subject: [PATCH 06/29] Rename required_params to filtered_params Call parse_url explicitly before make_request. --- lib/zoom/actions.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index affd1f91..b96d26e6 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -15,17 +15,16 @@ def self.parse_url(url, url_param_keys, params) parsed_url end - def self.make_request(obj, method, url, url_param_keys, params, required_params) + def self.make_request(obj, method, parsed_url, filtered_params) request_options = { headers: obj.request_headers } case method when :get - request_options[:query] = required_params + request_options[:query] = filtered_params when :post, :patch - request_options[:body] = required_params.to_json + request_options[:body] = filtered_params.to_json end - parsed_url = parse_url(url, url_param_keys, params) obj.class.public_send(method, parsed_url, **request_options) end @@ -36,11 +35,12 @@ def define_action(name:, method:, url:, required: [], permitted: []) define_method(name) do |*args| params = Zoom::Params.new(Utils.extract_options!(args)) url_param_keys = Zoom::Actions.extract_url_param_keys(url) - required_params = params - required_params = url_param_keys.empty? ? required_params : required_params.require(url_param_keys) - required_params = required.empty? ? required_params : required_params.require(required) - required_params.permit(permitted) unless permitted.empty? - response = Zoom::Actions.make_request(self, method, url, url_param_keys, params, required_params) + filtered_params = params + filtered_params = url_param_keys.empty? ? filtered_params : filtered_params.require(url_param_keys) + filtered_params = required.empty? ? filtered_params : filtered_params.require(required) + filtered_params.permit(permitted) unless permitted.empty? + parsed_url = Zoom::Actions.parse_url(url, url_param_keys, params) + response = Zoom::Actions.make_request(self, method, parsed_url, filtered_params) Utils.parse_response(response) end end From 60d448e2fa74a08595b516b795865c641b13099b Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 10:41:41 -0700 Subject: [PATCH 07/29] Create filter_params method Rename url_param_keys to url_keys for brevity --- lib/zoom/actions.rb | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index b96d26e6..540129dd 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -2,13 +2,13 @@ module Zoom module Actions - def self.extract_url_param_keys(url) + def self.extract_url_keys(url) url.scan(/:\w+/).map { |match| match[1..].to_sym } end - def self.parse_url(url, url_param_keys, params) + def self.parse_url(url, url_keys, params) parsed_url = url.dup - url_param_keys.each do |key| + url_keys.each do |key| value = params[key].to_s parsed_url = parsed_url.gsub(":#{key}", value) end @@ -28,18 +28,23 @@ def self.make_request(obj, method, parsed_url, filtered_params) obj.class.public_send(method, parsed_url, **request_options) end + def self.filter_params(params, url_keys, required, permitted) + filtered_params = params + filtered_params = filtered_params.require(url_keys) unless url_keys.empty? + filtered_params = filtered_params.require(required) unless required.empty? + filtered_params.permit(permitted) unless permitted.empty? + filtered_params + end + def define_action(name:, method:, url:, required: [], permitted: []) required = [required] if required.is_a?(Symbol) permitted = [permitted] if permitted.is_a?(Symbol) define_method(name) do |*args| params = Zoom::Params.new(Utils.extract_options!(args)) - url_param_keys = Zoom::Actions.extract_url_param_keys(url) - filtered_params = params - filtered_params = url_param_keys.empty? ? filtered_params : filtered_params.require(url_param_keys) - filtered_params = required.empty? ? filtered_params : filtered_params.require(required) - filtered_params.permit(permitted) unless permitted.empty? - parsed_url = Zoom::Actions.parse_url(url, url_param_keys, params) + url_keys = Zoom::Actions.extract_url_keys(url) + filtered_params = Zoom::Actions.filter_params(params, url_keys, required, permitted) + parsed_url = Zoom::Actions.parse_url(url, url_keys, params) response = Zoom::Actions.make_request(self, method, parsed_url, filtered_params) Utils.parse_response(response) end From b3b7f6ad28bce8be59d8155d3b7e4c339864a54d Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 10:46:44 -0700 Subject: [PATCH 08/29] Rewrite most Billing actions using new system --- lib/zoom/actions/billing.rb | 43 ++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/lib/zoom/actions/billing.rb b/lib/zoom/actions/billing.rb index 8c2d4ea9..c53a8916 100644 --- a/lib/zoom/actions/billing.rb +++ b/lib/zoom/actions/billing.rb @@ -3,29 +3,32 @@ module Zoom module Actions module Billing - def billing_get(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - Utils.parse_response self.class.get("/accounts/#{params[:account_id]}/billing", headers: request_headers) - end + extend Zoom::Actions - def billing_update(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id).permit(%i[first_name last_name email phone_number address apt city state zip country]) - Utils.parse_response self.class.patch("/accounts/#{params[:account_id]}/billing", body: params.except(:account_id).to_json, headers: request_headers) - end + define_action( + name: 'billing_get', + method: :get, + url: '/accounts/:account_id/billing' + ) - def billing_plans_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - Utils.parse_response self.class.get("/accounts/#{params[:account_id]}/plans", headers: request_headers) - end + define_action( + name: 'billing_update', + method: :patch, + url: '/accounts/:account_id/billing', + permitted: %i[first_name last_name email phone_number address apt city state zip country] + ) - def billing_plans_usage(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - Utils.parse_response self.class.get("/accounts/#{params[:account_id]}/plans/usage", headers: request_headers) - end + define_action( + name: 'billing_plans_list', + method: :get, + url: '/accounts/:account_id/plans' + ) + + define_action( + name: 'billing_plans_usage', + method: :get, + url: '/accounts/:account_id/plans/usage' + ) def billing_plans_subscribe(*args) params = Zoom::Params.new(Utils.extract_options!(args)) From 4349193e1e9aae9e0b3b8601e62f7e73f707e2d9 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 13:15:20 -0700 Subject: [PATCH 09/29] Fixes for param filtering Only remove url keys. Call require and permit but don't actually removed the require params from the final body result. Update api for billing_plans_subscribe to be more accurate. --- lib/zoom/actions.rb | 18 ++++++------------ lib/zoom/actions/billing.rb | 32 ++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index 540129dd..089143fe 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -10,7 +10,7 @@ def self.parse_url(url, url_keys, params) parsed_url = url.dup url_keys.each do |key| value = params[key].to_s - parsed_url = parsed_url.gsub(":#{key}", value) + parsed_url = parsed_url.sub(":#{key}", value) end parsed_url end @@ -28,24 +28,18 @@ def self.make_request(obj, method, parsed_url, filtered_params) obj.class.public_send(method, parsed_url, **request_options) end - def self.filter_params(params, url_keys, required, permitted) - filtered_params = params - filtered_params = filtered_params.require(url_keys) unless url_keys.empty? - filtered_params = filtered_params.require(required) unless required.empty? - filtered_params.permit(permitted) unless permitted.empty? - filtered_params - end - def define_action(name:, method:, url:, required: [], permitted: []) required = [required] if required.is_a?(Symbol) permitted = [permitted] if permitted.is_a?(Symbol) define_method(name) do |*args| - params = Zoom::Params.new(Utils.extract_options!(args)) url_keys = Zoom::Actions.extract_url_keys(url) - filtered_params = Zoom::Actions.filter_params(params, url_keys, required, permitted) + params = Zoom::Params.new(Utils.extract_options!(args)) parsed_url = Zoom::Actions.parse_url(url, url_keys, params) - response = Zoom::Actions.make_request(self, method, parsed_url, filtered_params) + params = params.require(url_keys) unless url_keys.empty? + params_without_required = required.empty? ? params : params.require(required) + params_without_required.permit(permitted) unless permitted.empty? + response = Zoom::Actions.make_request(self, method, parsed_url, params) Utils.parse_response(response) end end diff --git a/lib/zoom/actions/billing.rb b/lib/zoom/actions/billing.rb index c53a8916..64f78857 100644 --- a/lib/zoom/actions/billing.rb +++ b/lib/zoom/actions/billing.rb @@ -30,12 +30,32 @@ module Billing url: '/accounts/:account_id/plans/usage' ) - def billing_plans_subscribe(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - # TODO: Move to constants and do some data validation - params.require(:account_id, contact: %i[first_name last_name email phone_number address city state zip country], plan_base: %i[type hosts]).permit(:plan_recording, contact: [:apt], plan_zoom_rooms: %i[type hosts], plan_room_connector: %i[type hosts], plan_large_meeting: [], plan_webinar: [], plan_audio: %i[type tollfree_countries premium_countries callout_countries ddi_numbers], plan_phone: { plan_base: %i[type hosts], plan_calling: [], plan_number: [] }) - Utils.parse_response self.class.post("/accounts/#{params[:account_id]}/plans", body: params.except(:account_id).to_json, headers: request_headers) - end + define_action( + name: 'billing_plans_subscribe', + method: :post, + url: '/accounts/:account_id/plans', + required: { + contact: %i[first_name last_name email phone_number address city state zip country], + plan_base: %i[type hosts] + }, + permitted: [ + :plan_recording, + { + contact: [:apt], + plan_zoom_rooms: %i[type hosts], + plan_room_connector: %i[type hosts], + plan_large_meeting: %i[type hosts], + plan_zoom_events: %i[type hosts], + plan_webinar: %i[type hosts], + plan_audio: %i[type tollfree_countries premium_countries callout_countries ddi_numbers], + plan_phone: { + plan_base: %i[type callout_countries], + plan_calling: %i[type hosts], + plan_number: %i[type hosts] + } + } + ] + ) end end end \ No newline at end of file From d49124cd8f8d46539041629bb9874b430b36a23e Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 14:06:35 -0700 Subject: [PATCH 10/29] Automatically process time params Convert Dashboard to new system. Remove unnecessary whitespace --- lib/zoom/actions/account.rb | 72 +++++++++++++++++------------------ lib/zoom/actions/billing.rb | 18 ++++----- lib/zoom/actions/dashboard.rb | 49 +++++++++++++----------- lib/zoom/actions/meeting.rb | 2 - lib/zoom/actions/recording.rb | 1 - lib/zoom/utils.rb | 17 +++++---- spec/lib/zoom/utils_spec.rb | 2 +- 7 files changed, 83 insertions(+), 78 deletions(-) diff --git a/lib/zoom/actions/account.rb b/lib/zoom/actions/account.rb index 87c65444..b6c098b2 100644 --- a/lib/zoom/actions/account.rb +++ b/lib/zoom/actions/account.rb @@ -6,69 +6,69 @@ module Account extend Zoom::Actions define_action( - name: 'account_list', - method: :get, - url: '/accounts', - permitted: %i[page_size page_number] + name: 'account_list', + method: :get, + url: '/accounts', + permitted: %i[page_size page_number] ) define_action( - name: 'account_create', - method: :post, - url: '/accounts', - required: %i[first_name last_name email password], - permitted: { options: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] } + name: 'account_create', + method: :post, + url: '/accounts', + required: %i[first_name last_name email password], + permitted: { options: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] } ) define_action( - name: 'account_get', - method: :get, - url: '/accounts/:account_id' + name: 'account_get', + method: :get, + url: '/accounts/:account_id' ) define_action( - name: 'account_delete', - method: :delete, - url: '/accounts/:account_id' + name: 'account_delete', + method: :delete, + url: '/accounts/:account_id' ) define_action( - name: 'account_options_update', - method: :patch, - url: '/accounts/:account_id/options', - permitted: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] + name: 'account_options_update', + method: :patch, + url: '/accounts/:account_id/options', + permitted: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] ) define_action( - name: 'account_settings_get', - method: :get, - url: '/accounts/:account_id/settings', - permitted: :option + name: 'account_settings_get', + method: :get, + url: '/accounts/:account_id/settings', + permitted: :option ) define_action( - name: 'account_settings_update', - method: :patch, - url: '/accounts/:account_id/settings', - permitted: [:option, Zoom::Constants::Account::Settings::PERMITTED_KEYS] + name: 'account_settings_update', + method: :patch, + url: '/accounts/:account_id/settings', + permitted: [:option, Zoom::Constants::Account::Settings::PERMITTED_KEYS] ) define_action( - name: 'account_managed_domains', - method: :get, - url: '/accounts/:account_id/managed_domains' + name: 'account_managed_domains', + method: :get, + url: '/accounts/:account_id/managed_domains' ) define_action( - name: 'account_get_locked_settings', - method: :get, - url: '/accounts/:account_id/lock_settings' + name: 'account_get_locked_settings', + method: :get, + url: '/accounts/:account_id/lock_settings' ) define_action( - name: 'account_trusted_domains', - method: :get, - url: '/accounts/:account_id/trusted_domains' + name: 'account_trusted_domains', + method: :get, + url: '/accounts/:account_id/trusted_domains' ) end end diff --git a/lib/zoom/actions/billing.rb b/lib/zoom/actions/billing.rb index 64f78857..19bdbe5a 100644 --- a/lib/zoom/actions/billing.rb +++ b/lib/zoom/actions/billing.rb @@ -6,22 +6,22 @@ module Billing extend Zoom::Actions define_action( - name: 'billing_get', + name: 'billing_get', method: :get, - url: '/accounts/:account_id/billing' + url: '/accounts/:account_id/billing' ) define_action( - name: 'billing_update', - method: :patch, - url: '/accounts/:account_id/billing', + name: 'billing_update', + method: :patch, + url: '/accounts/:account_id/billing', permitted: %i[first_name last_name email phone_number address apt city state zip country] ) define_action( - name: 'billing_plans_list', + name: 'billing_plans_list', method: :get, - url: '/accounts/:account_id/plans' + url: '/accounts/:account_id/plans' ) define_action( @@ -41,7 +41,7 @@ module Billing permitted: [ :plan_recording, { - contact: [:apt], + contact: %i[apt], plan_zoom_rooms: %i[type hosts], plan_room_connector: %i[type hosts], plan_large_meeting: %i[type hosts], @@ -58,4 +58,4 @@ module Billing ) end end -end \ No newline at end of file +end diff --git a/lib/zoom/actions/dashboard.rb b/lib/zoom/actions/dashboard.rb index 5a9d2efd..914eecf0 100644 --- a/lib/zoom/actions/dashboard.rb +++ b/lib/zoom/actions/dashboard.rb @@ -3,31 +3,36 @@ module Zoom module Actions module Dashboard - def dashboard_crc(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[from to]) - Utils.process_datetime_params!(%i[from to], params) - Utils.parse_response self.class.get('/metrics/crc', query: params, headers: request_headers) - end + extend Zoom::Actions - def dashboard_meetings(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[from to]).permit(%i[next_page_token page_size type]) - Utils.process_datetime_params!(%i[from to], params) - Utils.parse_response self.class.get('/metrics/meetings', query: params, headers: request_headers) - end + define_action( + name: 'dashboard_crc', + method: :get, + url: '/metrics/crc', + required: %i[from to] + ) - def dashboard_meeting_details(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:meeting_id).permit(:type) - Utils.parse_response self.class.get("/metrics/meetings/#{params[:meeting_id]}", query: params.except(:meeting_id), headers: request_headers) - end + define_action( + name: 'dashboard_meetings', + method: :get, + url: '/metrics/meetings', + required: %i[from to], + permitted: %i[next_page_token page_size type] + ) - def dashboard_meeting_participants(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:meeting_id).permit(%i[next_page_token page_size type]) - Utils.parse_response self.class.get("/metrics/meetings/#{params[:meeting_id]}/participants", query: params.except(:meeting_id), headers: request_headers) - end + define_action( + name: 'dashboard_meeting_details', + method: :get, + url: '/metrics/meetings/:meeting_id', + permitted: :type + ) + + define_action( + name: 'dashboard_meeting_participants', + method: :get, + url: '/metrics/meetings/:meeting_id/participants', + permitted: %i[next_page_token page_size type] + ) end end end diff --git a/lib/zoom/actions/meeting.rb b/lib/zoom/actions/meeting.rb index 589b8677..a78b376f 100644 --- a/lib/zoom/actions/meeting.rb +++ b/lib/zoom/actions/meeting.rb @@ -14,7 +14,6 @@ def meeting_list(*args) def meeting_create(*args) params = Zoom::Params.new(Utils.extract_options!(args)) params.require(:user_id).permit(%i[topic type start_time duration schedule_for timezone password agenda tracking_fields recurrence settings]) - Utils.process_datetime_params!(:start_time, params) Utils.parse_response self.class.post("/users/#{params[:user_id]}/meetings", body: params.except(:user_id).to_json, headers: request_headers) end @@ -29,7 +28,6 @@ def meeting_get(*args) def meeting_update(*args) params = Zoom::Params.new(Utils.extract_options!(args)) params.require(:meeting_id) - Utils.process_datetime_params!(:start_time, params) # TODO Handle `topic` attr, Max of 300 characters. # TODO Handle `timezone` attr, refer to the id value in timezone list JSON file. like "America/Los_Angeles" # TODO Verify `password` attr, may only contain the following characters: a-z A-Z 0-9 @ - _ diff --git a/lib/zoom/actions/recording.rb b/lib/zoom/actions/recording.rb index 64ba6d49..13f7bd5b 100644 --- a/lib/zoom/actions/recording.rb +++ b/lib/zoom/actions/recording.rb @@ -10,7 +10,6 @@ module Recording def recording_list(*args) options = Zoom::Params.new(Utils.extract_options!(args)) options.require(:user_id) - Utils.process_datetime_params!(%i[from to], options) Utils.parse_response self.class.get("/users/#{options[:user_id]}/recordings", query: options.except(:user_id), headers: request_headers) end diff --git a/lib/zoom/utils.rb b/lib/zoom/utils.rb index 64325598..3229807f 100644 --- a/lib/zoom/utils.rb +++ b/lib/zoom/utils.rb @@ -32,7 +32,8 @@ def parse_response(http_response) end def extract_options!(array) - array.last.is_a?(::Hash) ? array.pop : {} + params = array.last.is_a?(::Hash) ? array.pop : {} + process_datetime_params!(params) end def validate_password(password) @@ -40,14 +41,16 @@ def validate_password(password) raise(Error , 'Invalid Password') unless password[password_regex].nil? end - def process_datetime_params!(params, options) - params = [params] unless params.is_a? Array - params.each do |param| - if options[param] && options[param].kind_of?(Time) - options[param] = options[param].strftime('%FT%TZ') + 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 + when Hash + process_datetime_params!(params[key]) end end - options + params end end end diff --git a/spec/lib/zoom/utils_spec.rb b/spec/lib/zoom/utils_spec.rb index 2e609c84..ee78d1ca 100644 --- a/spec/lib/zoom/utils_spec.rb +++ b/spec/lib/zoom/utils_spec.rb @@ -45,7 +45,7 @@ class Utils < Zoom::Utils; end bar: Time.utc(2000, 'jan', 1, 20, 15, 1) } expect( - Utils.process_datetime_params!(:bar, args) + Utils.process_datetime_params!(args) ).to eq({ foo: 'foo', bar: '2000-01-01T20:15:01Z' }) end From 3b96796aa02569c1aa2dab7f175233773126d4e4 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 14:21:42 -0700 Subject: [PATCH 11/29] Rework Meeting --- lib/zoom/actions/groups.rb | 20 +++-- lib/zoom/actions/meeting.rb | 147 ++++++++++++++++++++---------------- 2 files changed, 94 insertions(+), 73 deletions(-) diff --git a/lib/zoom/actions/groups.rb b/lib/zoom/actions/groups.rb index 0ceed9b0..81fff270 100644 --- a/lib/zoom/actions/groups.rb +++ b/lib/zoom/actions/groups.rb @@ -3,15 +3,19 @@ module Zoom module Actions module Groups - def groups_list(*_args) - Utils.parse_response self.class.get('/groups', headers: request_headers) - end + extend Zoom::Actions - def groups_get(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:group_id) - Utils.parse_response self.class.get("/groups/#{params[:group_id]}", headers: request_headers) - end + define_action( + name: 'groups_list', + method: :get, + url: '/groups' + ) + + define_action( + name: 'groups_get', + method: :get, + url: '/groups/:group_id' + ) end end end \ No newline at end of file diff --git a/lib/zoom/actions/meeting.rb b/lib/zoom/actions/meeting.rb index a78b376f..ef5dfa59 100644 --- a/lib/zoom/actions/meeting.rb +++ b/lib/zoom/actions/meeting.rb @@ -3,93 +3,110 @@ module Zoom module Actions module Meeting + extend Zoom::Actions + # List all the scheduled meetings on Zoom. - def meeting_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:user_id).permit(%i[type page_size next_page_token page_number]) - Utils.parse_response self.class.get("/users/#{params[:user_id]}/meetings", query: params.except(:user_id), headers: request_headers) - end + define_action( + name: 'meeting_list', + method: :get, + url: '/users/:user_id/meetings', + permitted: %i[type page_size next_page_token page_number] + ) # Create a meeting on Zoom, return the created meeting URL - def meeting_create(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:user_id).permit(%i[topic type start_time duration schedule_for timezone password agenda tracking_fields recurrence settings]) - Utils.parse_response self.class.post("/users/#{params[:user_id]}/meetings", body: params.except(:user_id).to_json, headers: request_headers) - end + define_action( + name: 'meeting_create', + method: :post, + url: '/users/:user_id/meetings', + permitted: %i[ + topic type start_time duration schedule_for timezone password agenda tracking_fields + recurrence settings + ] + ) # Get a meeting on Zoom via meeting ID, return the meeting info. - def meeting_get(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:meeting_id).permit(%i[occurrence_id show_previous_occurrences]) - Utils.parse_response self.class.get("/meetings/#{params[:meeting_id]}", query: params.except(:meeting_id), headers: request_headers) - end + define_action( + name: 'meeting_get', + method: :get, + url: '/meetings/:meeting_id/', + permitted: %i[occurrence_id show_previous_occurrences] + ) # Update meeting info on Zoom via meeting ID. - def meeting_update(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:meeting_id) - # TODO Handle `topic` attr, Max of 300 characters. - # TODO Handle `timezone` attr, refer to the id value in timezone list JSON file. like "America/Los_Angeles" - # 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". - Utils.parse_response self.class.patch("/meetings/#{params[:meeting_id]}", body: params.except(:meeting_id).to_json, headers: request_headers) - end + # TODO Handle `topic` attr, Max of 300 characters. + # TODO Handle `timezone` attr, refer to the id value in timezone list JSON file. like "America/Los_Angeles" + # 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". + define_action( + name: 'meeting_update', + method: :patch, + url: '/meetings/:meeting_id' + ) # Delete a meeting on Zoom, return the deleted meeting ID. - def meeting_delete(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:meeting_id) - Utils.parse_response self.class.delete("/meetings/#{params[:meeting_id]}", query: params.except(:meeting_id), headers: request_headers) - end + define_action( + name: 'meeting_delete', + method: :delete, + url: '/meetings/:meeting_id' + ) # Update a meeting's status - def meeting_update_status(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:meeting_id).permit(:action) - Utils.parse_response self.class.put("/meetings/#{params[:meeting_id]}/status", body: params.except(:meeting_id).to_json, headers: request_headers) - end + define_action( + name: 'meeting_update_status', + method: :put, + url: '/meetings/:meeting_id/status', + permitted: :action + ) # Register for a meeting. - def meeting_add_registrant(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[meeting_id email first_name]).permit(%i[last_name address city country zip state phone industry org job_title purchasing_time_frame role_in_purchase_process no_of_employees comments custom_questions language occurrence_ids]) - Utils.parse_response self.class.post("/meetings/#{params[:meeting_id]}/registrants", query: params.slice(:occurrence_ids), body: params.except(:meeting_id).to_json, headers: request_headers) - end + define_action( + name: 'meeting_add_registrant', + method: :post, + url: '/meetings/:meeting_id/registrants', + required: %i[email first_name], + permitted: %i[ + last_name address city country zip state phone industry org job_title + purchasing_time_frame role_in_purchase_process no_of_employees comments custom_questions + language occurrence_ids + ] + ) # Register for a meeting. - def meeting_registrant_questions(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:meeting_id) - Utils.parse_response self.class.patch("/meetings/#{params[:meeting_id]}/registrants/questions", body: params.except(:meeting_id).to_json, headers: request_headers) - end + define_action( + name: 'meeting_registrant_questions', + method: :patch, + url: '/meeting/:meeting_id/registrants/questions' + ) # Retrieve ended meeting details - def past_meeting_details(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:meeting_uuid) - Utils.parse_response self.class.get("/past_meetings/#{params[:meeting_uuid]}", headers: request_headers) - end + define_action( + name: 'past_meeting_details', + method: :get, + url: '/past_meetings/:meeting_uuid' + ) # Retrieve ended meeting participants - def past_meeting_participants(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:meeting_uuid) - Utils.parse_response self.class.get("/past_meetings/#{params[:meeting_uuid]}/participants", headers: request_headers) - end + define_action( + name: 'past_meeting_participants', + method: :get, + url: '/past_meetings/:meeting_uuid/participants' + ) - def livestream(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[meeting_id stream_url stream_key]).permit(:page_url) - Utils.parse_response self.class.patch("/meetings/#{params[:meeting_id]}/livestream", body: params.except(:meeting_id).to_json, headers: request_headers) - end + define_action( + name: 'livestream', + method: :patch, + url: '/meetings/:meeting_id/livestream', + required: %i[stream_url stream_key], + permitted: :page_url + ) # Get a meeting on Zoom via meeting ID, return the meeting info. - def meeting_invitation(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:meeting_id) - Utils.parse_response self.class.get("/meetings/#{params[:meeting_id]}/invitation", headers: request_headers) - end + define_action( + name: 'meeting_invitation', + method: :get, + url: '/meetings/:meeting_id/invitation', + ) end end end From 45bf1efb1f84719f422f287a8d3d3c7a19334662 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 14:24:34 -0700 Subject: [PATCH 12/29] Rework Phone --- lib/zoom/actions/phone.rb | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/zoom/actions/phone.rb b/lib/zoom/actions/phone.rb index 8e365ba2..c09ebd82 100644 --- a/lib/zoom/actions/phone.rb +++ b/lib/zoom/actions/phone.rb @@ -3,25 +3,25 @@ module Zoom module Actions module Phone - def call_logs(*args) - options = Zoom::Params.new(Utils.extract_options!(args)) - options.require(%i[user_id]) - response = self.class.get("/phone/users/#{options[:user_id]}/call_logs", query: options.except(:user_id), headers: request_headers) - Utils.parse_response(response) - end + extend Zoom::Actions - def phone_users_list(*args) - options = Zoom::Params.new(Utils.extract_options!(args)) - response = self.class.get("/phone/users", query: options, headers: request_headers) - Utils.parse_response(response) - end + define_action( + name: 'call_logs', + method: :get, + url: '/phone/users/:user_id/call_logs' + ) - def call_recordings(*args) - options = Zoom::Params.new(Utils.extract_options!(args)) - options.require(%i[user_id]) - response = self.class.get("/phone/users/#{options[:user_id]}/recordings", query: options.except(:user_id), headers: request_headers) - Utils.parse_response(response) - end + define_action( + name: 'phone_users_list', + method: :get, + url: '/phone/users' + ) + + define_action( + name: 'call_recordings', + method: :get, + url: '/phone/users/:user_id/recordings' + ) end end end From 4e72b5b0efe376e30f43b711cae7271e6837dcce Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 14:29:13 -0700 Subject: [PATCH 13/29] Rework Recording --- lib/zoom/actions/recording.rb | 53 ++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/lib/zoom/actions/recording.rb b/lib/zoom/actions/recording.rb index 13f7bd5b..8f2632b7 100644 --- a/lib/zoom/actions/recording.rb +++ b/lib/zoom/actions/recording.rb @@ -3,39 +3,42 @@ module Zoom module Actions 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 - def recording_list(*args) - options = Zoom::Params.new(Utils.extract_options!(args)) - options.require(:user_id) - Utils.parse_response self.class.get("/users/#{options[:user_id]}/recordings", query: options.except(:user_id), headers: request_headers) - end + define_action( + name: 'recording_list', + method: :get, + url: '/users/:user_id/recordings' + ) - def meeting_recording_get(*args) - options = Zoom::Params.new(Utils.extract_options!(args)) - options.require(:meeting_id) - Utils.parse_response self.class.get("/meetings/#{options[:meeting_id]}/recordings/settings", query: options.except(:meeting_id), headers: request_headers) - end + define_action( + name: 'meeting_recording_get', + method: :get, + url: '/meetings/:meeting_id/recordings/settings' + ) - def meeting_recording_settings_get(*args) - options = Zoom::Params.new(Utils.extract_options!(args)) - options.require(:meeting_id) - Utils.parse_response self.class.get("/meetings/#{options[:meeting_id]}/recordings/settings", query: options.except(:meeting_id), headers: request_headers) - end + define_action( + name: 'meeting_recording_settings_get', + method: :get, + url: '/meetings/:meeting_id/recordings/settings' + ) - def meeting_recording_settings_update(*args) - options = Zoom::Params.new(Utils.extract_options!(args)) - options.require(:meeting_id).permit(RECORDING_SETTINGS_KEYS) - Utils.parse_response self.class.patch("/meetings/#{options[:meeting_id]}/recordings/settings", body: options.except(:meeting_id).to_json, headers: request_headers) - end + define_action( + name: 'meeting_recording_settings_update', + method: :patch, + url: '/meetings/:meeting_id/recordings/settings', + permitted: RECORDING_SETTINGS_KEYS + ) - def meeting_recording_file_delete(*args) - options = Zoom::Params.new(Utils.extract_options!(args)) - options.require(%i[meeting_id recording_id]) - Utils.parse_response self.class.delete("/meetings/#{options[:meeting_id]}/recordings/#{options[:recording_id]}", query: options.except(:meeting_id, :recording_id), headers: request_headers) - end + define_action( + name: 'meeting_recording_file_delete', + method: :delete, + url: '/meetings/:meeting_id/recordings/:recording_id' + ) end end end From cfd56f525579aadcf8612b4f588a0ceb2855ede1 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 14:34:40 -0700 Subject: [PATCH 14/29] Rework Report --- lib/zoom/actions/report.rb | 46 +++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/lib/zoom/actions/report.rb b/lib/zoom/actions/report.rb index 69dc2bde..a53ce25a 100644 --- a/lib/zoom/actions/report.rb +++ b/lib/zoom/actions/report.rb @@ -3,28 +3,34 @@ module Zoom module Actions module Report - def daily_report(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.permit(%i[year month]) - Utils.parse_response self.class.get('/report/daily', query: params, headers: request_headers) - end - def meeting_details_report(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id) - Utils.parse_response self.class.get("/report/meetings/#{params[:id]}", query: params.except(:id), headers: request_headers) - end + extend Zoom::Actions - def meeting_participants_report(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id).permit(%i[page_size next_page_token]) - Utils.parse_response self.class.get("/report/meetings/#{params[:id]}/participants", query: params.except(:id), headers: request_headers) - end + define_action( + name: 'daily_report', + method: :get, + url: '/report/daily', + permitted: %i[year month] + ) - def webinar_participants_report(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id).permit(%i[page_size next_page_token]) - Utils.parse_response self.class.get("/report/webinars/#{params[:id]}/participants", query: params.except(:id), headers: request_headers) - end + define_action( + name: 'meeting_details_report', + method: :get, + url: '/report/meetings/:id' + ) + + define_action( + name: 'meeting_participants_report', + method: :get, + url: '/report/meetings/:id/participants', + permitted: %i[page_size next_page_token] + ) + + define_action( + name: 'webinar_participants_report', + method: :get, + url: '/report/webinars/:id/participants', + permitted: %i[page_size next_page_token] + ) end end end From 70cbb041da8638faf50b2ad3f7e17e524d827d89 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 14:50:11 -0700 Subject: [PATCH 15/29] Even simpler syntax option --- lib/zoom/actions.rb | 12 +++++++ lib/zoom/actions/account.rb | 67 +++++++++---------------------------- 2 files changed, 28 insertions(+), 51 deletions(-) diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index 089143fe..ec197067 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -43,5 +43,17 @@ def define_action(name:, method:, url:, required: [], permitted: []) Utils.parse_response(response) end end + + [:get, :post, :patch, :put, :delete].each do |method| + define_method("#{method}_action") do |name, url, validations={}| + define_action( + name: name, + method: method, + url: url, + required: validations[:require] || [], + permitted: validations[:permit] || [] + ) + end + end end end diff --git a/lib/zoom/actions/account.rb b/lib/zoom/actions/account.rb index b6c098b2..adef7b70 100644 --- a/lib/zoom/actions/account.rb +++ b/lib/zoom/actions/account.rb @@ -5,71 +5,36 @@ module Actions module Account extend Zoom::Actions - define_action( - name: 'account_list', - method: :get, - url: '/accounts', - permitted: %i[page_size page_number] + get_action('account_list', '/accounts', + permit: %i[page_size page_number] ) - define_action( - name: 'account_create', - method: :post, - url: '/accounts', - required: %i[first_name last_name email password], - permitted: { options: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] } + post_action('account_create', '/accounts', + require: %i[first_name last_name email password], + permit: { options: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] } ) - define_action( - name: 'account_get', - method: :get, - url: '/accounts/:account_id' - ) + get_action('account_get', '/accounts/:account_id') - define_action( - name: 'account_delete', - method: :delete, - url: '/accounts/:account_id' - ) + delete_action('account_delete', '/accounts/:account_id') - define_action( - name: 'account_options_update', - method: :patch, - url: '/accounts/:account_id/options', - permitted: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] + patch_action('account_options_update', '/accounts/:account_id/options', + permit: %i[share_rc room_connectors share_mc meeting_connectors pay_mode] ) - define_action( - name: 'account_settings_get', - method: :get, - url: '/accounts/:account_id/settings', - permitted: :option + get_action('account_settings_get', '/accounts/:account_id/settings', + permit: :option ) - define_action( - name: 'account_settings_update', - method: :patch, - url: '/accounts/:account_id/settings', - permitted: [:option, Zoom::Constants::Account::Settings::PERMITTED_KEYS] + patch_action('account_settings_update', '/accounts/:account_id/settings', + permit: [:option, Zoom::Constants::Account::Settings::PERMITTED_KEYS] ) - define_action( - name: 'account_managed_domains', - method: :get, - url: '/accounts/:account_id/managed_domains' - ) + get_action('account_managed_domains', '/accounts/:account_id/managed_domains') - define_action( - name: 'account_get_locked_settings', - method: :get, - url: '/accounts/:account_id/lock_settings' - ) + get_action('account_get_locked_settings', '/accounts/:account_id/lock_settings') - define_action( - name: 'account_trusted_domains', - method: :get, - url: '/accounts/:account_id/trusted_domains' - ) + get_action('account_trusted_domains', '/accounts/:account_id/trusted_domains') end end end From 2866c6d6d7db646bd0991171dcc83e6722c93484 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 15:26:07 -0700 Subject: [PATCH 16/29] Use really simple syntax --- lib/zoom/actions.rb | 39 ++++++---------- lib/zoom/actions/account.rb | 25 ++++------ lib/zoom/actions/billing.rb | 36 ++++---------- lib/zoom/actions/dashboard.rb | 34 ++++---------- lib/zoom/actions/groups.rb | 12 +---- lib/zoom/actions/meeting.rb | 88 ++++++++--------------------------- lib/zoom/actions/phone.rb | 18 ++----- lib/zoom/actions/recording.rb | 32 +++---------- lib/zoom/actions/report.rb | 30 +++--------- 9 files changed, 80 insertions(+), 234 deletions(-) diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index ec197067..d4ccf771 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -28,31 +28,22 @@ def self.make_request(obj, method, parsed_url, filtered_params) obj.class.public_send(method, parsed_url, **request_options) end - def define_action(name:, method:, url:, required: [], permitted: []) - required = [required] if required.is_a?(Symbol) - permitted = [permitted] if permitted.is_a?(Symbol) - - define_method(name) do |*args| - url_keys = Zoom::Actions.extract_url_keys(url) - params = Zoom::Params.new(Utils.extract_options!(args)) - parsed_url = Zoom::Actions.parse_url(url, url_keys, params) - params = params.require(url_keys) unless url_keys.empty? - params_without_required = required.empty? ? params : params.require(required) - params_without_required.permit(permitted) unless permitted.empty? - response = Zoom::Actions.make_request(self, method, parsed_url, params) - Utils.parse_response(response) - end - end - [:get, :post, :patch, :put, :delete].each do |method| - define_method("#{method}_action") do |name, url, validations={}| - define_action( - name: name, - method: method, - url: url, - required: validations[:require] || [], - permitted: validations[:permit] || [] - ) + define_method(method) do |name, url, validations={}| + required, permitted = validations.values_at :require, :permit + required = Array(required) unless required.is_a?(Hash) + permitted = Array(permitted) unless permitted.is_a?(Hash) + + define_method(name) do |*args| + url_keys = Zoom::Actions.extract_url_keys(url) + params = Zoom::Params.new(Utils.extract_options!(args)) + parsed_url = Zoom::Actions.parse_url(url, url_keys, params) + params = params.require(url_keys) unless url_keys.empty? + params_without_required = required.empty? ? params : params.require(required) + params_without_required.permit(permitted) unless permitted.empty? + response = Zoom::Actions.make_request(self, method, parsed_url, params) + Utils.parse_response(response) + end end end end diff --git a/lib/zoom/actions/account.rb b/lib/zoom/actions/account.rb index adef7b70..9ae1c4ad 100644 --- a/lib/zoom/actions/account.rb +++ b/lib/zoom/actions/account.rb @@ -5,36 +5,31 @@ module Actions module Account extend Zoom::Actions - get_action('account_list', '/accounts', + get 'account_list', '/accounts', permit: %i[page_size page_number] - ) - post_action('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] } - ) - get_action('account_get', '/accounts/:account_id') + get 'account_get', '/accounts/:account_id' - delete_action('account_delete', '/accounts/:account_id') + delete 'account_delete', '/accounts/:account_id' - patch_action('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_action('account_settings_get', '/accounts/:account_id/settings', + get 'account_settings_get', '/accounts/:account_id/settings', permit: :option - ) - patch_action('account_settings_update', '/accounts/:account_id/settings', + patch 'account_settings_update', '/accounts/:account_id/settings', permit: [:option, Zoom::Constants::Account::Settings::PERMITTED_KEYS] - ) - get_action('account_managed_domains', '/accounts/:account_id/managed_domains') + get 'account_managed_domains', '/accounts/:account_id/managed_domains' - get_action('account_get_locked_settings', '/accounts/:account_id/lock_settings') + get 'account_get_locked_settings', '/accounts/:account_id/lock_settings' - get_action('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 19bdbe5a..fb122991 100644 --- a/lib/zoom/actions/billing.rb +++ b/lib/zoom/actions/billing.rb @@ -5,40 +5,21 @@ module Actions module Billing extend Zoom::Actions - define_action( - name: 'billing_get', - method: :get, - url: '/accounts/:account_id/billing' - ) + get 'billing_get', '/accounts/:account_id/billing' - define_action( - name: 'billing_update', - method: :patch, - url: '/accounts/:account_id/billing', - permitted: %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] - define_action( - name: 'billing_plans_list', - method: :get, - url: '/accounts/:account_id/plans' - ) + get 'billing_plans_list', '/accounts/:account_id/plans' - define_action( - name: 'billing_plans_usage', - method: :get, - url: '/accounts/:account_id/plans/usage' - ) + get 'billing_plans_usage', '/accounts/:account_id/plans/usage' - define_action( - name: 'billing_plans_subscribe', - method: :post, - url: '/accounts/:account_id/plans', - required: { + 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] }, - permitted: [ + permit: [ :plan_recording, { contact: %i[apt], @@ -55,7 +36,6 @@ module Billing } } ] - ) end end end diff --git a/lib/zoom/actions/dashboard.rb b/lib/zoom/actions/dashboard.rb index 914eecf0..9c45cfcc 100644 --- a/lib/zoom/actions/dashboard.rb +++ b/lib/zoom/actions/dashboard.rb @@ -5,34 +5,18 @@ module Actions module Dashboard extend Zoom::Actions - define_action( - name: 'dashboard_crc', - method: :get, - url: '/metrics/crc', - required: %i[from to] - ) + get 'dashboard_crc', '/metrics/crc', + require: %i[from to] - define_action( - name: 'dashboard_meetings', - method: :get, - url: '/metrics/meetings', - required: %i[from to], - permitted: %i[next_page_token page_size type] - ) + get 'dashboard_meetings', '/metrics/meetings', + require: %i[from to], + permit: %i[next_page_token page_size type] - define_action( - name: 'dashboard_meeting_details', - method: :get, - url: '/metrics/meetings/:meeting_id', - permitted: :type - ) + get 'dashboard_meeting_details', '/metrics/meetings/:meeting_id', + permit: :type - define_action( - name: 'dashboard_meeting_participants', - method: :get, - url: '/metrics/meetings/:meeting_id/participants', - permitted: %i[next_page_token page_size type] - ) + get 'dashboard_meeting_participants', '/metrics/meetings/:meeting_id/participants', + permit: %i[next_page_token page_size type] end end end diff --git a/lib/zoom/actions/groups.rb b/lib/zoom/actions/groups.rb index 81fff270..8146e2c8 100644 --- a/lib/zoom/actions/groups.rb +++ b/lib/zoom/actions/groups.rb @@ -5,17 +5,9 @@ module Actions module Groups extend Zoom::Actions - define_action( - name: 'groups_list', - method: :get, - url: '/groups' - ) + get 'groups_list', '/groups' - define_action( - name: 'groups_get', - method: :get, - url: '/groups/:group_id' - ) + get 'groups_get', '/groups/:group_id' end end end \ No newline at end of file diff --git a/lib/zoom/actions/meeting.rb b/lib/zoom/actions/meeting.rb index ef5dfa59..197b27c7 100644 --- a/lib/zoom/actions/meeting.rb +++ b/lib/zoom/actions/meeting.rb @@ -6,31 +6,19 @@ module Meeting extend Zoom::Actions # List all the scheduled meetings on Zoom. - define_action( - name: 'meeting_list', - method: :get, - url: '/users/:user_id/meetings', - permitted: %i[type page_size next_page_token page_number] - ) + 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 - define_action( - name: 'meeting_create', - method: :post, - url: '/users/:user_id/meetings', - permitted: %i[ + post 'meeting_create', '/users/:user_id/meetings', + permit: %i[ topic type start_time duration schedule_for timezone password agenda tracking_fields recurrence settings ] - ) # Get a meeting on Zoom via meeting ID, return the meeting info. - define_action( - name: 'meeting_get', - method: :get, - url: '/meetings/:meeting_id/', - permitted: %i[occurrence_id show_previous_occurrences] - ) + get 'meeting_get', '/meetings/:meeting_id/', + permit: %i[occurrence_id show_previous_occurrences] # Update meeting info on Zoom via meeting ID. # TODO Handle `topic` attr, Max of 300 characters. @@ -38,75 +26,39 @@ 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". - define_action( - name: 'meeting_update', - method: :patch, - url: '/meetings/:meeting_id' - ) + patch 'meeting_update', '/meetings/:meeting_id' # Delete a meeting on Zoom, return the deleted meeting ID. - define_action( - name: 'meeting_delete', - method: :delete, - url: '/meetings/:meeting_id' - ) + delete 'meeting_delete', '/meetings/:meeting_id' # Update a meeting's status - define_action( - name: 'meeting_update_status', - method: :put, - url: '/meetings/:meeting_id/status', - permitted: :action - ) + put 'meeting_update_status', '/meetings/:meeting_id/status', + permit: :action # Register for a meeting. - define_action( - name: 'meeting_add_registrant', - method: :post, - url: '/meetings/:meeting_id/registrants', - required: %i[email first_name], - permitted: %i[ + 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 purchasing_time_frame role_in_purchase_process no_of_employees comments custom_questions language occurrence_ids ] - ) # Register for a meeting. - define_action( - name: 'meeting_registrant_questions', - method: :patch, - url: '/meeting/:meeting_id/registrants/questions' - ) + patch 'meeting_registrant_questions', '/meeting/:meeting_id/registrants/questions' # Retrieve ended meeting details - define_action( - name: 'past_meeting_details', - method: :get, - url: '/past_meetings/:meeting_uuid' - ) + get 'past_meeting_details', '/past_meetings/:meeting_uuid' # Retrieve ended meeting participants - define_action( - name: 'past_meeting_participants', - method: :get, - url: '/past_meetings/:meeting_uuid/participants' - ) + get 'past_meeting_participants', '/past_meetings/:meeting_uuid/participants' - define_action( - name: 'livestream', - method: :patch, - url: '/meetings/:meeting_id/livestream', - required: %i[stream_url stream_key], - permitted: :page_url - ) + 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. - define_action( - name: 'meeting_invitation', - method: :get, - url: '/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 c09ebd82..749f46a3 100644 --- a/lib/zoom/actions/phone.rb +++ b/lib/zoom/actions/phone.rb @@ -5,23 +5,11 @@ module Actions module Phone extend Zoom::Actions - define_action( - name: 'call_logs', - method: :get, - url: '/phone/users/:user_id/call_logs' - ) + get 'call_logs', '/phone/users/:user_id/call_logs' - define_action( - name: 'phone_users_list', - method: :get, - url: '/phone/users' - ) + get 'phone_users_list', '/phone/users' - define_action( - name: 'call_recordings', - method: :get, - url: '/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 8f2632b7..c6ce9176 100644 --- a/lib/zoom/actions/recording.rb +++ b/lib/zoom/actions/recording.rb @@ -9,36 +9,16 @@ module Recording authentication_option authentication_domains viewer_download password on_demand approval_type send_email_to_host show_social_share_buttons].freeze - define_action( - name: 'recording_list', - method: :get, - url: '/users/:user_id/recordings' - ) + get 'recording_list', '/users/:user_id/recordings' - define_action( - name: 'meeting_recording_get', - method: :get, - url: '/meetings/:meeting_id/recordings/settings' - ) + get 'meeting_recording_get', '/meetings/:meeting_id/recordings/settings' - define_action( - name: 'meeting_recording_settings_get', - method: :get, - url: '/meetings/:meeting_id/recordings/settings' - ) + get 'meeting_recording_settings_get', '/meetings/:meeting_id/recordings/settings' - define_action( - name: 'meeting_recording_settings_update', - method: :patch, - url: '/meetings/:meeting_id/recordings/settings', - permitted: RECORDING_SETTINGS_KEYS - ) + patch 'meeting_recording_settings_update', '/meetings/:meeting_id/recordings/settings', + permit: RECORDING_SETTINGS_KEYS - define_action( - name: 'meeting_recording_file_delete', - method: :delete, - url: '/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 a53ce25a..37ef77bd 100644 --- a/lib/zoom/actions/report.rb +++ b/lib/zoom/actions/report.rb @@ -5,32 +5,16 @@ module Actions module Report extend Zoom::Actions - define_action( - name: 'daily_report', - method: :get, - url: '/report/daily', - permitted: %i[year month] - ) + get 'daily_report', '/report/daily', + permit: %i[year month] - define_action( - name: 'meeting_details_report', - method: :get, - url: '/report/meetings/:id' - ) + get 'meeting_details_report', '/report/meetings/:id' - define_action( - name: 'meeting_participants_report', - method: :get, - url: '/report/meetings/:id/participants', - permitted: %i[page_size next_page_token] - ) + get 'meeting_participants_report', '/report/meetings/:id/participants', + permit: %i[page_size next_page_token] - define_action( - name: 'webinar_participants_report', - method: :get, - url: '/report/webinars/:id/participants', - permitted: %i[page_size next_page_token] - ) + get 'webinar_participants_report', '/report/webinars/:id/participants', + permit: %i[page_size next_page_token] end end end From 50f2a02485adb93e280e674b79c18e7472ae03b0 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 15:38:23 -0700 Subject: [PATCH 17/29] Update Roles and SipAudio --- lib/zoom/actions/roles.rb | 39 ++++++------------- lib/zoom/actions/sip_audio.rb | 73 ++++++++--------------------------- 2 files changed, 27 insertions(+), 85 deletions(-) diff --git a/lib/zoom/actions/roles.rb b/lib/zoom/actions/roles.rb index f4fa1eae..10a7fd13 100644 --- a/lib/zoom/actions/roles.rb +++ b/lib/zoom/actions/roles.rb @@ -3,39 +3,22 @@ module Zoom module Actions module Roles - def roles_list(*_args) - Utils.parse_response self.class.get("/roles", headers: request_headers) - end + extend Zoom::Actions - def roles_create(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:name).permit(%i[description privileges]) - Utils.parse_response self.class.post("/roles", body: params.to_json, headers: request_headers) - end + get 'roles_list', '/roles' - def roles_members(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:role_id) - Utils.parse_response self.class.get("/roles/#{params[:role_id]}/members", headers: request_headers) - end + post 'roles_create', '/roles', + require: :name, + permit: %i[description privileges] - def roles_assign(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[role_id members]) - Utils.parse_response self.class.post("/roles/#{params[:role_id]}/members", body: params.except(:role_id).to_json, headers: request_headers) - end + get 'roles_members', '/roles/:role_id/members' - def roles_unassign(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[role_id member_id]) - Utils.parse_response self.class.delete("/roles/#{params[:role_id]}/members/#{params[:member_id]}", headers: request_headers) - end + post 'roles_assign', '/roles/:role_id/members', + require: :members - def roles_get(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:role_id) - Utils.parse_response self.class.get("/roles/#{params[:role_id]}", headers: request_headers) - end + delete 'roles_unassign', '/roles/:role_id/members/:member_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 743d121c..03550766 100644 --- a/lib/zoom/actions/sip_audio.rb +++ b/lib/zoom/actions/sip_audio.rb @@ -3,73 +3,32 @@ module Zoom module Actions module SipAudio - def sip_trunks_get(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - Utils.parse_response self.class.get("/accounts/#{params[:account_id]}/sip_trunk/trunks", headers: request_headers) - end + extend Zoom::Actions - def sip_trunks_delete(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id, :trunk_id) - Utils.parse_response self.class.delete("/accounts/#{params[:account_id]}/sip_trunk/trunks/#{params[:trunk_id]}", headers: request_headers) - end + get 'sip_trunks_get', '/accounts/:account_id/sip_trunk/trunks' - def sip_trunk_numbers_delete(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - Utils.parse_response self.class.delete("/accounts/#{params[:account_id]}/sip_trunk/numbers", headers: request_headers) - end + delete 'sip_trunks_delete', '/accounts/:account_id/sip_trunk/trunks/:trunk_id' - def sip_trunks_internal_numbers_delete(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[account_id number_id]) - Utils.parse_response self.class.delete("/accounts/#{params[:account_id]}/sip_trunk/internal_numbers/#{params[:number_id]}", headers: request_headers) - end + delete 'sip_trunk_numbers_delete', '/accounts/:account_id/sip_trunk/numbers' - def sip_trunks_internal_callout_country_delete(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[account_id country_id]) - Utils.parse_response self.class.delete("/accounts/#{params[:account_id]}/sip_trunk/callout_countries/#{params[:country_id]}", headers: request_headers) - end + delete 'sip_trunks_internal_numbers_delete', + '/accounts/:account_id/sip_trunk/internal_numbers/:number_id' - def sip_trunks_internal_numbers_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id).permit(%i[page_size next_page_token]) - response = self.class.get("/accounts/#{params[:account_id]}/sip_trunk/internal_numbers", query: params, headers: request_headers) - Utils.parse_response(response) - end + delete 'sip_trunks_internal_callout_country_delete', + '/accounts/:account_id/sip_trunk/callout_countries/:country_id' - def sip_trunks_internal_callout_country_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - response = self.class.get("/accounts/#{params[:account_id]}/sip_trunk/callout_countries", headers: request_headers) - Utils.parse_response(response) - end + get 'sip_trunks_internal_numbers_list', '/accounts/:account_id/sip_trunk/internal_numbers', + permit: %i[page_size next_page_token] - def sip_trunks_numbers_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - response = self.class.get("/sip_trunk/numbers", headers: request_headers) - Utils.parse_response(response) - end + get 'sip_trunks_internal_callout_country_list', '/accounts/:account_id/sip_trunk/callout_countries' - def sip_trunks_internal_numbers_add(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - Utils.parse_response self.class.post("/accounts/#{params[:account_id]}/sip_trunk/internal_numbers", headers: request_headers) - end + get 'sip_trunks_numbers_list', '/sip_trunk/numbers' - def sip_trunks_internal_callout_countries_add(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - Utils.parse_response self.class.post("/accounts/#{params[:account_id]}/sip_trunk/callout_countries", headers: request_headers) - end + post 'sip_trunks_internal_numbers_add', '/accounts/:account_id/sip_trunk/internal_numbers' - def sip_trunks_numbers_assign(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:account_id) - Utils.parse_response self.class.post("/accounts/#{params[:account_id]}/sip_trunk/numbers", headers: request_headers) - end + 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' end end end From bdac0c8a44b71dd0297e629cfbf229ff1827dff9 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 15:42:04 -0700 Subject: [PATCH 18/29] Update Token and add base_uri support --- lib/zoom/actions.rb | 13 ++++++------- lib/zoom/actions/token.rb | 39 +++++++++++++++------------------------ 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index d4ccf771..b7969656 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -15,10 +15,9 @@ def self.parse_url(url, url_keys, params) parsed_url end - def self.make_request(obj, method, parsed_url, filtered_params) - request_options = { - headers: obj.request_headers - } + def self.make_request(obj, method, parsed_url, filtered_params, base_uri) + request_options = { headers: obj.request_headers } + request_options[:base_uri] = base_uri if base_uri case method when :get request_options[:query] = filtered_params @@ -29,8 +28,8 @@ def self.make_request(obj, method, parsed_url, filtered_params) end [:get, :post, :patch, :put, :delete].each do |method| - define_method(method) do |name, url, validations={}| - required, permitted = validations.values_at :require, :permit + define_method(method) do |name, url, options={}| + required, permitted, base_uri = options.values_at :require, :permit, :base_uri required = Array(required) unless required.is_a?(Hash) permitted = Array(permitted) unless permitted.is_a?(Hash) @@ -41,7 +40,7 @@ def self.make_request(obj, method, parsed_url, filtered_params) params = params.require(url_keys) unless url_keys.empty? params_without_required = required.empty? ? params : params.require(required) params_without_required.permit(permitted) unless permitted.empty? - response = Zoom::Actions.make_request(self, method, parsed_url, params) + response = Zoom::Actions.make_request(self, method, parsed_url, params, base_uri) Utils.parse_response(response) end end diff --git a/lib/zoom/actions/token.rb b/lib/zoom/actions/token.rb index 30c523f1..5fcff33e 100644 --- a/lib/zoom/actions/token.rb +++ b/lib/zoom/actions/token.rb @@ -3,33 +3,24 @@ module Zoom module Actions module Token - def access_tokens(*args) - options = Zoom::Params.new(Utils.extract_options!(args)) - options.require(%i[auth_code redirect_uri]) - response = self.class.post("/oauth/token?grant_type=authorization_code&code=#{options[:auth_code]}&redirect_uri=#{options[:redirect_uri]}", headers: oauth_request_headers, base_uri: 'https://zoom.us/') - Utils.parse_response(response) - end + extend Zoom::Actions - def refresh_tokens(*args) - options = Zoom::Params.new(Utils.extract_options!(args)) - options.require(:refresh_token) - response = self.class.post("/oauth/token?grant_type=refresh_token&refresh_token=#{options[:refresh_token]}", headers: oauth_request_headers, base_uri: 'https://zoom.us/') - Utils.parse_response(response) - end + post 'access_tokens', + '/oauth/token?grant_type=authorization_code&code=:auth_code&redirect_uri=:redirect_uri', + base_uri: 'https://zoom.us/' - def data_compliance(*args) - options = Zoom::Params.new(Utils.extract_options!(args)) - options.require(%i[client_id user_id account_id deauthorization_event_received compliance_completed]) - response = self.class.post("/oauth/data/compliance", body: options.to_json, headers: oauth_request_headers, base_uri: 'https://zoom.us/') - Utils.parse_response response - end + post 'refresh_tokens', + '/oauth/token?grant_type=refresh_token&refresh_token=:refresh_token', + base_uri: 'https://zoom.us/' - def revoke_tokens(*args) - options = Zoom::Params.new(Utils.extract_options!(args)) - options.require(%i[access_token]) - response = self.class.post("/oauth/revoke?token=#{options[:access_token]}", headers: oauth_request_headers, base_uri: 'https://zoom.us/') - Utils.parse_response(response) - end + post 'data_compliance', '/oauth/data/compliance', + base_uri: 'https://zoom.us/', + require: %i[ + client_id user_id account_id deauthorization_event_received compliance_completed + ] + + post 'revoke_tokens', '/oauth/revoke?token=:access_token', + base_uri: 'https://zoom.us/' end end end From bd3cedb6e1f641481a223e15d77cb53bf02ca3eb Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 15:58:07 -0700 Subject: [PATCH 19/29] Update User, except one method --- lib/zoom/actions/user.rb | 130 ++++++++++----------------------------- 1 file changed, 33 insertions(+), 97 deletions(-) diff --git a/lib/zoom/actions/user.rb b/lib/zoom/actions/user.rb index e4cc2673..e0e94107 100644 --- a/lib/zoom/actions/user.rb +++ b/lib/zoom/actions/user.rb @@ -3,12 +3,10 @@ module Zoom module Actions module User - def user_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.permit(%i[status page_size role_id page_number include_fields next_page_token]) - response = self.class.get('/users', query: params, headers: request_headers) - Utils.parse_response(response) - end + extend Zoom::Actions + + get 'user_list', '/users', + permit: %i[status page_size role_id page_number include_fields next_page_token] def user_create(*args) params = Zoom::Params.new(Utils.extract_options!(args)) @@ -19,114 +17,52 @@ def user_create(*args) Utils.parse_response self.class.post('/users', body: { action: params[:action], user_info: params.except(:action) }.to_json, headers: request_headers) end - def user_get(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id).permit(:login_type) - Utils.parse_response self.class.get("/users/#{params[:id]}", query: params.except(:id), headers: request_headers) - end - - def user_update(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id).permit(%i[first_name last_name type pmi timezone dept vanity_name host_key cms_user_id]) - Utils.parse_response self.class.patch("/users/#{params[:id]}", body: params.except(:id), headers: request_headers) - end + get 'user_get', '/users/:id', + permit: :login_type - def user_delete(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id).permit(%i[action transfer_email transfer_meeting transfer_webinar transfer_recording]) - Utils.parse_response self.class.delete("/users/#{params[:id]}", query: params.except(:id), headers: request_headers) - end + patch 'user_update', '/users/:id', + permit: %i[first_name last_name type pmi timezone dept vanity_name host_key cms_user_id] - def user_assistants_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:user_id) - Utils.parse_response(self.class.get("/users/#{params[:user_id]}/assistants", query: params.except(:user_id), headers: request_headers)) - end + delete 'user_delete', '/users/:id', + permit: %i[action transfer_email transfer_meeting transfer_webinar transfer_recording] - def user_assistants_create(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:user_id).permit(:assistants) - Utils.parse_response self.class.post("/users/#{params[:user_id]}/assistants", body: params.except(:user_id).to_json, headers: request_headers) - end + get 'user_assistants_list', '/users/:user_id/assistants' - def user_assistants_delete_all(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:user_id) - Utils.parse_response(self.class.delete("/users/#{params[:user_id]}/assistants", query: params.except(:user_id), headers: request_headers)) - end + post 'user_assistants_create', '/users/:user_id/assistants', + permit: :assistants - def user_assistants_delete(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[user_id assistant_id]) - Utils.parse_response(self.class.delete("/users/#{params[:user_id]}/assistants/#{params[:assistant_id]}", query: params.except(:user_id, :assistant_id), headers: request_headers)) - end + delete 'user_assistants_delete_all', '/users/:user_id/assistants' - def user_schedulers_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:user_id) - Utils.parse_response(self.class.get("/users/#{params[:user_id]}/schedulers", query: params.except(:user_id), headers: request_headers)) - end + delete 'user_assistants_delete', '/users/:user_id/assistants/:assistant_id' - def user_schedulers_delete_all(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:user_id) - Utils.parse_response(self.class.delete("/users/#{params[:user_id]}/schedulers", query: params.except(:user_id), headers: request_headers)) - end + get 'user_schedulers_list', '/users/:user_id/schedulers' - def user_schedulers_delete(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[user_id scheduler_id]) - Utils.parse_response(self.class.delete("/users/#{params[:user_id]}/schedulers/#{params[:scheduler_id]}", query: params.except(:user_id, :scheduler_id), headers: request_headers)) - end + delete 'user_schedulers_delete_all', '/users/:user_id/schedulers' - def user_settings_get(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id).permit(:login_type) - Utils.parse_response self.class.get("/users/#{params[:id]}/settings", query: params.except(:id), headers: request_headers) - end + delete 'user_schedulers_delete', '/users/:user_id/schedulers/:scheduler_id' - def user_settings_update(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id).permit(%i[schedule_meeting in_meeting email_notification recording telephony feature tsp]) - Utils.parse_response self.class.patch("/users/#{params[:id]}/settings", body: params.except(:id).to_json, headers: request_headers) - end + get 'user_settings_get', '/users/:id/settings', + permit: :login_type - def user_email_check(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:email) - Utils.parse_response(self.class.get('/users/email', query: params.slice(:email), headers: request_headers)) - end + patch 'user_settings_update', '/users/:id/settings', + permit: %i[schedule_meeting in_meeting email_notification recording telephony feature tsp] - def user_recordings_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id).permit(%i[page_size next_page_token mc trash from to trash_type]) - Utils.parse_response self.class.get("/users/#{params[:id]}/recordings", query: params.except(:id), headers: request_headers) - end + get 'user_email_check', '/users/email', + require: :email - def user_token(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:user_id).permit(%i[type ttl]) - Utils.parse_response self.class.get("/users/#{params[:user_id]}/token", query: params.except(:user_id), headers: request_headers) - end + get 'user_recordings_list', '/users/:id/recordings', + permit: %i[page_size next_page_token mc trash from to trash_type] - def user_permissions(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:user_id) - Utils.parse_response self.class.get("/users/#{params[:user_id]}/permissions", headers: request_headers) - end + get 'user_token', '/users/:user_id/token', + permit: %i[type ttl] - def user_vanity_name(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:vanity_name) - Utils.parse_response self.class.get("/users/vanity_name", query: params.slice(:vanity_name), headers: request_headers) - end + get 'user_permissions', '/users/:user_id/permissions' - def user_password_update(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id).permit(%i[password]) - Utils.parse_response self.class.patch("/users/#{params[:id]}/password", body: params.except(:id), headers: request_headers) - end + get 'user_vanity_name', '/users/vanity_name', + require: :vanity_name + patch 'user_password_update', '/users/:id/password', + permit: :password end end end From 908f91af09db545c8816da11788a050e26c5bd08 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 16:08:03 -0700 Subject: [PATCH 20/29] Update Webinar --- lib/zoom/actions/webinar.rb | 114 ++++++++++++------------------------ 1 file changed, 37 insertions(+), 77 deletions(-) diff --git a/lib/zoom/actions/webinar.rb b/lib/zoom/actions/webinar.rb index 8a106983..af5aa2c5 100644 --- a/lib/zoom/actions/webinar.rb +++ b/lib/zoom/actions/webinar.rb @@ -3,6 +3,8 @@ module Zoom module Actions 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 SETTINGS_KEYS = %i[host_video panelists_video practice_session hd_video approval_type @@ -14,95 +16,53 @@ module Webinar post_webinar_survey survey_url registrants_email_notification meeting_authentication authentication_option authentication_domains registrants_confirmation_email question_answer].freeze - def webinar_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:host_id).permit(%i[page_size page_number]) - Utils.parse_response self.class.get("/users/#{params[:host_id]}/webinars", query: params.except(:host_id), headers: request_headers) - end - def webinar_create(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:host_id).permit(:topic, :type, :start_time, :duration, - :timezone, :password, :agenda, - recurrence: RECURRENCE_KEYS, - settings: SETTINGS_KEYS) - # TODO: process recurrence keys based on constants - # TODO: process settings keys based on constants - Utils.parse_response self.class.post("/users/#{params[:host_id]}/webinars", body: params.except(:host_id).to_json, headers: request_headers) - end + get 'webinar_list', '/users/:host_id/webinars', + permit: %i[page_size page_number] + + # TODO: process recurrence keys based on constants + # TODO: process settings keys based on constants + post 'webinar_create', '/users/:host_id/webinars', + permit: [ + :topic, :type, :start_time, :duration, :timezone, :password, :agenda, + { recurrence: RECURRENCE_KEYS, settings: SETTINGS_KEYS } + ] - def webinar_get(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id) - Utils.parse_response self.class.get("/webinars/#{params[:id]}", headers: request_headers) - end + get 'webinar_get', '/webinars/:id' - def webinar_update(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id).permit(:topic, :type, :start_time, :duration, - :timezone, :password, :agenda, - recurrence: RECURRENCE_KEYS, - settings: SETTINGS_KEYS) - Utils.parse_response self.class.patch("/webinars/#{params[:id]}", body: params.except(:id).to_json, headers: request_headers) - end + patch 'webinar_update', '/webinars/:id', + permit: [ + :topic, :type, :start_time, :duration, :timezone, :password, :agenda, + { recurrence: RECURRENCE_KEYS, settings: SETTINGS_KEYS } + ] - def webinar_delete(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id).permit(:occurrence_id) - Utils.parse_response self.class.delete("/webinars/#{params[:id]}", query: params.except(:id), headers: request_headers) - end + delete 'webinar_delete', '/webinars/:id', + permit: :occurrence_id - def webinar_registrants_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id).permit(%i[occurrence_id status page_size page_number]) - Utils.parse_response self.class.get("/webinars/#{params[:id]}/registrants", query: params.except(:id), headers: request_headers) - end + get 'webinar_registrants_list', '/webinars/:id/registrants', + permit: %i[occurrence_id status page_size page_number] - def webinar_registrant_add(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[id 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]) - Utils.parse_response self.class.post("/webinars/#{params[:id]}/registrants", body: params.except(:id, :occurrence_ids).to_json, query: params.slice(:occurrence_ids), headers: request_headers) - end + 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 + ] - def webinar_registrants_status_update(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[id action]) - .permit(:occurrence_id, registrants: []) - Utils.parse_response self.class.put("/webinars/#{params[:id]}/registrants/status", body: params.except(:id, :occurrence_id).to_json, query: params.slice(:occurrence_id), headers: request_headers) - end + put 'webinar_registrants_status_update', '/webinars/:id/registrants/status', + require: :action, + permit: [ :occurrence_id, registrants: [] ] - def past_webinar_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:id) - Utils.parse_response self.class.get("/past_webinars/#{params[:id]}/instances", headers: request_headers) - end + get 'past_webinar_list', '/past_webinars/:id/instances' - def webinar_registrant_get(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[webinar_id id]).permit(:occurrence_id) - Utils.parse_response self.class.get("/webinars/#{params[:webinar_id]}/registrants/#{params[:id]}", query: params.except(:webinar_id, :id), headers: request_headers) - end + get 'webinar_registrant_get', '/webinars/:webinar_id/registrants/:id', + permit: :occurrence_id - def webinar_polls_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:webinar_id) - Utils.parse_response self.class.get("/webinars/#{params[:webinar_id]}/polls", headers: request_headers) - end + get 'webinar_polls_list', '/webinars/:webinar_id/polls' - def webinar_poll_get(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(%i[webinar_id poll_id]) - Utils.parse_response self.class.get("/webinars/#{params[:webinar_id]}/polls/#{params[:poll_id]}", headers: request_headers) - end + get 'webinar_poll_get', '/webinars/:webinar_id/polls/:poll_id' - def webinar_panelist_list(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:webinar_id) - Utils.parse_response self.class.get("/webinars/#{params[:webinar_id]}/panelists", headers: request_headers) - end + get 'webinar_panelist_list', '/webinars/:webinar_id/panelists' end end end From be9abbaecaa24faa055bf434fea8d84d0844cdad Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 16:21:39 -0700 Subject: [PATCH 21/29] Update Chat Make get actions actual gets. --- lib/zoom/actions/im/chat.rb | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/lib/zoom/actions/im/chat.rb b/lib/zoom/actions/im/chat.rb index 7e294a0c..0a900772 100644 --- a/lib/zoom/actions/im/chat.rb +++ b/lib/zoom/actions/im/chat.rb @@ -4,35 +4,22 @@ module Zoom module Actions module IM module Chat - def get_chat_channels(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:channel_id) - Utils.parse_response self.class.get("/chat/channels/#{params[:channel_id]}", headers: request_headers) - end + extend Zoom::Actions - def get_chat_user_channels(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - params.require(:user_id).permit(%i[next_page_token page_size]) - Utils.parse_response self.class.get("/chat/users/#{params[:user_id]}/channels", query: params.except(:user_id), headers: request_headers) - end + get 'get_chat_channels', '/chat/channels/:channel_id' + + get 'get_chat_user_channels', '/chat/users/:user_id/channels', + permit: %i[next_page_token page_size] # Get chat messages for a specified period. - def chat_get(*args) - options = Utils.extract_options!(args) - Zoom::Params.new(options).require(:access_token, :session_id, :from, :to) - # TODO: handle date format for `from` and `to` params - # TODO: implement `next_page_token`, will be returned whenever the set of available chat history list exceeds 100. The expiration period is 30 minutes. - Utils.parse_response self.class.post('/chat/get', query: options) - end + # 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 history list for a specified time period. - def chat_list(*args) - options = Utils.extract_options!(args) - Zoom::Params.new(options).require(:access_token, :from, :to) - # TODO: handle date format for `from` and `to` params - # TODO: implement `next_page_token`, will be returned whenever the set of available chat history list exceeds 100. The expiration period is 30 minutes. - Utils.parse_response self.class.post('/chat/list', query: options) - end + # 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 ] end end end From a165ea9dc3f16a380c23606dcbfbbed600278648 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 22 Oct 2021 16:24:48 -0700 Subject: [PATCH 22/29] Minor cleanup Params not filtered_params, add a newline to the end of a file --- lib/zoom/actions.rb | 6 +++--- lib/zoom/actions/groups.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index b7969656..c5a89085 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -15,14 +15,14 @@ def self.parse_url(url, url_keys, params) parsed_url end - def self.make_request(obj, method, parsed_url, filtered_params, base_uri) + def self.make_request(obj, method, parsed_url, params, base_uri) request_options = { headers: obj.request_headers } request_options[:base_uri] = base_uri if base_uri case method when :get - request_options[:query] = filtered_params + request_options[:query] = params when :post, :patch - request_options[:body] = filtered_params.to_json + request_options[:body] = params.to_json end obj.class.public_send(method, parsed_url, **request_options) end diff --git a/lib/zoom/actions/groups.rb b/lib/zoom/actions/groups.rb index 8146e2c8..071e9ccb 100644 --- a/lib/zoom/actions/groups.rb +++ b/lib/zoom/actions/groups.rb @@ -10,4 +10,4 @@ module Groups get 'groups_get', '/groups/:group_id' end end -end \ No newline at end of file +end From 5db609c7e829df5d80ff6dc00fafd801514ba2f4 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 5 Nov 2021 14:14:10 -0700 Subject: [PATCH 23/29] Simplify user_create This is a breaking change! This function was defined with a few special qualities that I was not willing to add to the refactored system. These include: - Validating which values are acceptable for "action". - Optionally requiring "password" if action is set to autoCreate. - Passing user info values in the root of the hash instead of inside a user_info hash. This third item actually creates a breaking API change for users of zoom_rb who use the user_create method. The actual API requires this user_info hash, but this method deviated from the original API. I think it is better for the Ruby API to track with the actual API. So users of this library should update their code to wrap the user info values in a user_info hash. This should be noted in the Changelog, as this refactor is intended to be released as a major version release, specifically version 1.0. --- lib/zoom/actions/user.rb | 16 +++--- spec/lib/zoom/actions/user/create_spec.rb | 64 +++++++---------------- 2 files changed, 26 insertions(+), 54 deletions(-) diff --git a/lib/zoom/actions/user.rb b/lib/zoom/actions/user.rb index e0e94107..de4ddbcb 100644 --- a/lib/zoom/actions/user.rb +++ b/lib/zoom/actions/user.rb @@ -8,14 +8,14 @@ module User get 'user_list', '/users', permit: %i[status page_size role_id page_number include_fields next_page_token] - def user_create(*args) - params = Zoom::Params.new(Utils.extract_options!(args)) - require_param_keys = %i[action email type] - require_param_keys.append(:password) if params[:action] == 'autoCreate' - params.require(require_param_keys) - params.permit_value(:action, Zoom::Constants::User::CREATE_TYPES.keys) - Utils.parse_response self.class.post('/users', body: { action: params[:action], user_info: params.except(:action) }.to_json, headers: request_headers) - end + post 'user_create', '/users', + require: [ + :action, + user_info: %i[email type] + ], + permit: { + user_info: %i[first_name last_name password] + } get 'user_get', '/users/:id', permit: :login_type diff --git a/spec/lib/zoom/actions/user/create_spec.rb b/spec/lib/zoom/actions/user/create_spec.rb index 1193661f..fb4371f9 100644 --- a/spec/lib/zoom/actions/user/create_spec.rb +++ b/spec/lib/zoom/actions/user/create_spec.rb @@ -5,12 +5,16 @@ describe Zoom::Actions::User do let(:zc) { zoom_client } let(:args) do - { action: 'create', - email: 'foo@bar.com', - first_name: 'Zoomie', - last_name: 'Userton', - type: 1, - password: 'testerino' } + { + action: 'create', + user_info: { + email: 'foo@bar.com', + type: 1, + first_name: 'Zoomie', + last_name: 'Userton', + password: 'testerino' + } + } end describe '#user_create' do @@ -28,46 +32,14 @@ expect { zc.user_create(filter_key(args, :action)) }.to raise_error(Zoom::ParameterMissing, [:action].to_s) end - it 'does not raise an error when action is create' do - args[:action] = 'create' - expect { zc.user_create(args) }.not_to raise_error - end - - it 'does not raise an error when action is custCreate' do - args[:action] = 'custCreate' - expect { zc.user_create(args) }.not_to raise_error - end - - it 'does not raise an error when action is autoCreate' do - args[:action] = 'autoCreate' - expect { zc.user_create(args) }.not_to raise_error - end - - it 'does not raise an error when action is ssoCreate' do - args[:action] = 'ssoCreate' - expect { zc.user_create(args) }.not_to raise_error - end - - it 'requires valid action' do - args[:action] = 'baz' - expect { zc.user_create(args) }.to raise_error(Zoom::ParameterValueNotPermitted, "#{:action.to_s}: #{args[:action].to_s}") - end - it 'requires email param' do - expect { zc.user_create(filter_key(args, :email)) }.to raise_error(Zoom::ParameterMissing, [:email].to_s) + 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 - expect { zc.user_create(filter_key(args, :type)) }.to raise_error(Zoom::ParameterMissing, [:type].to_s) - end - - it 'does not require password param when action is not autoCreate' do - expect { zc.user_create(filter_key(args, :password)) }.not_to raise_error - end - - it 'requires password param when action is autoCreate' do - args[:action] = 'autoCreate' - expect { zc.user_create(filter_key(args, :password)) }.to raise_error(Zoom::ParameterMissing, [:password].to_s) + 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 @@ -77,10 +49,10 @@ it 'returns same params' do res = zc.user_create(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[: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 From 720a197dea9161726af147cfa24174f077ba6137 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 12 Nov 2021 16:18:14 -0800 Subject: [PATCH 24/29] Add Zoom::Actions spec Currently tests extract_url_keys and parse_url. --- spec/lib/zoom/actions_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 spec/lib/zoom/actions_spec.rb diff --git a/spec/lib/zoom/actions_spec.rb b/spec/lib/zoom/actions_spec.rb new file mode 100644 index 00000000..5be3d07f --- /dev/null +++ b/spec/lib/zoom/actions_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Zoom::Actions do + describe 'self.extract_url_keys' do + subject { described_class.extract_url_keys(url) } + + let(:url) { 'https://example.com/:id/foo/:bar' } + + it { is_expected.to contain_exactly(:id, :bar) } + end + + describe 'self.parse_url' do + subject { described_class.parse_url(url, url_keys, params) } + + let(:url) { 'https://example.com/:id/foo/:bar' } + let(:url_keys) { [:id, :bar] } + let(:params) { { id: 100, bar: 'baz' } } + + it { is_expected.to eq('https://example.com/100/foo/baz') } + end +end From 963afbc39727801eb2149ae13be47d7e2ceb1a02 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 12 Nov 2021 16:47:14 -0800 Subject: [PATCH 25/29] Rename url methods to path Add make_request specs. --- lib/zoom/actions.rb | 32 ++++++------ spec/lib/zoom/actions_spec.rb | 94 ++++++++++++++++++++++++++++++++--- 2 files changed, 102 insertions(+), 24 deletions(-) diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index c5a89085..360bd699 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -2,45 +2,45 @@ module Zoom module Actions - def self.extract_url_keys(url) - url.scan(/:\w+/).map { |match| match[1..].to_sym } + def self.extract_path_keys(path) + path.scan(/:\w+/).map { |match| match[1..].to_sym } end - def self.parse_url(url, url_keys, params) - parsed_url = url.dup - url_keys.each do |key| + def self.parse_path(path, path_keys, params) + parsed_path = path.dup + path_keys.each do |key| value = params[key].to_s - parsed_url = parsed_url.sub(":#{key}", value) + parsed_path = parsed_path.sub(":#{key}", value) end - parsed_url + parsed_path end - def self.make_request(obj, method, parsed_url, params, base_uri) - request_options = { headers: obj.request_headers } + def self.make_request(client, method, parsed_path, params, base_uri) + request_options = { headers: client.request_headers } request_options[:base_uri] = base_uri if base_uri case method when :get request_options[:query] = params - when :post, :patch + when :post, :put, :patch request_options[:body] = params.to_json end - obj.class.public_send(method, parsed_url, **request_options) + client.class.public_send(method, parsed_path, **request_options) end [:get, :post, :patch, :put, :delete].each do |method| - define_method(method) do |name, url, options={}| + define_method(method) do |name, path, options={}| required, permitted, base_uri = options.values_at :require, :permit, :base_uri required = Array(required) unless required.is_a?(Hash) permitted = Array(permitted) unless permitted.is_a?(Hash) define_method(name) do |*args| - url_keys = Zoom::Actions.extract_url_keys(url) + path_keys = Zoom::Actions.extract_path_keys(path) params = Zoom::Params.new(Utils.extract_options!(args)) - parsed_url = Zoom::Actions.parse_url(url, url_keys, params) - params = params.require(url_keys) unless url_keys.empty? + parsed_path = Zoom::Actions.parse_path(path, path_keys, params) + params = params.require(path_keys) unless path_keys.empty? params_without_required = required.empty? ? params : params.require(required) params_without_required.permit(permitted) unless permitted.empty? - response = Zoom::Actions.make_request(self, method, parsed_url, params, base_uri) + response = Zoom::Actions.make_request(self, method, parsed_path, params, base_uri) Utils.parse_response(response) end end diff --git a/spec/lib/zoom/actions_spec.rb b/spec/lib/zoom/actions_spec.rb index 5be3d07f..350a29a5 100644 --- a/spec/lib/zoom/actions_spec.rb +++ b/spec/lib/zoom/actions_spec.rb @@ -3,21 +3,99 @@ require 'spec_helper' describe Zoom::Actions do - describe 'self.extract_url_keys' do - subject { described_class.extract_url_keys(url) } + describe 'self.extract_path_keys' do + subject { described_class.extract_path_keys(path) } - let(:url) { 'https://example.com/:id/foo/:bar' } + let(:path) { '/:id/foo/:bar' } it { is_expected.to contain_exactly(:id, :bar) } end - describe 'self.parse_url' do - subject { described_class.parse_url(url, url_keys, params) } + describe 'self.parse_path' do + subject { described_class.parse_path(path, path_keys, params) } - let(:url) { 'https://example.com/:id/foo/:bar' } - let(:url_keys) { [:id, :bar] } + let(:path) { '/:id/foo/:bar' } + let(:path_keys) { [:id, :bar] } let(:params) { { id: 100, bar: 'baz' } } - it { is_expected.to eq('https://example.com/100/foo/baz') } + it { is_expected.to eq('/100/foo/baz') } + end + + describe 'self.make_request' do + subject { described_class.make_request(client, method, parsed_path, params, base_uri) } + + let(:client) { Zoom::Client::OAuth.new(access_token: 'xxx', timeout: 15) } + let(:parsed_path) { '/100/foo/baz' } + let(:params) { { id: 100, bar: 'baz' } } + let(:base_uri) { 'https://example.com' } + + context 'when get' do + let(:method) { :get } + + it 'calls get method on client with get request_options' do + request_options = { + headers: client.request_headers, + query: params, + base_uri: base_uri + } + expect(client.class).to receive(method).with(parsed_path, request_options) + subject + end + end + + context 'when post' do + let(:method) { :post } + + it 'calls post method on client with post request_options' do + request_options = { + headers: client.request_headers, + body: params.to_json, + base_uri: base_uri + } + expect(client.class).to receive(method).with(parsed_path, request_options) + subject + end + end + + context 'when put' do + let(:method) { :put } + + it 'calls put method on client with put request_options' do + request_options = { + headers: client.request_headers, + body: params.to_json, + base_uri: base_uri + } + expect(client.class).to receive(method).with(parsed_path, **request_options) + subject + end + end + + context 'when patch' do + let(:method) { :patch } + + it 'calls patch method on client with patch request_options' do + request_options = { + headers: client.request_headers, + body: params.to_json, + base_uri: base_uri + } + expect(client.class).to receive(method).with(parsed_path, **request_options) + subject + end + end + + context 'when delete' do + let(:method) { :delete } + + it 'calls delete method on client with delete request_options' do + request_options = { + headers: client.request_headers, + base_uri: base_uri + } + expect(client.class).to receive(method).with(parsed_path, **request_options) + subject + end + end end end From 330294e6f0b23a120a10f97c5e5b14b9c4d2030b Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 12 Nov 2021 16:55:33 -0800 Subject: [PATCH 26/29] Remove some redundancy --- spec/lib/zoom/actions_spec.rb | 59 +++++++++++++---------------------- 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/spec/lib/zoom/actions_spec.rb b/spec/lib/zoom/actions_spec.rb index 350a29a5..2e66998f 100644 --- a/spec/lib/zoom/actions_spec.rb +++ b/spec/lib/zoom/actions_spec.rb @@ -3,42 +3,41 @@ require 'spec_helper' describe Zoom::Actions do + 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(:base_uri) { 'https://example.com' } + let(:parsed_path) { '/100/foo/baz' } + describe 'self.extract_path_keys' do subject { described_class.extract_path_keys(path) } - - let(:path) { '/:id/foo/:bar' } - it { is_expected.to contain_exactly(:id, :bar) } + it { is_expected.to match_array(path_keys) } end describe 'self.parse_path' do subject { described_class.parse_path(path, path_keys, params) } - let(:path) { '/:id/foo/:bar' } - let(:path_keys) { [:id, :bar] } - let(:params) { { id: 100, bar: 'baz' } } - - it { is_expected.to eq('/100/foo/baz') } + it { is_expected.to eq(parsed_path) } end describe 'self.make_request' do subject { described_class.make_request(client, method, parsed_path, params, base_uri) } - let(:client) { Zoom::Client::OAuth.new(access_token: 'xxx', timeout: 15) } - let(:parsed_path) { '/100/foo/baz' } - let(:params) { { id: 100, bar: 'baz' } } - let(:base_uri) { 'https://example.com' } + let(:request_options) { + { + headers: client.request_headers, + base_uri: base_uri + } + } context 'when get' do let(:method) { :get } it 'calls get method on client with get request_options' do - request_options = { - headers: client.request_headers, - query: params, - base_uri: base_uri - } - expect(client.class).to receive(method).with(parsed_path, request_options) + request_options[:query] = params + expect(client.class).to receive(method).with(parsed_path, **request_options) subject end end @@ -47,12 +46,8 @@ let(:method) { :post } it 'calls post method on client with post request_options' do - request_options = { - headers: client.request_headers, - body: params.to_json, - base_uri: base_uri - } - expect(client.class).to receive(method).with(parsed_path, request_options) + request_options[:body] = params.to_json + expect(client.class).to receive(method).with(parsed_path, **request_options) subject end end @@ -61,11 +56,7 @@ let(:method) { :put } it 'calls put method on client with put request_options' do - request_options = { - headers: client.request_headers, - body: params.to_json, - base_uri: base_uri - } + request_options[:body] = params.to_json expect(client.class).to receive(method).with(parsed_path, **request_options) subject end @@ -75,11 +66,7 @@ let(:method) { :patch } it 'calls patch method on client with patch request_options' do - request_options = { - headers: client.request_headers, - body: params.to_json, - base_uri: base_uri - } + request_options[:body] = params.to_json expect(client.class).to receive(method).with(parsed_path, **request_options) subject end @@ -89,10 +76,6 @@ let(:method) { :delete } it 'calls delete method on client with delete request_options' do - request_options = { - headers: client.request_headers, - base_uri: base_uri - } expect(client.class).to receive(method).with(parsed_path, **request_options) subject end From 9221e0fbe9ed1da4a6ef76e9b88f76bfe3bf3108 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Tue, 30 Nov 2021 14:55:19 -0800 Subject: [PATCH 27/29] Minor whitespace cleanup --- lib/zoom/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zoom/actions.rb b/lib/zoom/actions.rb index 360bd699..4241fe6b 100644 --- a/lib/zoom/actions.rb +++ b/lib/zoom/actions.rb @@ -9,7 +9,7 @@ def self.extract_path_keys(path) def self.parse_path(path, path_keys, params) parsed_path = path.dup path_keys.each do |key| - value = params[key].to_s + value = params[key].to_s parsed_path = parsed_path.sub(":#{key}", value) end parsed_path From d56080a157db68cf41be0418c35f086bd9ec40b8 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 17 Dec 2021 16:10:24 -0800 Subject: [PATCH 28/29] Change version to 1.0.0 Add a Changelog entry which particularly notes the breaking change to user_create. --- CHANGELOG.md | 36 ++++++++++++++++++++++++++++++++++++ Gemfile.lock | 12 ++++++------ lib/zoom/version.rb | 2 +- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afc8aec4..1d576440 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,39 @@ +# 1.0.0 + +The 1.0 release and a major refactor of all endpoint definitions. + +### Breaking Change +* The `user_create` endpoint now requires its arguments to match the actual Zoom API. + This is done to simplify the code and encourage consistency. + This means that instead of passing: + ``` + { + action: 'create', + email: 'foo@bar.com', + type: 1, + first_name: 'Zoomie', + last_name: 'Userton', + password: 'testerino' + } + ``` + You will instead have to pass: + ``` + { + action: 'create', + user_info: { + email: 'foo@bar.com', + type: 1, + first_name: 'Zoomie', + last_name: 'Userton', + password: 'testerino' + } + } + ``` + Zoom API reference for user creation: https://marketplace.zoom.us/docs/api-reference/zoom-api/users/usercreate + +### New features +* Greatly simplified new syntax when adding endpoints. This reduces repetition and makes it easier. + # 0.11.0 This is the first CHANGELOG entry. diff --git a/Gemfile.lock b/Gemfile.lock index d78e8ea0..b7e5efdc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - zoom_rb (0.11.0) + zoom_rb (1.0.0) httparty (~> 0.13) json (>= 1.8) jwt @@ -31,17 +31,17 @@ GEM rubocop-performance (>= 1.3.0) rubocop-rails (>= 2.0.0) rubocop-rspec (>= 1.33.0) - httparty (0.18.1) + httparty (0.20.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) i18n (1.8.10) concurrent-ruby (~> 1.0) json (2.5.1) - jwt (2.2.3) + jwt (2.3.0) method_source (1.0.0) - mime-types (3.3.1) + mime-types (3.4.1) mime-types-data (~> 3.2015) - mime-types-data (3.2021.0704) + mime-types-data (3.2021.1115) minitest (5.14.4) multi_xml (0.6.0) parallel (1.20.1) @@ -122,4 +122,4 @@ DEPENDENCIES zoom_rb! BUNDLED WITH - 2.2.24 + 2.2.32 diff --git a/lib/zoom/version.rb b/lib/zoom/version.rb index 1445e7a3..42ee816b 100644 --- a/lib/zoom/version.rb +++ b/lib/zoom/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Zoom - VERSION = '0.11.0' + VERSION = '1.0.0' end From 5ab3a12607d8f3934fbdbe58942deccb177f8c21 Mon Sep 17 00:00:00 2001 From: Joel Hayhurst Date: Fri, 17 Dec 2021 16:29:49 -0800 Subject: [PATCH 29/29] Note the addition of new endpoints in the Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d576440..41b63ded 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,8 @@ The 1.0 release and a major refactor of all endpoint definitions. ### New features * Greatly simplified new syntax when adding endpoints. This reduces repetition and makes it easier. +* On `user_settings_get`, permit `option` and `custom_query_fields`. +* Add `group_create` and `group_update`. # 0.11.0