class Affirm::RequestError
Attributes
http_response[R]
Public Class Methods
new(http_response)
click to toggle source
Calls superclass method
# File lib/affirm/error.rb, line 8 def initialize(http_response) @http_response = http_response super(message_from(http_response)) end
Private Instance Methods
message_from(http_response)
click to toggle source
# File lib/affirm/error.rb, line 15 def message_from(http_response) return http_response if http_response.class == String content_type = http_response.header["Content-Type"] if content_type&.start_with?("application/json") JSON.parse(http_response.body)["message"] end end