Class: AdvancedBilling::PaymentProfileParams

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

Overview

PCI-safe cardholder fields only. Full card numbers, CVV, and billing address are never included.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(first_name: SKIP, last_name: SKIP, card_type: SKIP, additional_properties: {}) ⇒ PaymentProfileParams

Returns a new instance of PaymentProfileParams.



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/advanced_billing/models/payment_profile_params.rb', line 48

def initialize(first_name: SKIP, last_name: SKIP, card_type: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @first_name = first_name unless first_name == SKIP
  @last_name = last_name unless last_name == SKIP
  @card_type = card_type unless card_type == SKIP
end

Instance Attribute Details

#card_typeString

TODO: Write general description for this method

Returns:

  • (String)


23
24
25
# File 'lib/advanced_billing/models/payment_profile_params.rb', line 23

def card_type
  @card_type
end

#first_nameString

TODO: Write general description for this method

Returns:

  • (String)


15
16
17
# File 'lib/advanced_billing/models/payment_profile_params.rb', line 15

def first_name
  @first_name
end

#last_nameString

TODO: Write general description for this method

Returns:

  • (String)


19
20
21
# File 'lib/advanced_billing/models/payment_profile_params.rb', line 19

def last_name
  @last_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/advanced_billing/models/payment_profile_params.rb', line 61

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  first_name = hash.key?('first_name') ? hash['first_name'] : SKIP
  last_name = hash.key?('last_name') ? hash['last_name'] : SKIP
  card_type = hash.key?('card_type') ? hash['card_type'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  PaymentProfileParams.new(first_name: first_name,
                           last_name: last_name,
                           card_type: card_type,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
32
# File 'lib/advanced_billing/models/payment_profile_params.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['first_name'] = 'first_name'
  @_hash['last_name'] = 'last_name'
  @_hash['card_type'] = 'card_type'
  @_hash
end

.nullablesObject

An array for nullable fields



44
45
46
# File 'lib/advanced_billing/models/payment_profile_params.rb', line 44

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    first_name
    last_name
    card_type
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



81
82
83
84
85
86
87
# File 'lib/advanced_billing/models/payment_profile_params.rb', line 81

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

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



97
98
99
100
101
# File 'lib/advanced_billing/models/payment_profile_params.rb', line 97

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} first_name: #{@first_name.inspect}, last_name: #{@last_name.inspect},"\
  " card_type: #{@card_type.inspect}, additional_properties: #{get_additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



90
91
92
93
94
# File 'lib/advanced_billing/models/payment_profile_params.rb', line 90

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} first_name: #{@first_name}, last_name: #{@last_name}, card_type:"\
  " #{@card_type}, additional_properties: #{get_additional_properties}>"
end