Class: ProcessOut::Card
- Inherits:
-
Object
- Object
- ProcessOut::Card
- Defined in:
- lib/processout/card.rb
Instance Attribute Summary collapse
-
#address1 ⇒ Object
Returns the value of attribute address1.
-
#address2 ⇒ Object
Returns the value of attribute address2.
-
#avs_check ⇒ Object
Returns the value of attribute avs_check.
-
#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.
-
#city ⇒ Object
Returns the value of attribute city.
-
#co_scheme ⇒ Object
Returns the value of attribute co_scheme.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#cvc_check ⇒ Object
Returns the value of attribute cvc_check.
-
#exp_month ⇒ Object
Returns the value of attribute exp_month.
-
#exp_year ⇒ Object
Returns the value of attribute exp_year.
-
#expires_soon ⇒ Object
Returns the value of attribute expires_soon.
-
#fingerprint ⇒ Object
Returns the value of attribute fingerprint.
-
#has_been_authorized ⇒ Object
Returns the value of attribute has_been_authorized.
-
#id ⇒ Object
Returns the value of attribute id.
-
#iin ⇒ Object
Returns the value of attribute iin.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#last_4_digits ⇒ Object
Returns the value of attribute last_4_digits.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#preferred_scheme ⇒ Object
Returns the value of attribute preferred_scheme.
-
#project ⇒ Object
Returns the value of attribute project.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#state ⇒ Object
Returns the value of attribute state.
-
#token ⇒ Object
Returns the value of attribute token.
-
#token_type ⇒ Object
Returns the value of attribute token_type.
-
#type ⇒ Object
Returns the value of attribute type.
-
#used ⇒ Object
Returns the value of attribute used.
-
#zip ⇒ Object
Returns the value of attribute zip.
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
Get all the cards.
-
#anonymize(options = {}) ⇒ Object
Anonymize the card.
-
#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:
-
#find(card_id, options = {}) ⇒ Object
Find a card by its ID.
-
#initialize(client, data = {}) ⇒ Card
constructor
- Initializes the Card object Params:
client
ProcessOut
client 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
-
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 = {}) ⇒ Card
Initializes the Card object Params:
client
-
ProcessOut
client instance data
-
data that can be used to fill the object
207 208 209 210 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 |
# File 'lib/processout/card.rb', line 207 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.co_scheme = data.fetch(:co_scheme, nil) self.preferred_scheme = data.fetch(:preferred_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.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.fingerprint = data.fetch(:fingerprint, nil) self.token_type = data.fetch(:token_type, nil) self.used = data.fetch(:used, nil) self. = data.fetch(:has_been_authorized, 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
#address1 ⇒ Object
Returns the value of attribute address1.
29 30 31 |
# File 'lib/processout/card.rb', line 29 def address1 @address1 end |
#address2 ⇒ Object
Returns the value of attribute address2.
30 31 32 |
# File 'lib/processout/card.rb', line 30 def address2 @address2 end |
#avs_check ⇒ Object
Returns the value of attribute avs_check.
27 28 29 |
# File 'lib/processout/card.rb', line 27 def avs_check @avs_check end |
#bank_name ⇒ Object
Returns the value of attribute bank_name.
19 20 21 |
# File 'lib/processout/card.rb', line 19 def bank_name @bank_name end |
#brand ⇒ Object
Returns the value of attribute brand.
20 21 22 |
# File 'lib/processout/card.rb', line 20 def brand @brand end |
#category ⇒ Object
Returns the value of attribute category.
21 22 23 |
# File 'lib/processout/card.rb', line 21 def category @category end |
#city ⇒ Object
Returns the value of attribute city.
31 32 33 |
# File 'lib/processout/card.rb', line 31 def city @city end |
#co_scheme ⇒ Object
Returns the value of attribute co_scheme.
16 17 18 |
# File 'lib/processout/card.rb', line 16 def co_scheme @co_scheme end |
#country_code ⇒ Object
Returns the value of attribute country_code.
34 35 36 |
# File 'lib/processout/card.rb', line 34 def country_code @country_code end |
#created_at ⇒ Object
Returns the value of attribute created_at.
43 44 45 |
# File 'lib/processout/card.rb', line 43 def created_at @created_at end |
#cvc_check ⇒ Object
Returns the value of attribute cvc_check.
26 27 28 |
# File 'lib/processout/card.rb', line 26 def cvc_check @cvc_check end |
#exp_month ⇒ Object
Returns the value of attribute exp_month.
24 25 26 |
# File 'lib/processout/card.rb', line 24 def exp_month @exp_month end |
#exp_year ⇒ Object
Returns the value of attribute exp_year.
25 26 27 |
# File 'lib/processout/card.rb', line 25 def exp_year @exp_year end |
#expires_soon ⇒ Object
Returns the value of attribute expires_soon.
41 42 43 |
# File 'lib/processout/card.rb', line 41 def expires_soon @expires_soon end |
#fingerprint ⇒ Object
Returns the value of attribute fingerprint.
36 37 38 |
# File 'lib/processout/card.rb', line 36 def fingerprint @fingerprint end |
#has_been_authorized ⇒ Object
Returns the value of attribute has_been_authorized.
39 40 41 |
# File 'lib/processout/card.rb', line 39 def @has_been_authorized end |
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/processout/card.rb', line 11 def id @id end |
#iin ⇒ Object
Returns the value of attribute iin.
22 23 24 |
# File 'lib/processout/card.rb', line 22 def iin @iin end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
35 36 37 |
# File 'lib/processout/card.rb', line 35 def ip_address @ip_address end |
#last_4_digits ⇒ Object
Returns the value of attribute last_4_digits.
23 24 25 |
# File 'lib/processout/card.rb', line 23 def last_4_digits @last_4_digits end |
#metadata ⇒ Object
Returns the value of attribute metadata.
40 41 42 |
# File 'lib/processout/card.rb', line 40 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
28 29 30 |
# File 'lib/processout/card.rb', line 28 def name @name end |
#preferred_scheme ⇒ Object
Returns the value of attribute preferred_scheme.
17 18 19 |
# File 'lib/processout/card.rb', line 17 def preferred_scheme @preferred_scheme end |
#project ⇒ Object
Returns the value of attribute project.
12 13 14 |
# File 'lib/processout/card.rb', line 12 def project @project end |
#project_id ⇒ Object
Returns the value of attribute project_id.
13 14 15 |
# File 'lib/processout/card.rb', line 13 def project_id @project_id end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
42 43 44 |
# File 'lib/processout/card.rb', line 42 def sandbox @sandbox end |
#scheme ⇒ Object
Returns the value of attribute scheme.
15 16 17 |
# File 'lib/processout/card.rb', line 15 def scheme @scheme end |
#state ⇒ Object
Returns the value of attribute state.
32 33 34 |
# File 'lib/processout/card.rb', line 32 def state @state end |
#token ⇒ Object
Returns the value of attribute token.
14 15 16 |
# File 'lib/processout/card.rb', line 14 def token @token end |
#token_type ⇒ Object
Returns the value of attribute token_type.
37 38 39 |
# File 'lib/processout/card.rb', line 37 def token_type @token_type end |
#type ⇒ Object
Returns the value of attribute type.
18 19 20 |
# File 'lib/processout/card.rb', line 18 def type @type end |
#used ⇒ Object
Returns the value of attribute used.
38 39 40 |
# File 'lib/processout/card.rb', line 38 def used @used end |
#zip ⇒ Object
Returns the value of attribute zip.
33 34 35 |
# File 'lib/processout/card.rb', line 33 def zip @zip end |
Instance Method Details
#all(options = {}) ⇒ Object
Get all the cards. Params:
options
-
Hash
of options
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
# File 'lib/processout/card.rb', line 447 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 |
#anonymize(options = {}) ⇒ Object
Anonymize the card. Params:
options
-
Hash
of options
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
# File 'lib/processout/card.rb', line 505 def anonymize( = {}) self.prefill() request = Request.new(@client) path = "/cards/" + CGI.escape(@id) + "" data = { } response = Response.new(request.delete(path, data, )) return_values = Array.new return_values.push(response.success) 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
293 294 295 296 297 298 299 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 333 334 335 336 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 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/processout/card.rb', line 293 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? "co_scheme" self.co_scheme = data["co_scheme"] end if data.include? "preferred_scheme" self.preferred_scheme = data["preferred_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? "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? "fingerprint" self.fingerprint = data["fingerprint"] end if data.include? "token_type" self.token_type = data["token_type"] end if data.include? "used" self.used = data["used"] end if data.include? "has_been_authorized" self. = data["has_been_authorized"] 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
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
# File 'lib/processout/card.rb', line 478 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
247 248 249 |
# File 'lib/processout/card.rb', line 247 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
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
# File 'lib/processout/card.rb', line 403 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.co_scheme = data.fetch(:co_scheme, self.co_scheme) self.preferred_scheme = data.fetch(:preferred_scheme, self.preferred_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.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.fingerprint = data.fetch(:fingerprint, self.fingerprint) self.token_type = data.fetch(:token_type, self.token_type) self.used = data.fetch(:used, self.used) self. = data.fetch(:has_been_authorized, self.) 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 |
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want
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 |
# File 'lib/processout/card.rb', line 252 def to_json() { "id": self.id, "project": self.project, "project_id": self.project_id, "token": self.token, "scheme": self.scheme, "co_scheme": self.co_scheme, "preferred_scheme": self.preferred_scheme, "type": self.type, "bank_name": self.bank_name, "brand": self.brand, "category": self.category, "iin": self.iin, "last_4_digits": self.last_4_digits, "exp_month": self.exp_month, "exp_year": self.exp_year, "cvc_check": self.cvc_check, "avs_check": self.avs_check, "name": self.name, "address1": self.address1, "address2": self.address2, "city": self.city, "state": self.state, "zip": self.zip, "country_code": self.country_code, "ip_address": self.ip_address, "fingerprint": self.fingerprint, "token_type": self.token_type, "used": self.used, "has_been_authorized": self., "metadata": self., "expires_soon": self.expires_soon, "sandbox": self.sandbox, "created_at": self.created_at, }.to_json end |