Class: FreightFinancialsWebhookIngestionApi::SubmitInvoiceRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb

Overview

SubmitInvoiceRequest 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(carrier: SKIP, carrier_invoice_number: SKIP, charges: SKIP, factoring_company: SKIP, invoice_date: SKIP, invoice_due_date: SKIP, invoice_number: SKIP, items: SKIP, load_number: SKIP, payment_terms: SKIP, reference_numbers: SKIP, stops: SKIP, type: SKIP) ⇒ SubmitInvoiceRequest

Returns a new instance of SubmitInvoiceRequest.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 111

def initialize(carrier: SKIP, carrier_invoice_number: SKIP, charges: SKIP,
               factoring_company: SKIP, invoice_date: SKIP,
               invoice_due_date: SKIP, invoice_number: SKIP, items: SKIP,
               load_number: SKIP, payment_terms: SKIP,
               reference_numbers: SKIP, stops: SKIP, type: SKIP)
  @carrier = carrier unless carrier == SKIP
  @carrier_invoice_number = carrier_invoice_number unless carrier_invoice_number == SKIP
  @charges = charges unless charges == SKIP
  @factoring_company = factoring_company unless factoring_company == SKIP
  @invoice_date = invoice_date unless invoice_date == SKIP
  @invoice_due_date = invoice_due_date unless invoice_due_date == SKIP
  @invoice_number = invoice_number unless invoice_number == SKIP
  @items = items unless items == SKIP
  @load_number = load_number unless load_number == SKIP
  @payment_terms = payment_terms unless payment_terms == SKIP
  @reference_numbers = reference_numbers unless reference_numbers == SKIP
  @stops = stops unless stops == SKIP
  @type = type unless type == SKIP
end

Instance Attribute Details

#carrierCarrier

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 14

def carrier
  @carrier
end

#carrier_invoice_numberString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 18

def carrier_invoice_number
  @carrier_invoice_number
end

#chargesArray[Charge]

TODO: Write general description for this method

Returns:



22
23
24
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 22

def charges
  @charges
end

#factoring_companyFactoringCompany

TODO: Write general description for this method

Returns:



26
27
28
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 26

def factoring_company
  @factoring_company
end

#invoice_dateDate

TODO: Write general description for this method

Returns:

  • (Date)


30
31
32
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 30

def invoice_date
  @invoice_date
end

#invoice_due_dateDate

TODO: Write general description for this method

Returns:

  • (Date)


34
35
36
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 34

def invoice_due_date
  @invoice_due_date
end

#invoice_numberString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 38

def invoice_number
  @invoice_number
end

#itemsArray[LineItem]

TODO: Write general description for this method

Returns:



42
43
44
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 42

def items
  @items
end

#load_numberString

TODO: Write general description for this method

Returns:

  • (String)


46
47
48
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 46

def load_number
  @load_number
end

#payment_termsString

TODO: Write general description for this method

Returns:

  • (String)


50
51
52
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 50

def payment_terms
  @payment_terms
end

#reference_numbersArray[ReferenceNumber]

TODO: Write general description for this method

Returns:



54
55
56
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 54

def reference_numbers
  @reference_numbers
end

#stopsArray[Stop]

TODO: Write general description for this method

Returns:



58
59
60
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 58

def stops
  @stops
end

#typeInteger

TODO: Write general description for this method

Returns:

  • (Integer)


62
63
64
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 62

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



