Class: ProcessOut::CardInformation

Inherits:
Object
  • Object
show all
Defined in:
lib/processout/card_information.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data = {}) ⇒ CardInformation

Initializes the CardInformation object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/processout/card_information.rb', line 52

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

Instance Attribute Details

#bank_nameObject

Returns the value of attribute bank_name.



13
14
15
# File 'lib/processout/card_information.rb', line 13

def bank_name
  @bank_name
end

#brandObject

Returns the value of attribute brand.



14
15
16
# File 'lib/processout/card_information.rb', line 14

def brand
  @brand
end

#categoryObject

Returns the value of attribute category.



15
16
17
# File 'lib/processout/card_information.rb', line 15

def category
  @category
end

#countryObject

Returns the value of attribute country.



16
17
18
# File 'lib/processout/card_information.rb', line 16

def country
  @country
end

#iinObject

Returns the value of attribute iin.



10
11
12
# File 'lib/processout/card_information.rb', line 10

def iin
  @iin
end

#schemeObject

Returns the value of attribute scheme.



11
12
13
# File 'lib/processout/card_information.rb', line 11

def scheme
  @scheme
end

#typeObject

Returns the value of attribute type.



12
13
14
# File 'lib/processout/card_information.rb', line 12

def type
  @type
end

Instance Method Details

#fetch(iin, options = {}) ⇒ Object

Fetch card information from the IIN. Params:

iin

IIN of the card (first 6 digits)

options

Hash of options



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/processout/card_information.rb', line 124

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) ⇒ Object

Fills the object with data coming from the API Params:

data

Hash of data coming from the API



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/processout/card_information.rb', line 73

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

#new(data = {}) ⇒ Object

Create a new CardInformation using the current client



66
67
68
# File 'lib/processout/card_information.rb', line 66

def new(data = {})
  CardInformation.new(@client, data)
end

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/processout/card_information.rb', line 105

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