Class: Cielo::API30::CreditCard
- Inherits:
-
Object
- Object
- Cielo::API30::CreditCard
- Defined in:
- lib/cielo/api30/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
- #as_json(options = {}) ⇒ Object
-
#initialize(args = {}) ⇒ CreditCard
constructor
A new instance of CreditCard.
- #to_json(*options) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ CreditCard
Returns a new instance of CreditCard.
21 22 23 24 25 |
# File 'lib/cielo/api30/credit_card.rb', line 21 def initialize(args = {}) @security_code = args[:security_code] @brand = args[:brand] @card_token = args[:token] end |
Instance Attribute Details
#brand ⇒ String
Credit card brand
12 13 14 |
# File 'lib/cielo/api30/credit_card.rb', line 12 def brand @brand end |
#card_number ⇒ String
Credit card number
12 13 14 |
# File 'lib/cielo/api30/credit_card.rb', line 12 def card_number @card_number end |
#card_token ⇒ String
Card token
12 13 14 |
# File 'lib/cielo/api30/credit_card.rb', line 12 def card_token @card_token end |
#expiration_date ⇒ String
Credit card expiration date
12 13 14 |
# File 'lib/cielo/api30/credit_card.rb', line 12 def expiration_date @expiration_date end |
#holder ⇒ String
Holder name
12 13 14 |
# File 'lib/cielo/api30/credit_card.rb', line 12 def holder @holder end |
#save_card ⇒ Boolean
Whether or not to save the card
12 13 14 |
# File 'lib/cielo/api30/credit_card.rb', line 12 def save_card @save_card end |
#security_code ⇒ String
Credit card security code
12 13 14 |
# File 'lib/cielo/api30/credit_card.rb', line 12 def security_code @security_code end |
Class Method Details
.from_json(data) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cielo/api30/credit_card.rb', line 33 def self.from_json(data) return if data.nil? credit_card = new credit_card.card_number = data["CardNumber"] credit_card.holder = data["Holder"] credit_card.expiration_date = data["ExpirationDate"] credit_card.security_code = data["SecurityCode"] credit_card.save_card = data["SaveCard"] credit_card.brand = data["Brand"] credit_card.card_token = data["CardToken"] credit_card end |
Instance Method Details
#as_json(options = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cielo/api30/credit_card.rb', line 47 def as_json(={}) { CardNumber: @card_number, Holder: @holder, ExpirationDate: @expiration_date, SecurityCode: @security_code, SaveCard: @save_card, Brand: @brand, CardToken: @card_token } end |
#to_json(*options) ⇒ Object
27 28 29 30 31 |
# File 'lib/cielo/api30/credit_card.rb', line 27 def to_json(*) hash = as_json(*) hash.reject! {|k,v| v.nil?} hash.to_json(*) end |