Class: AdvancedBilling::ChjsTokenizationSuccess

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

Overview

ChjsTokenizationSuccess 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(payment_profile:, gateway_customer_id: SKIP, additional_properties: {}) ⇒ ChjsTokenizationSuccess

Returns a new instance of ChjsTokenizationSuccess.



42
43
44
45
46
47
48
49
50
51
# File 'lib/advanced_billing/models/chjs_tokenization_success.rb', line 42

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

  @payment_profile = payment_profile
  @gateway_customer_id = gateway_customer_id unless gateway_customer_id == SKIP
end

Instance Attribute Details

#gateway_customer_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def gateway_customer_id
  @gateway_customer_id
end

#payment_profileTokenizedPaymentProfile

TODO: Write general description for this method



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

def payment_profile
  @payment_profile
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/advanced_billing/models/chjs_tokenization_success.rb', line 54

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  payment_profile = TokenizedPaymentProfile.from_hash(hash['payment_profile']) if
    hash['payment_profile']
  gateway_customer_id =
    hash.key?('gateway_customer_id') ? hash['gateway_customer_id'] : SKIP

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

  # Create object from extracted values.
  ChjsTokenizationSuccess.new(payment_profile: payment_profile,
                              gateway_customer_id: gateway_customer_id,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



21
22
23
24
25
26
# File 'lib/advanced_billing/models/chjs_tokenization_success.rb', line 21

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['payment_profile'] = 'payment_profile'
  @_hash['gateway_customer_id'] = 'gateway_customer_id'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    gateway_customer_id
  ]
end

.optionalsObject

An array for optional fields



29
30
31
32
33
# File 'lib/advanced_billing/models/chjs_tokenization_success.rb', line 29

def self.optionals
  %w[
    gateway_customer_id
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/advanced_billing/models/chjs_tokenization_success.rb', line 74

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.payment_profile,
                                 ->(val) { TokenizedPaymentProfile.validate(val) },
                                 is_model_hash: true)
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['payment_profile'],
                        ->(val) { TokenizedPaymentProfile.validate(val) },
                        is_model_hash: true)
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



96
97
98
99
100
# File 'lib/advanced_billing/models/chjs_tokenization_success.rb', line 96

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

#to_sObject

Provides a human-readable string representation of the object.



89
90
91
92
93
# File 'lib/advanced_billing/models/chjs_tokenization_success.rb', line 89

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