Class: CyberSourceMergedSpec::CreateInvoiceRequest

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

Overview

CreateInvoiceRequest 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:, client_reference_information: SKIP, customer_information: SKIP, processing_information: SKIP, merchant_defined_field_values: SKIP, additional_properties: nil) ⇒ CreateInvoiceRequest

Returns a new instance of CreateInvoiceRequest.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/cyber_source_merged_spec/models/create_invoice_request.rb', line 66

def initialize(invoice_information:, order_information:,
               client_reference_information: SKIP,
               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?

  unless client_reference_information == SKIP
    @client_reference_information =
      client_reference_information
  end
  @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

#client_reference_informationClientReferenceInformation78

TODO: Write general description for this method



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

def client_reference_information
  @client_reference_information
end

#customer_informationCustomerInformation

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

Returns:



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

def customer_information
  @customer_information
end

#invoice_informationInvoiceInformation

Contains all of the invoice-specific fields, such as the invoice number and due date.

Returns:



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

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:



37
38
39
# File 'lib/cyber_source_merged_spec/models/create_invoice_request.rb', line 37

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:



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

def order_information
  @order_information
end

#processing_informationProcessingInformation72

Contains processing information, such as collection details.



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

def processing_information
  @processing_information
end

Class Method Details

.from_element(root) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/cyber_source_merged_spec/models/create_invoice_request.rb', line 133

def self.from_element(root)
  invoice_information = XmlUtilities.from_element(root,
                                                  'InvoiceInformation',
                                                  InvoiceInformation)
  order_information = XmlUtilities.from_element(root, 'OrderInformation60',
                                                OrderInformation60)
  client_reference_information = XmlUtilities.from_element(
    root, 'ClientReferenceInformation78',
    ClientReferenceInformation78
  )
  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,
      client_reference_information: client_reference_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.



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
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/cyber_source_merged_spec/models/create_invoice_request.rb', line 90

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  invoice_information = InvoiceInformation.from_hash(hash['invoiceInformation']) if
    hash['invoiceInformation']
  order_information = OrderInformation60.from_hash(hash['orderInformation']) if
    hash['orderInformation']
  if hash['clientReferenceInformation']
    client_reference_information = ClientReferenceInformation78.from_hash(hash['clientReferenceInformation'])
  end
  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.
  CreateInvoiceRequest.new(invoice_information: invoice_information,
                           order_information: order_information,
                           client_reference_information: client_reference_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.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['client_reference_information'] = 'clientReferenceInformation'
  @_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



62
63
64
# File 'lib/cyber_source_merged_spec/models/create_invoice_request.rb', line 62

def self.nullables
  []
end

.optionalsObject

An array for optional fields



52
53
54
55
56
57
58
59
# File 'lib/cyber_source_merged_spec/models/create_invoice_request.rb', line 52

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



195
196
197
198
199
200
201
202
203
# File 'lib/cyber_source_merged_spec/models/create_invoice_request.rb', line 195

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} client_reference_information: #{@client_reference_information.inspect},"\
  " 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.



185
186
187
188
189
190
191
192
# File 'lib/cyber_source_merged_spec/models/create_invoice_request.rb', line 185

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} client_reference_information: #{@client_reference_information},"\
  " 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



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/cyber_source_merged_spec/models/create_invoice_request.rb', line 162

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

  XmlUtilities.add_as_subelement(doc, root, 'InvoiceInformation',
                                 invoice_information)
  XmlUtilities.add_as_subelement(doc, root, 'OrderInformation60',
                                 order_information)
  XmlUtilities.add_as_subelement(doc, root, 'ClientReferenceInformation78',
                                 client_reference_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