Class: CyberSourceMergedSpec::JapanPaymentOptions2

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cyber_source_merged_spec/models/japan_payment_options2.rb

Overview

JapanPaymentOptions2 Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

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

Constructor Details

#initialize(payment_method: SKIP, installments: SKIP, additional_properties: nil) ⇒ JapanPaymentOptions2

Returns a new instance of JapanPaymentOptions2.



47
48
49
50
51
52
53
54
55
# File 'lib/cyber_source_merged_spec/models/japan_payment_options2.rb', line 47

def initialize(payment_method: SKIP, installments: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @payment_method = payment_method unless payment_method == SKIP
  @installments = installments unless installments == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#installmentsString

Number of Installments.

Returns:

  • (String)


24
25
26
# File 'lib/cyber_source_merged_spec/models/japan_payment_options2.rb', line 24

def installments
  @installments
end

#payment_methodString

This value is a 2-digit code indicating the payment method. Use Payment Method Code value that applies to the tranasction.

  • 10 (One-time payment)
  • 21, 22, 23, 24 (Bonus(one-time)payment)
  • 61 (Installment payment)
  • 31, 32, 33, 34 (Integrated (Bonus + Installment)payment)
  • 80 (Revolving payment)

Returns:

  • (String)


20
21
22
# File 'lib/cyber_source_merged_spec/models/japan_payment_options2.rb', line 20

def payment_method
  @payment_method
end

Class Method Details

.from_element(root) ⇒ Object



78
79
80
81
82
83
84
85
# File 'lib/cyber_source_merged_spec/models/japan_payment_options2.rb', line 78

def self.from_element(root)
  payment_method = XmlUtilities.from_element(root, 'paymentMethod', String)
  installments = XmlUtilities.from_element(root, 'installments', String)

  new(payment_method: payment_method,
      installments: installments,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/cyber_source_merged_spec/models/japan_payment_options2.rb', line 58

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  payment_method = hash.key?('paymentMethod') ? hash['paymentMethod'] : SKIP
  installments = hash.key?('installments') ? hash['installments'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  JapanPaymentOptions2.new(payment_method: payment_method,
                           installments: installments,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
# File 'lib/cyber_source_merged_spec/models/japan_payment_options2.rb', line 27

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['payment_method'] = 'paymentMethod'
  @_hash['installments'] = 'installments'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/cyber_source_merged_spec/models/japan_payment_options2.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



35
36
37
38
39
40
# File 'lib/cyber_source_merged_spec/models/japan_payment_options2.rb', line 35

def self.optionals
  %w[
    payment_method
    installments
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



106
107
108
109
110
# File 'lib/cyber_source_merged_spec/models/japan_payment_options2.rb', line 106

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

#to_sObject

Provides a human-readable string representation of the object.



99
100
101
102
103
# File 'lib/cyber_source_merged_spec/models/japan_payment_options2.rb', line 99

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

#to_xml_element(doc, root_name) ⇒ Object



87
88
89
90
91
92
93
94
95
96
# File 'lib/cyber_source_merged_spec/models/japan_payment_options2.rb', line 87

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'paymentMethod', payment_method)
  XmlUtilities.add_as_subelement(doc, root, 'installments', installments)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end