Class: AdvancedBilling::TokenizedPaymentProfile

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

Overview

TokenizedPaymentProfile Model.

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(id:, vault_token: SKIP, gateway_handle: SKIP, customer_vault_token: SKIP, additional_properties: {}) ⇒ TokenizedPaymentProfile

Returns a new instance of TokenizedPaymentProfile.



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/advanced_billing/models/tokenized_payment_profile.rb', line 55

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

  @id = id
  @vault_token = vault_token unless vault_token == SKIP
  @gateway_handle = gateway_handle unless gateway_handle == SKIP
  @customer_vault_token = customer_vault_token unless customer_vault_token == SKIP
end

Instance Attribute Details

#customer_vault_tokenString

TODO: Write general description for this method

Returns:

  • (String)


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

def customer_vault_token
  @customer_vault_token
end

#gateway_handleString

TODO: Write general description for this method

Returns:

  • (String)


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

def gateway_handle
  @gateway_handle
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def id
  @id
end

#vault_tokenString

TODO: Write general description for this method

Returns:

  • (String)


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

def vault_token
  @vault_token
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  vault_token = hash.key?('vault_token') ? hash['vault_token'] : SKIP
  gateway_handle =
    hash.key?('gateway_handle') ? hash['gateway_handle'] : SKIP
  customer_vault_token =
    hash.key?('customer_vault_token') ? hash['customer_vault_token'] : SKIP

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

  # Create object from extracted values.
  TokenizedPaymentProfile.new(id: id,
                              vault_token: vault_token,
                              gateway_handle: gateway_handle,
                              customer_vault_token: customer_vault_token,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/advanced_billing/models/tokenized_payment_profile.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['vault_token'] = 'vault_token'
  @_hash['gateway_handle'] = 'gateway_handle'
  @_hash['customer_vault_token'] = 'customer_vault_token'
  @_hash
end

.nullablesObject

An array for nullable fields



48
49
50
51
52
53
# File 'lib/advanced_billing/models/tokenized_payment_profile.rb', line 48

def self.nullables
  %w[
    gateway_handle
    customer_vault_token
  ]
end

.optionalsObject

An array for optional fields



39
40
41
42
43
44
45
# File 'lib/advanced_billing/models/tokenized_payment_profile.rb', line 39

def self.optionals
  %w[
    vault_token
    gateway_handle
    customer_vault_token
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/advanced_billing/models/tokenized_payment_profile.rb', line 93

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.id,
                                 ->(val) { val.instance_of? Integer })
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['id'],
                        ->(val) { val.instance_of? Integer })
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



114
115
116
117
118
119
# File 'lib/advanced_billing/models/tokenized_payment_profile.rb', line 114

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, vault_token: #{@vault_token.inspect}, gateway_handle:"\
  " #{@gateway_handle.inspect}, customer_vault_token: #{@customer_vault_token.inspect},"\
  " additional_properties: #{get_additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



106
107
108
109
110
111
# File 'lib/advanced_billing/models/tokenized_payment_profile.rb', line 106

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, vault_token: #{@vault_token}, gateway_handle:"\
  " #{@gateway_handle}, customer_vault_token: #{@customer_vault_token}, additional_properties:"\
  " #{get_additional_properties}>"
end