Class: FreightFinancialsWebhookIngestionApi::InvoiceStatusResponseData

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

Overview

InvoiceStatusResponseData 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(completed_at: SKIP, currency: SKIP, documents: SKIP, issues: SKIP, invoice_number: SKIP, load_number: SKIP, received_at: SKIP, status: SKIP, total_charge_amount: SKIP, additional_properties: nil) ⇒ InvoiceStatusResponseData

Returns a new instance of InvoiceStatusResponseData.



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

def initialize(completed_at: SKIP, currency: SKIP, documents: SKIP,
               issues: SKIP, invoice_number: SKIP, load_number: SKIP,
               received_at: SKIP, status: SKIP, total_charge_amount: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @completed_at = completed_at unless completed_at == SKIP
  @currency = currency unless currency == SKIP
  @documents = documents unless documents == SKIP
  @issues = issues unless issues == SKIP
  @invoice_number = invoice_number unless invoice_number == SKIP
  @load_number = load_number unless load_number == SKIP
  @received_at = received_at unless received_at == SKIP
  @status = status unless status == SKIP
  @total_charge_amount = total_charge_amount unless total_charge_amount == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#completed_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


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

def completed_at
  @completed_at
end

#currencyString

TODO: Write general description for this method

Returns:

  • (String)


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

def currency
  @currency
end

#documentsArray[Integer]

TODO: Write general description for this method

Returns:

  • (Array[Integer])


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

def documents
  @documents
end

#invoice_numberString

TODO: Write general description for this method

Returns:

  • (String)


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

def invoice_number
  @invoice_number
end

#issuesArray[InvoiceIssue]

TODO: Write general description for this method

Returns:



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

def issues
  @issues
end

#load_numberString

TODO: Write general description for this method

Returns:

  • (String)


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

def load_number
  @load_number
end

#received_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


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

def received_at
  @received_at
end

#statusInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def status
  @status
end

#total_charge_amountFloat

TODO: Write general description for this method

Returns:

  • (Float)


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

def total_charge_amount
  @total_charge_amount
end

Class Method Details

.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
147
148
149
150
151
152
153
154
155
156
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice_status_response_data.rb', line 106

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  completed_at = if hash.key?('completedAt')
                   (DateTimeHelper.from_rfc3339(hash['completedAt']) if hash['completedAt'])
                 else
                   SKIP
                 end
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  documents = hash.key?('documents') ? hash['documents'] : SKIP
  # Parameter is an array, so we need to iterate through it
  issues = nil
  unless hash['issues'].nil?
    issues = []
    hash['issues'].each do |structure|
      issues << (InvoiceIssue.from_hash(structure) if structure)
    end
  end

  issues = SKIP unless hash.key?('issues')
  invoice_number = hash.key?('invoiceNumber') ? hash['invoiceNumber'] : SKIP
  load_number = hash.key?('loadNumber') ? hash['loadNumber'] : SKIP
  received_at = if hash.key?('receivedAt')
                  (DateTimeHelper.from_rfc3339(hash['receivedAt']) if hash['receivedAt'])
                else
                  SKIP
                end
  status = hash.key?('status') ? hash['status'] : SKIP
  total_charge_amount =
    hash.key?('totalChargeAmount') ? hash['totalChargeAmount'] : 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.
  InvoiceStatusResponseData.new(completed_at: completed_at,
                                currency: currency,
                                documents: documents,
                                issues: issues,
                                invoice_number: invoice_number,
                                load_number: load_number,
                                received_at: received_at,
                                status: status,
                                total_charge_amount: total_charge_amount,
                                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice_status_response_data.rb', line 50

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['completed_at'] = 'completedAt'
  @_hash['currency'] = 'currency'
  @_hash['documents'] = 'documents'
  @_hash['issues'] = 'issues'
  @_hash['invoice_number'] = 'invoiceNumber'
  @_hash['load_number'] = 'loadNumber'
  @_hash['received_at'] = 'receivedAt'
  @_hash['status'] = 'status'
  @_hash['total_charge_amount'] = 'totalChargeAmount'
  @_hash
end

.nullablesObject

An array for nullable fields



80
81
82
83
84
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice_status_response_data.rb', line 80

def self.nullables
  %w[
    completed_at
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    completed_at
    currency
    documents
    issues
    invoice_number
    load_number
    received_at
    status
    total_charge_amount
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



176
177
178
179
180
181
182
183
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice_status_response_data.rb', line 176

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} completed_at: #{@completed_at.inspect}, currency: #{@currency.inspect},"\
  " documents: #{@documents.inspect}, issues: #{@issues.inspect}, invoice_number:"\
  " #{@invoice_number.inspect}, load_number: #{@load_number.inspect}, received_at:"\
  " #{@received_at.inspect}, status: #{@status.inspect}, total_charge_amount:"\
  " #{@total_charge_amount.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_completed_atObject



158
159
160
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice_status_response_data.rb', line 158

def to_custom_completed_at
  DateTimeHelper.to_rfc3339(completed_at)
end

#to_custom_received_atObject



162
163
164
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice_status_response_data.rb', line 162

def to_custom_received_at
  DateTimeHelper.to_rfc3339(received_at)
end

#to_sObject

Provides a human-readable string representation of the object.



167
168
169
170
171
172
173
# File 'lib/freight_financials_webhook_ingestion_api/models/invoice_status_response_data.rb', line 167

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} completed_at: #{@completed_at}, currency: #{@currency}, documents:"\
  " #{@documents}, issues: #{@issues}, invoice_number: #{@invoice_number}, load_number:"\
  " #{@load_number}, received_at: #{@received_at}, status: #{@status}, total_charge_amount:"\
  " #{@total_charge_amount}, additional_properties: #{@additional_properties}>"
end