Class: CardConnect::Service::BinResponse

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/cardconnect/services/bin/bin_response.rb

Constant Summary collapse

FIELDS =
[
  :country, :cardusestring, :gsa, :product,
  :corporate, :fsa, :subtype, :purchase, :prepaid, :binlo,
  :issuer, :binhi
].freeze
BIN_INFO_NOT_FOUND =

Error messages

'No bin information found'
TOKEN_NOT_FOUND =
'Token not found'
BIN_NOT_ENABLED =
'Bin feature not enabled for merchant'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#set_attributes, #symbolize_keys

Constructor Details

#initialize(response) ⇒ BinResponse

Returns a new instance of BinResponse.



20
21
22
23
24
25
# File 'lib/cardconnect/services/bin/bin_response.rb', line 20

def initialize(response)

  set_attributes(response, FIELDS)
 # raise [response, self].inspect
  @errors = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



18
19
20
# File 'lib/cardconnect/services/bin/bin_response.rb', line 18

def errors
  @errors
end

Instance Method Details

#bodyObject



31
32
33
# File 'lib/cardconnect/services/bin/bin_response.rb', line 31

def body
  FIELDS.collect{|attr| {attr => send(attr)} }.reduce({}, :merge)
end

#success?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/cardconnect/services/bin/bin_response.rb', line 27

def success?
  @errors.empty?
end