Class: ProcessOut::Card
- Inherits:
-
Object
- Object
- ProcessOut::Card
- Defined in:
- lib/processout/card.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.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#exp_month ⇒ Object
Returns the value of attribute exp_month.
-
#exp_year ⇒ Object
Returns the value of attribute exp_year.
-
#id ⇒ Object
Returns the value of attribute id.
-
#iin ⇒ Object
Returns the value of attribute iin.
-
#last_4_digits ⇒ Object
Returns the value of attribute last_4_digits.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#project ⇒ Object
Returns the value of attribute project.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
Get all the cards.
-
#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:
-
#find(card_id, options = {}) ⇒ Object
Find a card by its ID.
-
#initialize(client, data = {}) ⇒ Card
constructor
- Initializes the Card object Params:
client ProcessOutclient instancedata-
data that can be used to fill the object.
- Initializes the Card object Params:
-
#new(data = {}) ⇒ Object
Create a new Card 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 = {}) ⇒ Card
Initializes the Card object Params:
client-
ProcessOutclient instance data-
data that can be used to fill the object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/processout/card.rb', line 94 def initialize(client, data = {}) @client = client self.id = data.fetch(:id, nil) self.project = data.fetch(:project, 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) self.iin = data.fetch(:iin, nil) self.last_4_digits = data.fetch(:last_4_digits, nil) self.exp_month = data.fetch(:exp_month, nil) self.exp_year = data.fetch(:exp_year, nil) self. = data.fetch(:metadata, nil) self.sandbox = data.fetch(:sandbox, nil) self.created_at = data.fetch(:created_at, nil) end |
Instance Attribute Details
#bank_name ⇒ Object
Returns the value of attribute bank_name.
14 15 16 |
# File 'lib/processout/card.rb', line 14 def bank_name @bank_name end |
#brand ⇒ Object
Returns the value of attribute brand.
15 16 17 |
# File 'lib/processout/card.rb', line 15 def brand @brand end |
#country ⇒ Object
Returns the value of attribute country.
16 17 18 |
# File 'lib/processout/card.rb', line 16 def country @country end |
#created_at ⇒ Object
Returns the value of attribute created_at.
23 24 25 |
# File 'lib/processout/card.rb', line 23 def created_at @created_at end |
#exp_month ⇒ Object
Returns the value of attribute exp_month.
19 20 21 |
# File 'lib/processout/card.rb', line 19 def exp_month @exp_month end |
#exp_year ⇒ Object
Returns the value of attribute exp_year.
20 21 22 |
# File 'lib/processout/card.rb', line 20 def exp_year @exp_year end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/processout/card.rb', line 10 def id @id end |
#iin ⇒ Object
Returns the value of attribute iin.
17 18 19 |
# File 'lib/processout/card.rb', line 17 def iin @iin end |
#last_4_digits ⇒ Object
Returns the value of attribute last_4_digits.
18 19 20 |
# File 'lib/processout/card.rb', line 18 def last_4_digits @last_4_digits end |
#metadata ⇒ Object
Returns the value of attribute metadata.
21 22 23 |
# File 'lib/processout/card.rb', line 21 def @metadata end |
#project ⇒ Object
Returns the value of attribute project.
11 12 13 |
# File 'lib/processout/card.rb', line 11 def project @project end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
22 23 24 |
# File 'lib/processout/card.rb', line 22 def sandbox @sandbox end |
#scheme ⇒ Object
Returns the value of attribute scheme.
12 13 14 |
# File 'lib/processout/card.rb', line 12 def scheme @scheme end |
#type ⇒ Object
Returns the value of attribute type.
13 14 15 |
# File 'lib/processout/card.rb', line 13 def type @type end |
Instance Method Details
#all(options = {}) ⇒ Object
Get all the cards. Params:
options-
Hashof options
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/processout/card.rb', line 200 def all( = {}) self.prefill() request = Request.new(@client) path = "/cards" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new a = Array.new body = response.body for v in body['cards'] tmp = Card.new(@client) tmp.fill_with_data(v) a.push(tmp) end return_values.push(a) 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
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/processout/card.rb', line 122 def fill_with_data(data) if data.nil? return self end if data.include? "id" self.id = data["id"] end if data.include? "project" self.project = data["project"] 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 if data.include? "iin" self.iin = data["iin"] end if data.include? "last_4_digits" self.last_4_digits = data["last_4_digits"] end if data.include? "exp_month" self.exp_month = data["exp_month"] end if data.include? "exp_year" self.exp_year = data["exp_year"] end if data.include? "metadata" self. = data["metadata"] end if data.include? "sandbox" self.sandbox = data["sandbox"] end if data.include? "created_at" self.created_at = data["created_at"] end self end |
#find(card_id, options = {}) ⇒ Object
Find a card by its ID. Params:
card_id-
ID of the card
options-
Hashof options
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/processout/card.rb', line 231 def find(card_id, = {}) self.prefill() request = Request.new(@client) path = "/cards/" + CGI.escape(card_id) + "" data = { } response = Response.new(request.get(path, data, )) return_values = Array.new body = response.body body = body["card"] obj = Card.new(@client) return_values.push(obj.fill_with_data(body)) return_values[0] end |
#new(data = {}) ⇒ Object
Create a new Card using the current client
115 116 117 |
# File 'lib/processout/card.rb', line 115 def new(data = {}) Card.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data-
Hashof data
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/processout/card.rb', line 175 def prefill(data) if data.nil? return self end self.id = data.fetch(:id, self.id) self.project = data.fetch(:project, self.project) 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.iin = data.fetch(:iin, self.iin) self.last_4_digits = data.fetch(:last_4_digits, self.last_4_digits) self.exp_month = data.fetch(:exp_month, self.exp_month) self.exp_year = data.fetch(:exp_year, self.exp_year) self. = data.fetch(:metadata, self.) self.sandbox = data.fetch(:sandbox, self.sandbox) self.created_at = data.fetch(:created_at, self.created_at) self end |