Class: FreightFinancialsWebhookIngestionApi::Invoice

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

Overview

Invoice 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, documents: SKIP, factoring_company_id: SKIP, factoring_company_name: SKIP, has_claim: SKIP, invoice_number: SKIP, last_updated_at: SKIP, load: SKIP, payment: SKIP, status: SKIP, submitted_at: SKIP, uri: SKIP) ⇒ Invoice

Returns a new instance of Invoice.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 105

def initialize(carrier: SKIP, documents: SKIP, factoring_company_id: SKIP,
               factoring_company_name: SKIP, has_claim: SKIP,
               invoice_number: SKIP, last_updated_at: SKIP, load: SKIP,
               payment: SKIP, status: SKIP, submitted_at: SKIP, uri: SKIP)
  @carrier = carrier unless carrier == SKIP
  @documents = documents unless documents == SKIP
  @factoring_company_id = factoring_company_id unless factoring_company_id == SKIP
  @factoring_company_name = factoring_company_name unless factoring_company_name == SKIP
  @has_claim = has_claim unless has_claim == SKIP
  @invoice_number = invoice_number unless invoice_number == SKIP
  @last_updated_at = last_updated_at unless last_updated_at == SKIP
  @load = load unless load == SKIP
  @payment = payment unless payment == SKIP
  @status = status unless status == SKIP
  @submitted_at =  unless  == SKIP
  @uri = uri unless uri == SKIP
end

Instance Attribute Details

#carrierCarrier

TODO: Write general description for this method

Returns:



15
16
17
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 15

def carrier
  @carrier
end

#documentsArray[InvoiceDocument]

TODO: Write general description for this method

Returns:



19
20
21
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 19

def documents
  @documents
end

#factoring_company_idString

TODO: Write general description for this method

Returns:

  • (String)


23
24
25
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 23

def factoring_company_id
  @factoring_company_id
end

#factoring_company_nameString

TODO: Write general description for this method

Returns:

  • (String)


27
28
29
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 27

def factoring_company_name
  @factoring_company_name
end

#has_claimTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


31
32
33
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 31

def has_claim
  @has_claim
end

#invoice_numberString

TODO: Write general description for this method

Returns:

  • (String)


35
36
37
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 35

def invoice_number
  @invoice_number
end

#last_updated_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


39
40
41
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 39

def last_updated_at
  @last_updated_at
end

#loadLoadSlim

TODO: Write general description for this method

Returns:



43
44
45
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 43

def load
  @load
end

#paymentPayment

TODO: Write general description for this method

Returns:



47
48
49
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 47

def payment
  @payment
end

#statusInteger

TODO: Write general description for this method

Returns:

  • (Integer)


51
52
53
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 51

def status
  @status
end

#submitted_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


55
56
57
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 55

def 
  @submitted_at
end

#uriString

TODO: Write general description for this method

Returns:

  • (String)


59
60
61
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 59

def uri
  @uri
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 124

def self.from_hash(hash)
  return nil unless hash

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

  documents = SKIP unless hash.key?('documents')
  factoring_company_id =
    hash.key?('factoringCompanyId') ? hash['factoringCompanyId'] : SKIP
  factoring_company_name =
    hash.key?('factoringCompanyName') ? hash['factoringCompanyName'] : SKIP
  has_claim = hash.key?('hasClaim') ? hash['hasClaim'] : SKIP
  invoice_number = hash.key?('invoiceNumber') ? hash['invoiceNumber'] : SKIP
  last_updated_at = if hash.key?('lastUpdatedAt')
                      (DateTimeHelper.from_rfc3339(hash['lastUpdatedAt']) if hash['lastUpdatedAt'])
                    else
                      SKIP
                    end
  load = LoadSlim.from_hash(hash['load']) if hash['load']
  payment = Payment.from_hash(hash['payment']) if hash['payment']
  status = hash.key?('status') ? hash['status'] : SKIP
   = if hash.key?('submittedAt')
                   (DateTimeHelper.from_rfc3339(hash['submittedAt']) if hash['submittedAt'])
                 else
                   SKIP
                 end
  uri = hash.key?('uri') ? hash['uri'] : SKIP

  # Create object from extracted values.
  Invoice.new(carrier: carrier,
              documents: documents,
              factoring_company_id: factoring_company_id,
              factoring_company_name: factoring_company_name,
              has_claim: has_claim,
              invoice_number: invoice_number,
              last_updated_at: last_updated_at,
              load: load,
              payment: payment,
              status: status,
              submitted_at: ,
              uri: uri)
end

.namesObject

A mapping from model property names to API property names.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 62

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['carrier'] = 'carrier'
  @_hash['documents'] = 'documents'
  @_hash['factoring_company_id'] = 'factoringCompanyId'
  @_hash['factoring_company_name'] = 'factoringCompanyName'
  @_hash['has_claim'] = 'hasClaim'
  @_hash['invoice_number'] = 'invoiceNumber'
  @_hash['last_updated_at'] = 'lastUpdatedAt'
  @_hash['load'] = 'load'
  @_hash['payment'] = 'payment'
  @_hash['status'] = 'status'
  @_hash['submitted_at'] = 'submittedAt'
  @_hash['uri'] = 'uri'
  @_hash
end

.nullablesObject

An array for nullable fields



98
99
100
101
102
103
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 98

def self.nullables
  %w[
    factoring_company_id
    uri
  ]
end

.optionalsObject

An array for optional fields



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 80

def self.optionals
  %w[
    carrier
    documents
    factoring_company_id
    factoring_company_name
    has_claim
    invoice_number
    last_updated_at
    load
    payment
    status
    submitted_at
    uri
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



194
195
196
197
198
199
200
201
202
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 194

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} carrier: #{@carrier.inspect}, documents: #{@documents.inspect},"\
  " factoring_company_id: #{@factoring_company_id.inspect}, factoring_company_name:"\
  " #{@factoring_company_name.inspect}, has_claim: #{@has_claim.inspect}, invoice_number:"\
  " #{@invoice_number.inspect}, last_updated_at: #{@last_updated_at.inspect}, load:"\
  " #{@load.inspect}, payment: #{@payment.inspect}, status: #{@status.inspect}, submitted_at:"\
  " #{@submitted_at.inspect}, uri: #{@uri.inspect}>"
end

#to_custom_last_updated_atObject



175
176
177
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 175

def to_custom_last_updated_at
  DateTimeHelper.to_rfc3339(last_updated_at)
end

#to_custom_submitted_atObject



179
180
181
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 179

def 
  DateTimeHelper.to_rfc3339()
end

#to_sObject

Provides a human-readable string representation of the object.



184
185
186
187
188
189
190
191
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice.rb', line 184

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} carrier: #{@carrier}, documents: #{@documents}, factoring_company_id:"\
  " #{@factoring_company_id}, factoring_company_name: #{@factoring_company_name}, has_claim:"\
  " #{@has_claim}, invoice_number: #{@invoice_number}, last_updated_at: #{@last_updated_at},"\
  " load: #{@load}, payment: #{@payment}, status: #{@status}, submitted_at: #{@submitted_at},"\
  " uri: #{@uri}>"
end