class Ingenico::Connect::SDK::ResponseException

Exception used internally in the SDK to indicate an error response was received from the Ingenico ePayments platform.

@attr_reader [Integer] status_code HTTP status code that was returned by the Ingenico ePayments platform @attr_reader [String] body HTTP message body that was returned by the Ingenico ePayments platform @attr_reader [Array<Ingenico:Connect:SDK:ResponseHeader>] headers HTTP headers used in the response from the Ingenico ePayments platform

Attributes

body[R]
headers[R]
status_code[R]

Public Class Methods

new(status_code, headers, body) click to toggle source
Calls superclass method
# File lib/ingenico/connect/sdk/response_exception.rb, line 10
def initialize(status_code, headers, body)
  super('the Ingenico ePayments platform returned an error response')
  @status_code = status_code
  @headers = if headers.nil? or headers.empty?
               {}
             else
               headers.inject({}) do |hash, header|
                 hash[header.name.downcase.to_sym] = header.dup.freeze
                 hash
               end
             end.freeze
  @body = body
end

Public Instance Methods

get_header(header_name) click to toggle source

Returns the {Ingenico::Connect::SDK::ResponseHeader} that corresponds to the given header_name used in the HTTP response from the Ingenico ePayments platform, or nil if the header was not present in the response.

# File lib/ingenico/connect/sdk/response_exception.rb, line 30
def get_header(header_name)
  ResponseHeader.get_header(@headers, header_name)
end
get_header_value(header_name) click to toggle source

Returns the header value received that corresponds to the header named by header_name, or nil if header_name was not a header present in the HTTP response.

# File lib/ingenico/connect/sdk/response_exception.rb, line 36
def get_header_value(header_name)
  ResponseHeader.get_header_value(@headers, header_name)
end
to_s() click to toggle source
Calls superclass method
# File lib/ingenico/connect/sdk/response_exception.rb, line 40
def to_s
  str = super.to_s
  if @status_code > 0
    str += '; status_code=' + @status_code.to_s
  end
  if !@body.nil? && @body.length > 0
    str += "; response_body='" + @body + "'"
  end
  str.to_s
end