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.
-
#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
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_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 |
#country ⇒ Object
Returns the value of attribute country.
15 16 17 |
# File 'lib/processout/card_information.rb', line 15 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
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, = {}) 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
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-
Hashof 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 |