Module: Profitwell::Common
Constant Summary collapse
- ERROR_CODES =
{ 400 => BadRequest, 401 => Unauthorized, 404 => NotFound, 502 => BadGateway, }.freeze
Instance Method Summary collapse
- #request(http_method, endpoint, options: {}) ⇒ Object
- #resource_path(path = nil, options = "") ⇒ Object
Instance Method Details
#request(http_method, endpoint, options: {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/profitwell/common.rb', line 18 def request(http_method, endpoint, options: {}) response = HTTParty.send(http_method, endpoint, params().merge!()) if response.success? parse_success response else parse_failed response end end |
#resource_path(path = nil, options = "") ⇒ Object
12 13 14 15 16 |
# File 'lib/profitwell/common.rb', line 12 def resource_path(path = nil, = "") return "#{base_endpoint}/#{path}/?#{}" if .nil? "#{base_endpoint}/#{path}/" end |