Class: Braspag::CreditCard
- Inherits:
-
Object
- Object
- Braspag::CreditCard
- Defined in:
- lib/braspag/api/credit_card.rb
Overview
Credit card data
Instance Attribute Summary collapse
-
#brand ⇒ String
Credit card brand.
-
#card_number ⇒ String
Credit card number.
-
#card_token ⇒ String
Card token.
-
#expiration_date ⇒ String
Credit card expiration date.
-
#holder ⇒ String
Holder name.
-
#save_card ⇒ Boolean
Whether or not to save the card.
-
#security_code ⇒ String
Credit card security code.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ CreditCard
constructor
A new instance of CreditCard.
- #to_json(*options) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ CreditCard
Returns a new instance of CreditCard.
20 21 22 23 24 |
# File 'lib/braspag/api/credit_card.rb', line 20 def initialize(args = {}) @security_code = args[:security_code] @brand = args[:brand] @token = args[:token] end |
Instance Attribute Details
#brand ⇒ String
Credit card brand
11 12 13 |
# File 'lib/braspag/api/credit_card.rb', line 11 def brand @brand end |
#card_number ⇒ String
Credit card number
11 12 13 |
# File 'lib/braspag/api/credit_card.rb', line 11 def card_number @card_number end |
#card_token ⇒ String
Card token
11 12 13 |
# File 'lib/braspag/api/credit_card.rb', line 11 def card_token @card_token end |
#expiration_date ⇒ String
Credit card expiration date
11 12 13 |
# File 'lib/braspag/api/credit_card.rb', line 11 def expiration_date @expiration_date end |
#holder ⇒ String
Holder name
11 12 13 |
# File 'lib/braspag/api/credit_card.rb', line 11 def holder @holder end |
#save_card ⇒ Boolean
Whether or not to save the card
11 12 13 |
# File 'lib/braspag/api/credit_card.rb', line 11 def save_card @save_card end |
#security_code ⇒ String
Credit card security code
11 12 13 |
# File 'lib/braspag/api/credit_card.rb', line 11 def security_code @security_code end |
Class Method Details
.from_json(data) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/braspag/api/credit_card.rb', line 32 def self.from_json(data) if (data != nil) credit_card = CreditCard.new() credit_card.card_number = data["CardNumber"] || nil credit_card.holder = data["Holder"] || nil credit_card.expiration_date = data["ExpirationDate"] || nil credit_card.security_code = data["SecurityCode"] || nil credit_card.save_card = data["SaveCard"] || nil credit_card.brand = data["Brand"] || nil credit_card.card_token = data["CardToken"] || nil return credit_card end end |
Instance Method Details
#to_json(*options) ⇒ Object
26 27 28 29 30 |
# File 'lib/braspag/api/credit_card.rb', line 26 def to_json(*) hash = as_json(*) hash.reject! {|k,v| v.nil?} hash.to_json(*) end |