132
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
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
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 132

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  carrier = Carrier.from_hash(hash['carrier']) if hash['carrier']
  carrier_invoice_number =
    hash.key?('carrierInvoiceNumber') ? hash['carrierInvoiceNumber'] : SKIP
  # Parameter is an array, so we need to iterate through it
  charges = nil
  unless hash['charges'].nil?
    charges = []
    hash['charges'].each do |structure|
      charges << (Charge.from_hash(structure) if structure)
    end
  end

  charges = SKIP unless hash.key?('charges')
  factoring_company = FactoringCompany.from_hash(hash['factoringCompany']) if
    hash['factoringCompany']
  invoice_date = hash.key?('invoiceDate') ? hash['invoiceDate'] : SKIP
  invoice_due_date =
    hash.key?('invoiceDueDate') ? hash['invoiceDueDate'] : SKIP
  invoice_number = hash.key?('invoiceNumber') ? hash['invoiceNumber'] : SKIP
  # Parameter is an array, so we need to iterate through it
  items = nil
  unless hash['items'].nil?
    items = []
    hash['items'].each do |structure|
      items << (LineItem.from_hash(structure) if structure)
    end
  end

  items = SKIP unless hash.key?('items')
  load_number = hash.key?('loadNumber') ? hash['loadNumber'] : SKIP
  payment_terms = hash.key?('paymentTerms') ? hash['paymentTerms'] : SKIP
  # Parameter is an array, so we need to iterate through it
  reference_numbers = nil
  unless hash['referenceNumbers'].nil?
    reference_numbers = []
    hash['referenceNumbers'].each do |structure|
      reference_numbers << (ReferenceNumber.from_hash(structure) if structure)
    end
  end

  reference_numbers = SKIP unless hash.key?('referenceNumbers')
  # Parameter is an array, so we need to iterate through it
  stops = nil
  unless hash['stops'].nil?
    stops = []
    hash['stops'].each do |structure|
      stops << (Stop.from_hash(structure) if structure)
    end
  end

  stops = SKIP unless hash.key?('stops')
  type = hash.key?('type') ? hash['type'] : SKIP

  # Create object from extracted values.
  SubmitInvoiceRequest.new(carrier: carrier,
                           carrier_invoice_number: carrier_invoice_number,
                           charges: charges,
                           factoring_company: factoring_company,
                           invoice_date: invoice_date,
                           invoice_due_date: invoice_due_date,
                           invoice_number: invoice_number,
                           items: items,
                           load_number: load_number,
                           payment_terms: payment_terms,
                           reference_numbers: reference_numbers,
                           stops: stops,
                           type: type)
end

.namesObject

A mapping from model property names to API property names.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 65

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['carrier'] = 'carrier'
  @_hash['carrier_invoice_number'] = 'carrierInvoiceNumber'
  @_hash['charges'] = 'charges'
  @_hash['factoring_company'] = 'factoringCompany'
  @_hash['invoice_date'] = 'invoiceDate'
  @_hash['invoice_due_date'] = 'invoiceDueDate'
  @_hash['invoice_number'] = 'invoiceNumber'
  @_hash['items'] = 'items'
  @_hash['load_number'] = 'loadNumber'
  @_hash['payment_terms'] = 'paymentTerms'
  @_hash['reference_numbers'] = 'referenceNumbers'
  @_hash['stops'] = 'stops'
  @_hash['type'] = 'type'
  @_hash
end

.nullablesObject

An array for nullable fields



103
104
105
106
107
108
109
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 103

def self.nullables
  %w[
    carrier_invoice_number
    invoice_due_date
    payment_terms
  ]
end

.optionalsObject

An array for optional fields



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 84

def self.optionals
  %w[
    carrier
    carrier_invoice_number
    charges
    factoring_company
    invoice_date
    invoice_due_date
    invoice_number
    items
    load_number
    payment_terms
    reference_numbers
    stops
    type
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



217
218
219
220
221
222
223
224
225
226
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 217

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} carrier: #{@carrier.inspect}, carrier_invoice_number:"\
  " #{@carrier_invoice_number.inspect}, charges: #{@charges.inspect}, factoring_company:"\
  " #{@factoring_company.inspect}, invoice_date: #{@invoice_date.inspect}, invoice_due_date:"\
  " #{@invoice_due_date.inspect}, invoice_number: #{@invoice_number.inspect}, items:"\
  " #{@items.inspect}, load_number: #{@load_number.inspect}, payment_terms:"\
  " #{@payment_terms.inspect}, reference_numbers: #{@reference_numbers.inspect}, stops:"\
  " #{@stops.inspect}, type: #{@type.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



206
207
208
209
210
211
212
213
214
# File 'lib/freight_financials_webhook_ingestion_api/models/submit_invoice_request.rb', line 206

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} carrier: #{@carrier}, carrier_invoice_number: #{@carrier_invoice_number},"\
  " charges: #{@charges}, factoring_company: #{@factoring_company}, invoice_date:"\
  " #{@invoice_date}, invoice_due_date: #{@invoice_due_date}, invoice_number:"\
  " #{@invoice_number}, items: #{@items}, load_number: #{@load_number}, payment_terms:"\
  " #{@payment_terms}, reference_numbers: #{@reference_numbers}, stops: #{@stops}, type:"\
  " #{@type}>"
end