class Zype::Client
Constants
- ERROR_TYPES
Attributes
headers[R]
Public Instance Methods
delete(path:, params: _)
click to toggle source
# File lib/zype/client.rb, line 43 def delete(path:, params: _) self.class.delete(path, headers: headers) end
execute(method:, path:, params: {})
click to toggle source
# File lib/zype/client.rb, line 47 def execute(method:, path:, params: {}) if Zype.configuration.api_key.to_s.empty? raise NoApiKey if Zype.configuration.app_key.to_s.empty? end resp = send(method, path: path, params: params) if resp.success? resp['response'].nil? ? resp.parsed_response : resp['response'] else error!(code: resp.code, message: resp['message']) end end
get(path:, params: {})
click to toggle source
# File lib/zype/client.rb, line 31 def get(path:, params: {}) self.class.get(path, query: params, headers: headers) end
post(path:, params: {})
click to toggle source
# File lib/zype/client.rb, line 35 def post(path:, params: {}) self.class.post(path, query: params, headers: headers) end
put(path:, params: {})
click to toggle source
# File lib/zype/client.rb, line 39 def put(path:, params: {}) self.class.put(path, query: params, headers: headers) end
Private Instance Methods
authentication(auth_method)
click to toggle source
# File lib/zype/client.rb, line 67 def authentication(auth_method) if auth_method.to_sym == :api_key { 'x-zype-key' => Zype.configuration.api_key } else { 'x-zype-app-key' => Zype.configuration.app_key } end end
error!(code:, message:)
click to toggle source
# File lib/zype/client.rb, line 62 def error!(code:, message:) error_type = ERROR_TYPES[code] || GenericError raise error_type.new(message) end