Class: CyberSourceMergedSpec::Links

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

Overview

Links 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(mself: SKIP, reversal: SKIP, capture: SKIP, customer: SKIP, payment_instrument: SKIP, shipping_address: SKIP, instrument_identifier: SKIP, additional_properties: nil) ⇒ Links

Returns a new instance of Links.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/cyber_source_merged_spec/models/links.rb', line 71

def initialize(mself: SKIP, reversal: SKIP, capture: SKIP, customer: SKIP,
               payment_instrument: SKIP, shipping_address: SKIP,
               instrument_identifier: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @mself = mself unless mself == SKIP
  @reversal = reversal unless reversal == SKIP
  @capture = capture unless capture == SKIP
  @customer = customer unless customer == SKIP
  @payment_instrument = payment_instrument unless payment_instrument == SKIP
  @shipping_address = shipping_address unless shipping_address == SKIP
  @instrument_identifier = instrument_identifier unless instrument_identifier == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#captureCapture

TODO: Write general description for this method

Returns:



22
23
24
# File 'lib/cyber_source_merged_spec/models/links.rb', line 22

def capture
  @capture
end

#customerCustomer1

TODO: Write general description for this method

Returns:



26
27
28
# File 'lib/cyber_source_merged_spec/models/links.rb', line 26

def customer
  @customer
end

#instrument_identifierInstrumentIdentifier1

TODO: Write general description for this method



38
39
40
# File 'lib/cyber_source_merged_spec/models/links.rb', line 38

def instrument_identifier
  @instrument_identifier
end

#mselfSelf

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/cyber_source_merged_spec/models/links.rb', line 14

def mself
  @mself
end

#payment_instrumentPaymentInstrument2

TODO: Write general description for this method

Returns:



30
31
32
# File 'lib/cyber_source_merged_spec/models/links.rb', line 30

def payment_instrument
  @payment_instrument
end

#reversalReversal1

TODO: Write general description for this method

Returns:



18
19
20
# File 'lib/cyber_source_merged_spec/models/links.rb', line 18

def reversal
  @reversal
end

#shipping_addressShippingAddress2

TODO: Write general description for this method

Returns:



34
35
36
# File 'lib/cyber_source_merged_spec/models/links.rb', line 34

def shipping_address
  @shipping_address
end

Class Method Details

.from_element(root) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/cyber_source_merged_spec/models/links.rb', line 121

def self.from_element(root)
  mself = XmlUtilities.from_element(root, 'Self', Self)
  reversal = XmlUtilities.from_element(root, 'Reversal1', Reversal1)
  capture = XmlUtilities.from_element(root, 'Capture', Capture)
  customer = XmlUtilities.from_element(root, 'Customer1', Customer1)
  payment_instrument = XmlUtilities.from_element(root, 'PaymentInstrument2',
                                                 PaymentInstrument2)
  shipping_address = XmlUtilities.from_element(root, 'ShippingAddress2',
                                               ShippingAddress2)
  instrument_identifier = XmlUtilities.from_element(root,
                                                    'InstrumentIdentifier1',
                                                    InstrumentIdentifier1)

  new(mself: mself,
      reversal: reversal,
      capture: capture,
      customer: customer,
      payment_instrument: payment_instrument,
      shipping_address: shipping_address,
      instrument_identifier: instrument_identifier,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/cyber_source_merged_spec/models/links.rb', line 88

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  mself = Self.from_hash(hash['self']) if hash['self']
  reversal = Reversal1.from_hash(hash['reversal']) if hash['reversal']
  capture = Capture.from_hash(hash['capture']) if hash['capture']
  customer = Customer1.from_hash(hash['customer']) if hash['customer']
  payment_instrument = PaymentInstrument2.from_hash(hash['paymentInstrument']) if
    hash['paymentInstrument']
  shipping_address = ShippingAddress2.from_hash(hash['shippingAddress']) if
    hash['shippingAddress']
  instrument_identifier = InstrumentIdentifier1.from_hash(hash['instrumentIdentifier']) if
    hash['instrumentIdentifier']

  # 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.
  Links.new(mself: mself,
            reversal: reversal,
            capture: capture,
            customer: customer,
            payment_instrument: payment_instrument,
            shipping_address: shipping_address,
            instrument_identifier: instrument_identifier,
            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['mself'] = 'self'
  @_hash['reversal'] = 'reversal'
  @_hash['capture'] = 'capture'
  @_hash['customer'] = 'customer'
  @_hash['payment_instrument'] = 'paymentInstrument'
  @_hash['shipping_address'] = 'shippingAddress'
  @_hash['instrument_identifier'] = 'instrumentIdentifier'
  @_hash
end

.nullablesObject

An array for nullable fields



67
68
69
# File 'lib/cyber_source_merged_spec/models/links.rb', line 67

def self.nullables
  []
end

.optionalsObject

An array for optional fields



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/cyber_source_merged_spec/models/links.rb', line 54

def self.optionals
  %w[
    mself
    reversal
    capture
    customer
    payment_instrument
    shipping_address
    instrument_identifier
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



173
174
175
176
177
178
179
180
# File 'lib/cyber_source_merged_spec/models/links.rb', line 173

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} mself: #{@mself.inspect}, reversal: #{@reversal.inspect}, capture:"\
  " #{@capture.inspect}, customer: #{@customer.inspect}, payment_instrument:"\
  " #{@payment_instrument.inspect}, shipping_address: #{@shipping_address.inspect},"\
  " instrument_identifier: #{@instrument_identifier.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



164
165
166
167
168
169
170
# File 'lib/cyber_source_merged_spec/models/links.rb', line 164

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} mself: #{@mself}, reversal: #{@reversal}, capture: #{@capture}, customer:"\
  " #{@customer}, payment_instrument: #{@payment_instrument}, shipping_address:"\
  " #{@shipping_address}, instrument_identifier: #{@instrument_identifier},"\
  " additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/cyber_source_merged_spec/models/links.rb', line 144

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

  XmlUtilities.add_as_subelement(doc, root, 'Self', mself)
  XmlUtilities.add_as_subelement(doc, root, 'Reversal1', reversal)
  XmlUtilities.add_as_subelement(doc, root, 'Capture', capture)
  XmlUtilities.add_as_subelement(doc, root, 'Customer1', customer)
  XmlUtilities.add_as_subelement(doc, root, 'PaymentInstrument2',
                                 payment_instrument)
  XmlUtilities.add_as_subelement(doc, root, 'ShippingAddress2',
                                 shipping_address)
  XmlUtilities.add_as_subelement(doc, root, 'InstrumentIdentifier1',
                                 instrument_identifier)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end