Class: AdvancedBilling::PaymentMethodCreditCardType

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/payment_method_credit_card_type.rb

Overview

PaymentMethodCreditCardType Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(card_brand = SKIP, card_expiration = SKIP, last_four = SKIP, masked_card_number = SKIP, type = 'credit_card') ⇒ PaymentMethodCreditCardType

Returns a new instance of PaymentMethodCreditCardType.



61
62
63
64
65
66
67
68
# File 'lib/advanced_billing/models/payment_method_credit_card_type.rb', line 61

def initialize(card_brand = SKIP, card_expiration = SKIP, last_four = SKIP,
               masked_card_number = SKIP, type = 'credit_card')
  @card_brand = card_brand unless card_brand == SKIP
  @card_expiration = card_expiration unless card_expiration == SKIP
  @last_four = last_four unless last_four == SKIP
  @masked_card_number = masked_card_number unless masked_card_number == SKIP
  @type = type unless type == SKIP
end

Instance Attribute Details

#card_brandString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/advanced_billing/models/payment_method_credit_card_type.rb', line 14

def card_brand
  @card_brand
end

#card_expirationString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/advanced_billing/models/payment_method_credit_card_type.rb', line 18

def card_expiration
  @card_expiration
end

#last_fourString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/advanced_billing/models/payment_method_credit_card_type.rb', line 22

def last_four
  @last_four
end

#masked_card_numberString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/advanced_billing/models/payment_method_credit_card_type.rb', line 26

def masked_card_number
  @masked_card_number
end

#typeString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/advanced_billing/models/payment_method_credit_card_type.rb', line 30

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/advanced_billing/models/payment_method_credit_card_type.rb', line 71

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  card_brand = hash.key?('card_brand') ? hash['card_brand'] : SKIP
  card_expiration =
    hash.key?('card_expiration') ? hash['card_expiration'] : SKIP
  last_four = hash.key?('last_four') ? hash['last_four'] : SKIP
  masked_card_number =
    hash.key?('masked_card_number') ? hash['masked_card_number'] : SKIP
  type = hash['type'] ||= 'credit_card'

  # Create object from extracted values.
  PaymentMethodCreditCardType.new(card_brand,
                                  card_expiration,
                                  last_four,
                                  masked_card_number,
                                  type)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/advanced_billing/models/payment_method_credit_card_type.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['card_brand'] = 'card_brand'
  @_hash['card_expiration'] = 'card_expiration'
  @_hash['last_four'] = 'last_four'
  @_hash['masked_card_number'] = 'masked_card_number'
  @_hash['type'] = 'type'
  @_hash
end

.nullablesObject

An array for nullable fields



55
56
57
58
59
# File 'lib/advanced_billing/models/payment_method_credit_card_type.rb', line 55

def self.nullables
  %w[
    last_four
  ]
end

.optionalsObject

An array for optional fields



44
45
46
47
48
49
50
51
52
# File 'lib/advanced_billing/models/payment_method_credit_card_type.rb', line 44

def self.optionals
  %w[
    card_brand
    card_expiration
    last_four
    masked_card_number
    type
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



93
94
95
96
97
98
99
# File 'lib/advanced_billing/models/payment_method_credit_card_type.rb', line 93

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end