forked from mllocs/zoomus
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #392 from hintmedia/refactor
Attempt refactor
- Loading branch information
Showing
23 changed files
with
488 additions
and
655 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,41 @@ | ||
# 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: '[email protected]', | ||
type: 1, | ||
first_name: 'Zoomie', | ||
last_name: 'Userton', | ||
password: 'testerino' | ||
} | ||
``` | ||
You will instead have to pass: | ||
``` | ||
{ | ||
action: 'create', | ||
user_info: { | ||
email: '[email protected]', | ||
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. | ||
* On `user_settings_get`, permit `option` and `custom_query_fields`. | ||
* Add `group_create` and `group_update`. | ||
|
||
# 0.11.0 | ||
|
||
This is the first CHANGELOG entry. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# frozen_string_literal: true | ||
|
||
module Zoom | ||
module Actions | ||
def self.extract_path_keys(path) | ||
path.scan(/:\w+/).map { |match| match[1..].to_sym } | ||
end | ||
|
||
def self.parse_path(path, path_keys, params) | ||
parsed_path = path.dup | ||
path_keys.each do |key| | ||
value = params[key].to_s | ||
parsed_path = parsed_path.sub(":#{key}", value) | ||
end | ||
parsed_path | ||
end | ||
|
||
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, :put, :patch | ||
request_options[:body] = params.to_json | ||
end | ||
client.class.public_send(method, parsed_path, **request_options) | ||
end | ||
|
||
[:get, :post, :patch, :put, :delete].each do |method| | ||
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| | ||
path_keys = Zoom::Actions.extract_path_keys(path) | ||
params = Zoom::Params.new(Utils.extract_options!(args)) | ||
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_path, params, base_uri) | ||
Utils.parse_response(response) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.