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 -
Hashof 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 ProcessOutclient 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 -
Hashof data.
- Prefills the object with the data passed as parameters Params:
Constructor Details
#initialize(client, data = {}) ⇒ CardInformation
Initializes the CardInformation object Params:
client-
ProcessOutclient 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_name ⇒ Object
Returns the value of attribute bank_name.
13 14 15 |
# File 'lib/processout/card_information.rb', line 13 def bank_name @bank_name end |
#brand ⇒ Object
Returns the value of attribute brand.
14 15 16 |
# File 'lib/processout/card_information.rb', line 14 def brand @brand end |
#category ⇒ Object
Returns the value of attribute category.
15 16 17 |
# File 'lib/processout/card_information.rb', line 15 def category @category end |
#country ⇒ Object
Returns the value of attribute country.
16 17 18 |
# File 'lib/processout/card_information.rb', line 16 def country @country end |
#iin ⇒ Object
Returns the value of attribute iin.
10 11 12 |
# File 'lib/processout/card_information.rb', line 10 def iin @iin end |
#scheme ⇒ Object
Returns the value of attribute scheme.
11 12 13 |
# File 'lib/processout/card_information.rb', line 11 def scheme @scheme end |
#type ⇒ Object
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-
Hashof 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, = {}) 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-
Hashof 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-
Hashof 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 |