Class: Pagseguro::Charge::CreditCard
- Inherits:
-
Object
- Object
- Pagseguro::Charge::CreditCard
- Defined in:
- lib/pagseguro/charge/credit_card.rb,
lib/pagseguro/charge/payment_credit_card.rb
Overview
Credit card data
Instance Attribute Summary collapse
-
#brand ⇒ String
Credit card brand.
-
#exp_month ⇒ integer
Credit card expiration month.
-
#exp_year ⇒ Integer
Credit card expiration year.
-
#first_digits ⇒ Object
Returns the value of attribute first_digits.
-
#holder ⇒ Object
Returns the value of attribute holder.
-
#last_digits ⇒ Object
Returns the value of attribute last_digits.
-
#number ⇒ Long
Credit card number.
-
#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.
20 21 22 23 24 25 26 |
# File 'lib/pagseguro/charge/credit_card.rb', line 20 def initialize(args = {}) @security_code = args[:security_code] @number = args[:number] @exp_month = args[:exp_month] @exp_year = args[:exp_year] @holder = args[:holder] end |
Instance Attribute Details
#brand ⇒ String
Credit card brand
10 11 12 |
# File 'lib/pagseguro/charge/credit_card.rb', line 10 def brand @brand end |
#exp_month ⇒ integer
Credit card expiration month
10 11 12 |
# File 'lib/pagseguro/charge/credit_card.rb', line 10 def exp_month @exp_month end |
#exp_year ⇒ Integer
Credit card expiration year
10 11 12 |
# File 'lib/pagseguro/charge/credit_card.rb', line 10 def exp_year @exp_year end |
#first_digits ⇒ Object
Returns the value of attribute first_digits.
11 12 13 |
# File 'lib/pagseguro/charge/credit_card.rb', line 11 def first_digits @first_digits end |
#holder ⇒ Object
Returns the value of attribute holder.
11 12 13 |
# File 'lib/pagseguro/charge/credit_card.rb', line 11 def holder @holder end |
#last_digits ⇒ Object
Returns the value of attribute last_digits.
11 12 13 |
# File 'lib/pagseguro/charge/credit_card.rb', line 11 def last_digits @last_digits end |
#number ⇒ Long
Credit card number
10 11 12 |
# File 'lib/pagseguro/charge/credit_card.rb', line 10 def number @number end |
#security_code ⇒ String
Credit card security_code
10 11 12 |
# File 'lib/pagseguro/charge/credit_card.rb', line 10 def security_code @security_code end |
Class Method Details
.fill_from_json(data) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pagseguro/charge/credit_card.rb', line 34 def self.fill_from_json(data) return if data.nil? credit_card = new credit_card.number = data["number"] credit_card.exp_month = data["exp_month"] credit_card.exp_year = data["exp_year"] credit_card.security_code = data["security_code"] credit_card.first_digits = data["first_digits"] credit_card.last_digits = data["last_digits"] credit_card.brand = data["brand"] credit_card.holder = Holder.fill_from_json(data["holder"]) credit_card end |
Instance Method Details
#as_json(options = {}) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pagseguro/charge/credit_card.rb', line 49 def as_json(={}) { brand: @brand, number: @number, exp_year: @exp_year, exp_month: @exp_month, security_code: @security_code, last_digits: @last_digits, first_digits: @first_digits, holder: @holder } end |
#to_json(*options) ⇒ Object
28 29 30 31 32 |
# File 'lib/pagseguro/charge/credit_card.rb', line 28 def to_json(*) hash = as_json(*) hash.reject! {|k,v| v.nil?} hash.to_json(*) end |