Class: ProcessOut::CardInformation
- Inherits:
-
Object
- Object
- ProcessOut::CardInformation
- Defined in:
- lib/processout/card_information.rb
Instance Attribute Summary collapse
-
#bank_name ⇒ Object
Returns the value of attribute bank_name.
-
#brand ⇒ Object
Returns the value of attribute brand.
-
#category ⇒ Object
Returns the value of attribute category.
-
#country ⇒ Object
Returns the value of attribute country.
-
#iin ⇒ Object
Returns the value of attribute iin.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#fetch(iin, options = {}) ⇒ Object
Fetch card information from the IIN.
-
#fill_with_data(data) ⇒ Object
- Fills the object with data coming from the API Params:
data
-
Hash
of data coming from the API.
- Fills the object with data coming from the API Params:
-
#initialize(client, data = {}) ⇒ CardInformation
constructor
- Initializes the CardInformation object Params:
client
ProcessOut
client instancedata
-
data that can be used to fill the object.
- Initializes the CardInformation object Params:
-
#new(data = {}) ⇒ Object
Create a new CardInformation using the current client.
-
#prefill(data) ⇒ Object
- Prefills the object with the data passed as parameters Params:
data
-
Hash
of data.
- Prefills the object with the data passed as parameters Params:
-
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want.
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
53 54 55 56 57 58 59 60 61 62 63 64 |
# 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 |
Instance Attribute Details
#bank_name ⇒ Object
Returns the value of attribute bank_name.
14 15 16 |
# File 'lib/processout/card_information.rb', line 14 def bank_name @bank_name end |
#brand ⇒ Object
Returns the value of attribute brand.
15 16 17 |
# File 'lib/processout/card_information.rb', line 15 def brand @brand end |
#category ⇒ Object
Returns the value of attribute category.
16 17 18 |
# File 'lib/processout/card_information.rb', line 16 def category @category end |
#country ⇒ Object
Returns the value of attribute country.
17 18 19 |
# File 'lib/processout/card_information.rb', line 17 def country @country end |
#iin ⇒ Object
Returns the value of attribute iin.
11 12 13 |
# File 'lib/processout/card_information.rb', line 11 def iin @iin end |
#scheme ⇒ Object
Returns the value of attribute scheme.
12 13 14 |
# File 'lib/processout/card_information.rb', line 12 def scheme @scheme end |
#type ⇒ Object
Returns the value of attribute type.
13 14 15 |
# File 'lib/processout/card_information.rb', line 13 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
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/processout/card_information.rb', line 138 def fetch(iin, = {}) self.prefill() request = Request.new(@client) path = "/iins/" + CGI.escape(iin) + "" data = { } response = Response.new(request.get(path, data, )) 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
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# 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 |
#new(data = {}) ⇒ Object
Create a new CardInformation using the current client
67 68 69 |
# File 'lib/processout/card_information.rb', line 67 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
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# 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 |
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/processout/card_information.rb', line 72 def to_json() { "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 |