Class: Zoom::Utils
- Inherits:
-
Object
- Object
- Zoom::Utils
- Defined in:
- lib/zoom/utils.rb
Class Method Summary collapse
- .argument_error(name) ⇒ Object
- .exclude_argument_error(name) ⇒ Object
- .extract_options!(array) ⇒ Object
- .parse_response(http_response) ⇒ Object
- .process_datetime_params!(params, options) ⇒ Object
- .raise_if_error!(response) ⇒ Object
- .validate_password(password) ⇒ Object
Class Method Details
.argument_error(name) ⇒ Object
6 7 8 |
# File 'lib/zoom/utils.rb', line 6 def argument_error(name) name ? ArgumentError.new("You must provide #{name}") : ArgumentError.new end |
.exclude_argument_error(name) ⇒ Object
10 11 12 |
# File 'lib/zoom/utils.rb', line 10 def exclude_argument_error(name) name ? ArgumentError.new("Unrecognized parameter #{name}") : ArgumentError.new end |
.extract_options!(array) ⇒ Object
29 30 31 |
# File 'lib/zoom/utils.rb', line 29 def (array) array.last.is_a?(::Hash) ? array.pop : {} end |
.parse_response(http_response) ⇒ Object
25 26 27 |
# File 'lib/zoom/utils.rb', line 25 def parse_response(http_response) raise_if_error!(http_response.parsed_response) || http_response.code end |
.process_datetime_params!(params, options) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/zoom/utils.rb', line 38 def process_datetime_params!(params, ) params = [params] unless params.is_a? Array params.each do |param| if [param] && [param].kind_of?(Time) [param] = [param].strftime('%FT%TZ') end end end |
.raise_if_error!(response) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/zoom/utils.rb', line 14 def raise_if_error!(response) if response&.[]('code') && response['code'] >= 300 error_hash = { base: response['message']} raise Error, error_hash unless response['errors'] error_hash[response['message']] = response['errors'] raise Error, error_hash else response end end |
.validate_password(password) ⇒ Object
33 34 35 36 |
# File 'lib/zoom/utils.rb', line 33 def validate_password(password) password_regex = /\A[a-zA-Z0-9@-_*]{0,10}\z/ raise(Error , 'Invalid Password') unless password[password_regex].nil? end |