Class: ModernTreasury::InvoiceLineItemUpdateRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/modern_treasury/models/invoice_line_item_update_request.rb

Overview

InvoiceLineItemUpdateRequest 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(contact_details: SKIP, counterparty_id: SKIP, counterparty_billing_address: SKIP, counterparty_shipping_address: SKIP, currency: SKIP, description: SKIP, due_date: SKIP, invoicer_address: SKIP, originating_account_id: SKIP, receiving_account_id: SKIP, payment_effective_date: SKIP, payment_type: SKIP, payment_method: SKIP, additional_properties: nil) ⇒ InvoiceLineItemUpdateRequest

Returns a new instance of InvoiceLineItemUpdateRequest.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 123

def initialize(contact_details: SKIP, counterparty_id: SKIP,
               counterparty_billing_address: SKIP,
               counterparty_shipping_address: SKIP, currency: SKIP,
               description: SKIP, due_date: SKIP, invoicer_address: SKIP,
               originating_account_id: SKIP, receiving_account_id: SKIP,
               payment_effective_date: SKIP, payment_type: SKIP,
               payment_method: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @contact_details = contact_details unless contact_details == SKIP
  @counterparty_id = counterparty_id unless counterparty_id == SKIP
  unless counterparty_billing_address == SKIP
    @counterparty_billing_address =
      counterparty_billing_address
  end
  unless counterparty_shipping_address == SKIP
    @counterparty_shipping_address =
      counterparty_shipping_address
  end
  @currency = currency unless currency == SKIP
  @description = description unless description == SKIP
  @due_date = due_date unless due_date == SKIP
  @invoicer_address = invoicer_address unless invoicer_address == SKIP
  @originating_account_id =  unless  == SKIP
  @receiving_account_id =  unless  == SKIP
  @payment_effective_date = payment_effective_date unless payment_effective_date == SKIP
  @payment_type = payment_type unless payment_type == SKIP
  @payment_method = payment_method unless payment_method == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#contact_detailsArray[ContactDetail]

The invoicer’s contact details displayed at the top of the invoice.

Returns:



15
16
17
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 15

def contact_details
  @contact_details
end

#counterparty_billing_addressCounterpartyBillingAddress

The counterparty’s billing address.



23
24
25
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 23

def counterparty_billing_address
  @counterparty_billing_address
end

#counterparty_idString

The ID of the counterparty receiving the invoice.

Returns:

  • (String)


19
20
21
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 19

def counterparty_id
  @counterparty_id
end

#counterparty_shipping_addressCounterpartyShippingAddress

The counterparty’s shipping address where physical goods should be delivered.



28
29
30
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 28

def counterparty_shipping_address
  @counterparty_shipping_address
end

#currencyCurrency

Three-letter ISO currency code.

Returns:



32
33
34
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 32

def currency
  @currency
end

#descriptionString

A free-form description of the invoice.

Returns:

  • (String)


36
37
38
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 36

def description
  @description
end

#due_dateDateTime

A future date by when the invoice needs to be paid.

Returns:

  • (DateTime)


40
41
42
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 40

def due_date
  @due_date
end

#invoicer_addressInvoicerAddress

The invoice issuer’s business address.

Returns:



44
45
46
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 44

def invoicer_address
  @invoicer_address
end

#originating_account_idString

The ID of the internal account the invoice should be paid to.

Returns:

  • (String)


48
49
50
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 48

def 
  @originating_account_id
end

#payment_effective_dateDate

Date transactions are to be posted to the participants’ account. Defaults to the current business day or the next business day if the current day is a bank holiday or weekend. Format: yyyy-mm-dd.

Returns:

  • (Date)


58
59
60
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 58

def payment_effective_date
  @payment_effective_date
end

#payment_methodPaymentMethod1

The method by which the invoice can be paid. ‘ui` will show the embedded payment collection flow. `automatic` will automatically initiate payment based upon the account details of the receiving_account id.nIf the invoice amount is positive, the automatically initiated payment order’s direction will be debit. If the invoice amount is negative, the automatically initiated payment order’s direction will be credit. One of ‘manual`, `ui`, or `automatic`.

Returns:



73
74
75
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 73

def payment_method
  @payment_method
end

#payment_typePaymentType6

One of ‘ach`, `eft`, `wire`, `check`, `sen`, `book`, `rtp`, `sepa`, `bacs`, `au_becs`, `interac`, `signet`, `provexchange`.

Returns:



63
64
65
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 63

def payment_type
  @payment_type
end

#receiving_account_idUUID | String

The receiving account ID. Can be an ‘external_account`.

Returns:

  • (UUID | String)


52
53
54
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 52

def 
  @receiving_account_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 156

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  contact_details = nil
  unless hash['contact_details'].nil?
    contact_details = []
    hash['contact_details'].each do |structure|
      contact_details << (ContactDetail.from_hash(structure) if structure)
    end
  end

  contact_details = SKIP unless hash.key?('contact_details')
  counterparty_id =
    hash.key?('counterparty_id') ? hash['counterparty_id'] : SKIP
  if hash['counterparty_billing_address']
    counterparty_billing_address = CounterpartyBillingAddress.from_hash(hash['counterparty_billing_address'])
  end
  if hash['counterparty_shipping_address']
    counterparty_shipping_address = CounterpartyShippingAddress.from_hash(hash['counterparty_shipping_address'])
  end
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  due_date = if hash.key?('due_date')
               (DateTimeHelper.from_rfc3339(hash['due_date']) if hash['due_date'])
             else
               SKIP
             end
  invoicer_address = InvoicerAddress.from_hash(hash['invoicer_address']) if
    hash['invoicer_address']
   =
    hash.key?('originating_account_id') ? hash['originating_account_id'] : SKIP
   =
    hash.key?('receiving_account_id') ? hash['receiving_account_id'] : SKIP
  payment_effective_date =
    hash.key?('payment_effective_date') ? hash['payment_effective_date'] : SKIP
  payment_type = hash.key?('payment_type') ? hash['payment_type'] : SKIP
  payment_method =
    hash.key?('payment_method') ? hash['payment_method'] : 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.
  InvoiceLineItemUpdateRequest.new(contact_details: contact_details,
                                   counterparty_id: counterparty_id,
                                   counterparty_billing_address: counterparty_billing_address,
                                   counterparty_shipping_address: counterparty_shipping_address,
                                   currency: currency,
                                   description: description,
                                   due_date: due_date,
                                   invoicer_address: invoicer_address,
                                   originating_account_id: ,
                                   receiving_account_id: ,
                                   payment_effective_date: payment_effective_date,
                                   payment_type: payment_type,
                                   payment_method: payment_method,
                                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 76

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['contact_details'] = 'contact_details'
  @_hash['counterparty_id'] = 'counterparty_id'
  @_hash['counterparty_billing_address'] = 'counterparty_billing_address'
  @_hash['counterparty_shipping_address'] =
    'counterparty_shipping_address'
  @_hash['currency'] = 'currency'
  @_hash['description'] = 'description'
  @_hash['due_date'] = 'due_date'
  @_hash['invoicer_address'] = 'invoicer_address'
  @_hash['originating_account_id'] = 'originating_account_id'
  @_hash['receiving_account_id'] = 'receiving_account_id'
  @_hash['payment_effective_date'] = 'payment_effective_date'
  @_hash['payment_type'] = 'payment_type'
  @_hash['payment_method'] = 'payment_method'
  @_hash
end

.nullablesObject

An array for nullable fields



115
116
117
118
119
120
121
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 115

def self.nullables
  %w[
    counterparty_billing_address
    counterparty_shipping_address
    invoicer_address
  ]
end

.optionalsObject

An array for optional fields



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 96

def self.optionals
  %w[
    contact_details
    counterparty_id
    counterparty_billing_address
    counterparty_shipping_address
    currency
    description
    due_date
    invoicer_address
    originating_account_id
    receiving_account_id
    payment_effective_date
    payment_type
    payment_method
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 239

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} contact_details: #{@contact_details.inspect}, counterparty_id:"\
  " #{@counterparty_id.inspect}, counterparty_billing_address:"\
  " #{@counterparty_billing_address.inspect}, counterparty_shipping_address:"\
  " #{@counterparty_shipping_address.inspect}, currency: #{@currency.inspect}, description:"\
  " #{@description.inspect}, due_date: #{@due_date.inspect}, invoicer_address:"\
  " #{@invoicer_address.inspect}, originating_account_id: #{@originating_account_id.inspect},"\
  " receiving_account_id: #{@receiving_account_id.inspect}, payment_effective_date:"\
  " #{@payment_effective_date.inspect}, payment_type: #{@payment_type.inspect},"\
  " payment_method: #{@payment_method.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_due_dateObject



221
222
223
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 221

def to_custom_due_date
  DateTimeHelper.to_rfc3339(due_date)
end

#to_sObject

Provides a human-readable string representation of the object.



226
227
228
229
230
231
232
233
234
235
236
# File 'lib/modern_treasury/models/invoice_line_item_update_request.rb', line 226

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} contact_details: #{@contact_details}, counterparty_id: #{@counterparty_id},"\
  " counterparty_billing_address: #{@counterparty_billing_address},"\
  " counterparty_shipping_address: #{@counterparty_shipping_address}, currency: #{@currency},"\
  " description: #{@description}, due_date: #{@due_date}, invoicer_address:"\
  " #{@invoicer_address}, originating_account_id: #{@originating_account_id},"\
  " receiving_account_id: #{@receiving_account_id}, payment_effective_date:"\
  " #{@payment_effective_date}, payment_type: #{@payment_type}, payment_method:"\
  " #{@payment_method}, additional_properties: #{@additional_properties}>"
end