Class: Braspag::CreditCard

Inherits:
Object
  • Object
show all
Defined in:
lib/braspag/api/credit_card.rb

Overview

Credit card data

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#brandString

Credit card brand

Returns:

  • (String)

    the current value of brand



11
12
13
# File 'lib/braspag/api/credit_card.rb', line 11

def brand
  @brand
end

#card_numberString

Credit card number

Returns:

  • (String)

    the current value of card_number



11
12
13
# File 'lib/braspag/api/credit_card.rb', line 11

def card_number
  @card_number
end

#card_tokenString

Card token

Returns:

  • (String)

    the current value of card_token



11
12
13
# File 'lib/braspag/api/credit_card.rb', line 11

def card_token
  @card_token
end

#expiration_dateString

Credit card expiration date

Returns:

  • (String)

    the current value of expiration_date



11
12
13
# File 'lib/braspag/api/credit_card.rb', line 11

def expiration_date
  @expiration_date
end

#holderString

Holder name

Returns:

  • (String)

    the current value of holder



11
12
13
# File 'lib/braspag/api/credit_card.rb', line 11

def holder
  @holder
end

#save_cardBoolean

Whether or not to save the card

Returns:

  • (Boolean)

    the current value of save_card



11
12
13
# File 'lib/braspag/api/credit_card.rb', line 11

def save_card
  @save_card
end

#security_codeString

Credit card security code

Returns:

  • (String)

    the current value of 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(*options)
    hash = as_json(*options)
    hash.reject! {|k,v| v.nil?}
    hash.to_json(*options)
end