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



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/processout/card_information.rb', line 47

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.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

#countryObject

Returns the value of attribute country.



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

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



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/processout/card_information.rb', line 114

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



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/processout/card_information.rb', line 67

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? "country"
    self.country = data["country"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new CardInformation using the current client



60
61
62
# File 'lib/processout/card_information.rb', line 60

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



96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/processout/card_information.rb', line 96

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.country = data.fetch(:country, self.country)
  
  self
end