class ProcessOut::CardInformation

Attributes

bank_name[R]
brand[R]
category[R]
country[R]
iin[R]
scheme[R]
type[R]

Public Class Methods

new(client, data = {}) click to toggle source

Initializes the CardInformation object Params:

client

ProcessOut client instance

data

data that can be used to fill the object

# File lib/processout/card_information.rb, line 53
def initialize(client, data = {})
  @client = client

  self.iin = data.fetch(:iin, nil)
  self.scheme = data.fetch(:scheme, nil)
  self.type = data.fetch(:type, nil)
  self.bank_name = data.fetch(:bank_name, nil)
  self.brand = data.fetch(:brand, nil)
  self.category = data.fetch(:category, nil)
  self.country = data.fetch(:country, nil)
  
end

Public Instance Methods

bank_name=(val) click to toggle source
# File lib/processout/card_information.rb, line 32
def bank_name=(val)
  @bank_name = val
end
brand=(val) click to toggle source
# File lib/processout/card_information.rb, line 36
def brand=(val)
  @brand = val
end
category=(val) click to toggle source
# File lib/processout/card_information.rb, line 40
def category=(val)
  @category = val
end
country=(val) click to toggle source
# File lib/processout/card_information.rb, line 44
def country=(val)
  @country = val
end
fetch(iin, options = {}) click to toggle source

Fetch card information from the IIN. Params:

iin

IIN of the card (first 6 digits)

options

Hash of options

# File lib/processout/card_information.rb, line 138
def fetch(iin, options = {})
  self.prefill(options)

  request = Request.new(@client)
  path    = "/iins/" + CGI.escape(iin) + ""
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  return_values = Array.new
  
  body = response.body
  body = body["card_information"]
  
  
  obj = CardInformation.new(@client)
  return_values.push(obj.fill_with_data(body))
  

  
  return_values[0]
end
fill_with_data(data) click to toggle source

Fills the object with data coming from the API Params:

data

Hash of data coming from the API

# File lib/processout/card_information.rb, line 87
def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "iin"
    self.iin = data["iin"]
  end
  if data.include? "scheme"
    self.scheme = data["scheme"]
  end
  if data.include? "type"
    self.type = data["type"]
  end
  if data.include? "bank_name"
    self.bank_name = data["bank_name"]
  end
  if data.include? "brand"
    self.brand = data["brand"]
  end
  if data.include? "category"
    self.category = data["category"]
  end
  if data.include? "country"
    self.country = data["country"]
  end
  
  self
end
iin=(val) click to toggle source
# File lib/processout/card_information.rb, line 20
def iin=(val)
  @iin = val
end
new(data = {}) click to toggle source

Create a new CardInformation using the current client

# File lib/processout/card_information.rb, line 67
def new(data = {})
  CardInformation.new(@client, data)
end
prefill(data) click to toggle source

Prefills the object with the data passed as parameters Params:

data

Hash of data

# File lib/processout/card_information.rb, line 119
def prefill(data)
  if data.nil?
    return self
  end
  self.iin = data.fetch(:iin, self.iin)
  self.scheme = data.fetch(:scheme, self.scheme)
  self.type = data.fetch(:type, self.type)
  self.bank_name = data.fetch(:bank_name, self.bank_name)
  self.brand = data.fetch(:brand, self.brand)
  self.category = data.fetch(:category, self.category)
  self.country = data.fetch(:country, self.country)
  
  self
end
scheme=(val) click to toggle source
# File lib/processout/card_information.rb, line 24
def scheme=(val)
  @scheme = val
end
to_json(options) click to toggle source

Overrides the JSON marshaller to only send the fields we want

# File lib/processout/card_information.rb, line 72
def to_json(options)
  {
      "iin": self.iin,
      "scheme": self.scheme,
      "type": self.type,
      "bank_name": self.bank_name,
      "brand": self.brand,
      "category": self.category,
      "country": self.country,
  }.to_json
end
type=(val) click to toggle source
# File lib/processout/card_information.rb, line 28
def type=(val)
  @type = val
end