Class: CyberSourceMergedSpec::InvoiceInformation1

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

Overview

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

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_number: SKIP, description: SKIP, due_date: SKIP, expiration_date: SKIP, allow_partial_payments: false, payment_link: SKIP, delivery_mode: SKIP, custom_labels: SKIP, additional_properties: nil) ⇒ InvoiceInformation1

Returns a new instance of InvoiceInformation1.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 87

def initialize(invoice_number: SKIP, description: SKIP, due_date: SKIP,
               expiration_date: SKIP, allow_partial_payments: false,
               payment_link: SKIP, delivery_mode: SKIP, custom_labels: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @invoice_number = invoice_number unless invoice_number == SKIP
  @description = description unless description == SKIP
  @due_date = due_date unless due_date == SKIP
  @expiration_date = expiration_date unless expiration_date == SKIP
  @allow_partial_payments = allow_partial_payments unless allow_partial_payments == SKIP
  @payment_link = payment_link unless payment_link == SKIP
  @delivery_mode = delivery_mode unless delivery_mode == SKIP
  @custom_labels = custom_labels unless custom_labels == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#allow_partial_paymentsTrueClass | FalseClass

If set to true, the payer can make a partial invoice payment.

Returns:

  • (TrueClass | FalseClass)


33
34
35
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 33

def allow_partial_payments
  @allow_partial_payments
end

#custom_labelsArray[CustomLabel]

A list of custom labels that allows you to override (rename) default field names and control the visibility of specific fields on invoices and items. If the list is empty, the labels will not be overwritten.

Returns:



52
53
54
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 52

def custom_labels
  @custom_labels
end

#delivery_modeString

If this field is set to 'None', an invoice will be generated with the status 'CREATED', but no email will be dispatched.
Possible values:

  • None
  • Email

Returns:

  • (String)


46
47
48
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 46

def delivery_mode
  @delivery_mode
end

#descriptionString

The description included in the invoice.

Returns:

  • (String)


19
20
21
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 19

def description
  @description
end

#due_dateDate

The invoice due date. This field is required for creating an invoice. Format: YYYY-MM-DD, where YYYY = year, MM = month, and DD = day

Returns:

  • (Date)


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

def due_date
  @due_date
end

#expiration_dateDate

Define an expiration date for the link. Format: YYYY-MM-DD, where YYYY = year, MM = month, and DD = day

Returns:

  • (Date)


29
30
31
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 29

def expiration_date
  @expiration_date
end

#invoice_numberString

Invoice Number.

Returns:

  • (String)


15
16
17
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 15

def invoice_number
  @invoice_number
end

Returns the payment link to an invoice when the invoice status is SENT, CREATED, PARTIAL, or PAID.

Returns:

  • (String)


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

def payment_link
  @payment_link
end

Class Method Details

.from_element(root) ⇒ Object



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 148

def self.from_element(root)
  invoice_number = XmlUtilities.from_element(root, 'invoiceNumber', String)
  description = XmlUtilities.from_element(root, 'description', String)
  due_date = XmlUtilities.from_element(root, 'dueDate', String)
  expiration_date = XmlUtilities.from_element(root, 'expirationDate',
                                              String)
  allow_partial_payments = XmlUtilities.from_element(root,
                                                     'allowPartialPayments',
                                                     TrueClass)
  payment_link = XmlUtilities.from_element(root, 'paymentLink', String)
  delivery_mode = XmlUtilities.from_element(root, 'deliveryMode', String)
  custom_labels = XmlUtilities.from_element_to_array(root, 'CustomLabel',
                                                     CustomLabel)

  new(invoice_number: invoice_number,
      description: description,
      due_date: due_date,
      expiration_date: expiration_date,
      allow_partial_payments: allow_partial_payments,
      payment_link: payment_link,
      delivery_mode: delivery_mode,
      custom_labels: custom_labels,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 106

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  invoice_number = hash.key?('invoiceNumber') ? hash['invoiceNumber'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  due_date = hash.key?('dueDate') ? hash['dueDate'] : SKIP
  expiration_date =
    hash.key?('expirationDate') ? hash['expirationDate'] : SKIP
  allow_partial_payments = hash['allowPartialPayments'] ||= false
  payment_link = hash.key?('paymentLink') ? hash['paymentLink'] : SKIP
  delivery_mode = hash.key?('deliveryMode') ? hash['deliveryMode'] : SKIP
  # Parameter is an array, so we need to iterate through it
  custom_labels = nil
  unless hash['customLabels'].nil?
    custom_labels = []
    hash['customLabels'].each do |structure|
      custom_labels << (CustomLabel.from_hash(structure) if structure)
    end
  end

  custom_labels = SKIP unless hash.key?('customLabels')

  # 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.
  InvoiceInformation1.new(invoice_number: invoice_number,
                          description: description,
                          due_date: due_date,
                          expiration_date: expiration_date,
                          allow_partial_payments: allow_partial_payments,
                          payment_link: payment_link,
                          delivery_mode: delivery_mode,
                          custom_labels: custom_labels,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['invoice_number'] = 'invoiceNumber'
  @_hash['description'] = 'description'
  @_hash['due_date'] = 'dueDate'
  @_hash['expiration_date'] = 'expirationDate'
  @_hash['allow_partial_payments'] = 'allowPartialPayments'
  @_hash['payment_link'] = 'paymentLink'
  @_hash['delivery_mode'] = 'deliveryMode'
  @_hash['custom_labels'] = 'customLabels'
  @_hash
end

.nullablesObject

An array for nullable fields



83
84
85
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 83

def self.nullables
  []
end

.optionalsObject

An array for optional fields



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 69

def self.optionals
  %w[
    invoice_number
    description
    due_date
    expiration_date
    allow_partial_payments
    payment_link
    delivery_mode
    custom_labels
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



204
205
206
207
208
209
210
211
212
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 204

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} invoice_number: #{@invoice_number.inspect}, description:"\
  " #{@description.inspect}, due_date: #{@due_date.inspect}, expiration_date:"\
  " #{@expiration_date.inspect}, allow_partial_payments: #{@allow_partial_payments.inspect},"\
  " payment_link: #{@payment_link.inspect}, delivery_mode: #{@delivery_mode.inspect},"\
  " custom_labels: #{@custom_labels.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



194
195
196
197
198
199
200
201
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 194

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} invoice_number: #{@invoice_number}, description: #{@description}, due_date:"\
  " #{@due_date}, expiration_date: #{@expiration_date}, allow_partial_payments:"\
  " #{@allow_partial_payments}, payment_link: #{@payment_link}, delivery_mode:"\
  " #{@delivery_mode}, custom_labels: #{@custom_labels}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/cyber_source_merged_spec/models/invoice_information1.rb', line 173

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

  XmlUtilities.add_as_subelement(doc, root, 'invoiceNumber', invoice_number)
  XmlUtilities.add_as_subelement(doc, root, 'description', description)
  XmlUtilities.add_as_subelement(doc, root, 'dueDate', due_date)
  XmlUtilities.add_as_subelement(doc, root, 'expirationDate',
                                 expiration_date)
  XmlUtilities.add_as_subelement(doc, root, 'allowPartialPayments',
                                 allow_partial_payments)
  XmlUtilities.add_as_subelement(doc, root, 'paymentLink', payment_link)
  XmlUtilities.add_as_subelement(doc, root, 'deliveryMode', delivery_mode)
  XmlUtilities.add_array_as_subelement(doc, root, 'CustomLabel',
                                       custom_labels)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end