Class: CyberSourceMergedSpec::UpdateInvoiceRequest

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

Overview

UpdateInvoiceRequest 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(invoice_information:, order_information:, customer_information: SKIP, processing_information: SKIP, merchant_defined_field_values: SKIP, additional_properties: nil) ⇒ UpdateInvoiceRequest

Returns a new instance of UpdateInvoiceRequest.



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

def initialize(invoice_information:, order_information:,
               customer_information: SKIP, processing_information: SKIP,
               merchant_defined_field_values: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @customer_information = customer_information unless customer_information == SKIP
  @processing_information = processing_information unless processing_information == SKIP
  @invoice_information = invoice_information
  @order_information = order_information
  unless merchant_defined_field_values == SKIP
    @merchant_defined_field_values =
      merchant_defined_field_values
  end
  @additional_properties = additional_properties
end

Instance Attribute Details

#customer_informationCustomerInformation

Contains all of the customer-related fields for the invoice.

Returns:



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

def customer_information
  @customer_information
end

#invoice_informationInvoiceInformation4

Contains the updatable invoice information.

Returns:



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

def invoice_information
  @invoice_information
end

#merchant_defined_field_valuesArray[MerchantDefinedFieldValue]

Contains all of the order-related fields, such as the amount and line item details.

Returns:



32
33
34
# File 'lib/cyber_source_merged_spec/models/update_invoice_request.rb', line 32

def merchant_defined_field_values
  @merchant_defined_field_values
end

#order_informationOrderInformation60

Contains all of the order-related fields, such as the amount and line item details.

Returns:



27
28
29
# File 'lib/cyber_source_merged_spec/models/update_invoice_request.rb', line 27

def order_information
  @order_information
end

#processing_informationProcessingInformation72

Contains processing information, such as collection details.



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

def processing_information
  @processing_information
end

Class Method Details

.from_element(root) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/cyber_source_merged_spec/models/update_invoice_request.rb', line 117

def self.from_element(root)
  invoice_information = XmlUtilities.from_element(root,
                                                  'InvoiceInformation4',
                                                  InvoiceInformation4)
  order_information = XmlUtilities.from_element(root, 'OrderInformation60',
                                                OrderInformation60)
  customer_information = XmlUtilities.from_element(root,
                                                   'CustomerInformation',
                                                   CustomerInformation)
  processing_information = XmlUtilities.from_element(
    root, 'ProcessingInformation72', ProcessingInformation72
  )
  merchant_defined_field_values = XmlUtilities.from_element_to_array(
    root, 'MerchantDefinedFieldValue', MerchantDefinedFieldValue
  )

  new(invoice_information: invoice_information,
      order_information: order_information,
      customer_information: customer_information,
      processing_information: processing_information,
      merchant_defined_field_values: merchant_defined_field_values,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



78
79
80
81
82
83
84
85
86
87
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
# File 'lib/cyber_source_merged_spec/models/update_invoice_request.rb', line 78

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  invoice_information = InvoiceInformation4.from_hash(hash['invoiceInformation']) if
    hash['invoiceInformation']
  order_information = OrderInformation60.from_hash(hash['orderInformation']) if
    hash['orderInformation']
  customer_information = CustomerInformation.from_hash(hash['customerInformation']) if
    hash['customerInformation']
  processing_information = ProcessingInformation72.from_hash(hash['processingInformation']) if
    hash['processingInformation']
  # Parameter is an array, so we need to iterate through it
  merchant_defined_field_values = nil
  unless hash['merchantDefinedFieldValues'].nil?
    merchant_defined_field_values = []
    hash['merchantDefinedFieldValues'].each do |structure|
      merchant_defined_field_values << (MerchantDefinedFieldValue.from_hash(structure) if structure)
    end
  end

  merchant_defined_field_values = SKIP unless hash.key?('merchantDefinedFieldValues')

  # 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.
  UpdateInvoiceRequest.new(invoice_information: invoice_information,
                           order_information: order_information,
                           customer_information: customer_information,
                           processing_information: processing_information,
                           merchant_defined_field_values: merchant_defined_field_values,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



35
36
37
38
39
40
41
42
43
# File 'lib/cyber_source_merged_spec/models/update_invoice_request.rb', line 35

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['customer_information'] = 'customerInformation'
  @_hash['processing_information'] = 'processingInformation'
  @_hash['invoice_information'] = 'invoiceInformation'
  @_hash['order_information'] = 'orderInformation'
  @_hash['merchant_defined_field_values'] = 'merchantDefinedFieldValues'
  @_hash
end

.nullablesObject

An array for nullable fields



55
56
57
# File 'lib/cyber_source_merged_spec/models/update_invoice_request.rb', line 55

def self.nullables
  []
end

.optionalsObject

An array for optional fields



46
47
48
49
50
51
52
# File 'lib/cyber_source_merged_spec/models/update_invoice_request.rb', line 46

def self.optionals
  %w[
    customer_information
    processing_information
    merchant_defined_field_values
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



171
172
173
174
175
176
177
178
# File 'lib/cyber_source_merged_spec/models/update_invoice_request.rb', line 171

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} customer_information: #{@customer_information.inspect},"\
  " processing_information: #{@processing_information.inspect}, invoice_information:"\
  " #{@invoice_information.inspect}, order_information: #{@order_information.inspect},"\
  " merchant_defined_field_values: #{@merchant_defined_field_values.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



162
163
164
165
166
167
168
# File 'lib/cyber_source_merged_spec/models/update_invoice_request.rb', line 162

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} customer_information: #{@customer_information}, processing_information:"\
  " #{@processing_information}, invoice_information: #{@invoice_information},"\
  " order_information: #{@order_information}, merchant_defined_field_values:"\
  " #{@merchant_defined_field_values}, additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/cyber_source_merged_spec/models/update_invoice_request.rb', line 141

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

  XmlUtilities.add_as_subelement(doc, root, 'InvoiceInformation4',
                                 invoice_information)
  XmlUtilities.add_as_subelement(doc, root, 'OrderInformation60',
                                 order_information)
  XmlUtilities.add_as_subelement(doc, root, 'CustomerInformation',
                                 customer_information)
  XmlUtilities.add_as_subelement(doc, root, 'ProcessingInformation72',
                                 processing_information)
  XmlUtilities.add_array_as_subelement(doc, root,
                                       'MerchantDefinedFieldValue',
                                       merchant_defined_field_values)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end