Class: ProcessOut::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/processout/card.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data = {}) ⇒ Card

Initializes the Card object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/processout/card.rb', line 171

def initialize(client, data = {})
  @client = client

  self.id = data.fetch(:id, nil)
  self.project = data.fetch(:project, nil)
  self.project_id = data.fetch(:project_id, nil)
  self.token = data.fetch(:token, 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.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.cvc_check = data.fetch(:cvc_check, nil)
  self.avs_check = data.fetch(:avs_check, nil)
  self.name = data.fetch(:name, nil)
  self.address1 = data.fetch(:address1, nil)
  self.address2 = data.fetch(:address2, nil)
  self.city = data.fetch(:city, nil)
  self.state = data.fetch(:state, nil)
  self.zip = data.fetch(:zip, nil)
  self.country_code = data.fetch(:country_code, nil)
  self.ip_address = data.fetch(:ip_address, nil)
  self. = data.fetch(:metadata, nil)
  self.expires_soon = data.fetch(:expires_soon, nil)
  self.sandbox = data.fetch(:sandbox, nil)
  self.created_at = data.fetch(:created_at, nil)
  
end

Instance Attribute Details

#address1Object

Returns the value of attribute address1.



25
26
27
# File 'lib/processout/card.rb', line 25

def address1
  @address1
end

#address2Object

Returns the value of attribute address2.



26
27
28
# File 'lib/processout/card.rb', line 26

def address2
  @address2
end

#avs_checkObject

Returns the value of attribute avs_check.



23
24
25
# File 'lib/processout/card.rb', line 23

def avs_check
  @avs_check
end

#bank_nameObject

Returns the value of attribute bank_name.



16
17
18
# File 'lib/processout/card.rb', line 16

def bank_name
  @bank_name
end

#brandObject

Returns the value of attribute brand.



17
18
19
# File 'lib/processout/card.rb', line 17

def brand
  @brand
end

#cityObject

Returns the value of attribute city.



27
28
29
# File 'lib/processout/card.rb', line 27

def city
  @city
end

#country_codeObject

Returns the value of attribute country_code.



30
31
32
# File 'lib/processout/card.rb', line 30

def country_code
  @country_code
end

#created_atObject

Returns the value of attribute created_at.



35
36
37
# File 'lib/processout/card.rb', line 35

def created_at
  @created_at
end

#cvc_checkObject

Returns the value of attribute cvc_check.



22
23
24
# File 'lib/processout/card.rb', line 22

def cvc_check
  @cvc_check
end

#exp_monthObject

Returns the value of attribute exp_month.



20
21
22
# File 'lib/processout/card.rb', line 20

def exp_month
  @exp_month
end

#exp_yearObject

Returns the value of attribute exp_year.



21
22
23
# File 'lib/processout/card.rb', line 21

def exp_year
  @exp_year
end

#expires_soonObject

Returns the value of attribute expires_soon.



33
34
35
# File 'lib/processout/card.rb', line 33

def expires_soon
  @expires_soon
end

#idObject

Returns the value of attribute id.



10
11
12
# File 'lib/processout/card.rb', line 10

def id
  @id
end

#iinObject

Returns the value of attribute iin.



18
19
20
# File 'lib/processout/card.rb', line 18

def iin
  @iin
end

#ip_addressObject

Returns the value of attribute ip_address.



31
32
33
# File 'lib/processout/card.rb', line 31

def ip_address
  @ip_address
end

#last_4_digitsObject

Returns the value of attribute last_4_digits.



19
20
21
# File 'lib/processout/card.rb', line 19

def last_4_digits
  @last_4_digits
end

#metadataObject

Returns the value of attribute metadata.



32
33
34
# File 'lib/processout/card.rb', line 32

def 
  @metadata
end

#nameObject

Returns the value of attribute name.



24
25
26
# File 'lib/processout/card.rb', line 24

def name
  @name
end

#projectObject

Returns the value of attribute project.



11
12
13
# File 'lib/processout/card.rb', line 11

def project
  @project
end

#project_idObject

Returns the value of attribute project_id.



12
13
14
# File 'lib/processout/card.rb', line 12

def project_id
  @project_id
end

#sandboxObject

Returns the value of attribute sandbox.



34
35
36
# File 'lib/processout/card.rb', line 34

def sandbox
  @sandbox
end

#schemeObject

Returns the value of attribute scheme.



14
15
16
# File 'lib/processout/card.rb', line 14

def scheme
  @scheme
end

#stateObject

Returns the value of attribute state.



28
29
30
# File 'lib/processout/card.rb', line 28

def state
  @state
end

#tokenObject

Returns the value of attribute token.



13
14
15
# File 'lib/processout/card.rb', line 13

def token
  @token
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#zipObject

Returns the value of attribute zip.



29
30
31
# File 'lib/processout/card.rb', line 29

def zip
  @zip
end

Instance Method Details

#all(options = {}) ⇒ Object

Get all the cards. Params:

options

Hash of options



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/processout/card.rb', line 337

def all(options = {})
  self.prefill(options)

  request = Request.new(@client)
  path    = "/cards"
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  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

Hash of data coming from the API



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/processout/card.rb', line 211

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? "project_id"
    self.project_id = data["project_id"]
  end
  if data.include? "token"
    self.token = data["token"]
  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? "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? "cvc_check"
    self.cvc_check = data["cvc_check"]
  end
  if data.include? "avs_check"
    self.avs_check = data["avs_check"]
  end
  if data.include? "name"
    self.name = data["name"]
  end
  if data.include? "address1"
    self.address1 = data["address1"]
  end
  if data.include? "address2"
    self.address2 = data["address2"]
  end
  if data.include? "city"
    self.city = data["city"]
  end
  if data.include? "state"
    self.state = data["state"]
  end
  if data.include? "zip"
    self.zip = data["zip"]
  end
  if data.include? "country_code"
    self.country_code = data["country_code"]
  end
  if data.include? "ip_address"
    self.ip_address = data["ip_address"]
  end
  if data.include? "metadata"
    self. = data["metadata"]
  end
  if data.include? "expires_soon"
    self.expires_soon = data["expires_soon"]
  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

Hash of options



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/processout/card.rb', line 368

def find(card_id, options = {})
  self.prefill(options)

  request = Request.new(@client)
  path    = "/cards/" + CGI.escape(card_id) + ""
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  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



204
205
206
# File 'lib/processout/card.rb', line 204

def new(data = {})
  Card.new(@client, data)
end

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/processout/card.rb', line 300

def prefill(data)
  if data.nil?
    return self
  end
  self.id = data.fetch(:id, self.id)
  self.project = data.fetch(:project, self.project)
  self.project_id = data.fetch(:project_id, self.project_id)
  self.token = data.fetch(:token, self.token)
  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.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.cvc_check = data.fetch(:cvc_check, self.cvc_check)
  self.avs_check = data.fetch(:avs_check, self.avs_check)
  self.name = data.fetch(:name, self.name)
  self.address1 = data.fetch(:address1, self.address1)
  self.address2 = data.fetch(:address2, self.address2)
  self.city = data.fetch(:city, self.city)
  self.state = data.fetch(:state, self.state)
  self.zip = data.fetch(:zip, self.zip)
  self.country_code = data.fetch(:country_code, self.country_code)
  self.ip_address = data.fetch(:ip_address, self.ip_address)
  self. = data.fetch(:metadata, self.)
  self.expires_soon = data.fetch(:expires_soon, self.expires_soon)
  self.sandbox = data.fetch(:sandbox, self.sandbox)
  self.created_at = data.fetch(:created_at, self.created_at)
  
  self
end