class SebElink::Response
Constants
- SUPPORTED_MESSAGES
- SUPPORTED_VERSIONS
Attributes
body[R]
gateway_instance[R]
Public Class Methods
new(gateway_instance, body)
click to toggle source
# File lib/seb_elink/response.rb, line 9 def initialize(gateway_instance, body) @gateway_instance = gateway_instance @body = body end
Public Instance Methods
to_h(mode=:secure)
click to toggle source
# File lib/seb_elink/response.rb, line 34 def to_h(mode=:secure) raise SebElink::InvalidResponseError.new( "The response with body '#{body}' is invalid" ) if mode != :insecure && !valid? @to_h ||= body_hash end
valid?()
click to toggle source
# File lib/seb_elink/response.rb, line 14 def valid? return @valid if defined?(@valid) validate_message_code validate_version footprint = gateway_instance.produce_footprint({ message_code: message_code, version: version, skip_validation: true, data: body_hash }) @valid = gateway_instance.verify({ version: version, message: footprint, base64_signature: body_hash[:IB_CRC] }) end
Private Instance Methods
body_hash()
click to toggle source
# File lib/seb_elink/response.rb, line 43 def body_hash # @body_hash ||= body.split("&").each_with_object({}) do |q_pair, hash| @body_hash ||= CGI.unescape(body).split("&").each_with_object({}) do |pair, hash| split_index = pair.index("=") key, value = pair[0..(split_index - 1)], pair[split_index.next..-1] hash[key.to_sym] = value.to_s end end
message_code()
click to toggle source
# File lib/seb_elink/response.rb, line 52 def message_code return @message_code if defined?(@message_code) @message_code = body_hash[:IB_SERVICE] end
version()
click to toggle source
# File lib/seb_elink/response.rb, line 58 def version return @version if defined?(@version) @version = body_hash[:IB_VERSION] end