class PayuAPI::Response

Constants

SUCCESS_HTTP_STATUSES
SUCCESS_STATUSES

Public Instance Methods

error?() click to toggle source
# File lib/payu_api/response.rb, line 14
def error?
  !success?
end
error_code() click to toggle source
# File lib/payu_api/response.rb, line 18
def error_code
  return unless error?
  body[:error] || status_code
end
error_message() click to toggle source
# File lib/payu_api/response.rb, line 23
def error_message
  return unless error?
  body[:error_description] || status_description
end
success?() click to toggle source
# File lib/payu_api/response.rb, line 10
def success?
  http_success? && status_success?
end

Private Instance Methods

body() click to toggle source
# File lib/payu_api/response.rb, line 54
def body
  return unless raw_body
  @body ||=
    begin
      JSON.parse(raw_body, symbolize_names: true)
    rescue => e
      raise InvalidResponseError, e.message
    end
end
http_status() click to toggle source
# File lib/payu_api/response.rb, line 34
def http_status
  @http_status ||= http_response.status
end
http_success?() click to toggle source
# File lib/payu_api/response.rb, line 30
def http_success?
  self.class::SUCCESS_HTTP_STATUSES.include?(http_status)
end
raw_body() click to toggle source
# File lib/payu_api/response.rb, line 64
def raw_body
  @raw_body ||= http_response.body
end
status() click to toggle source
# File lib/payu_api/response.rb, line 50
def status
  body[:status] || {}
end
status_code() click to toggle source
# File lib/payu_api/response.rb, line 42
def status_code
  status[:statusCode]
end
status_description() click to toggle source
# File lib/payu_api/response.rb, line 46
def status_description
  status[:statusDesc]
end
status_success?() click to toggle source
# File lib/payu_api/response.rb, line 38
def status_success?
  self.class::SUCCESS_STATUSES.include?(status_code)
end