Class: FreightFinancialsWebhookIngestionApi::UploadResponseData

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

Overview

UploadResponseData 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(document_id: SKIP, invoice_number: SKIP, received_at: SKIP, tags: SKIP, additional_properties: nil) ⇒ UploadResponseData

Returns a new instance of UploadResponseData.



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

def initialize(document_id: SKIP, invoice_number: SKIP, received_at: SKIP,
               tags: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @document_id = document_id unless document_id == SKIP
  @invoice_number = invoice_number unless invoice_number == SKIP
  @received_at = received_at unless received_at == SKIP
  @tags = tags unless tags == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#document_idUUID | String

TODO: Write general description for this method

Returns:

  • (UUID | String)


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

def document_id
  @document_id
end

#invoice_numberString

TODO: Write general description for this method

Returns:

  • (String)


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

def invoice_number
  @invoice_number
end

#received_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


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

def received_at
  @received_at
end

#tagsHash[String, String]

TODO: Write general description for this method

Returns:

  • (Hash[String, String])


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

def tags
  @tags
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/freight_financials_webhook_ingestion_api/models/upload_response_data.rb', line 69

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  document_id = hash.key?('documentId') ? hash['documentId'] : SKIP
  invoice_number = hash.key?('invoiceNumber') ? hash['invoiceNumber'] : SKIP
  received_at = if hash.key?('receivedAt')
                  (DateTimeHelper.from_rfc3339(hash['receivedAt']) if hash['receivedAt'])
                else
                  SKIP
                end
  tags = hash.key?('tags') ? hash['tags'] : 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.
  UploadResponseData.new(document_id: document_id,
                         invoice_number: invoice_number,
                         received_at: received_at,
                         tags: tags,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/freight_financials_webhook_ingestion_api/models/upload_response_data.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['document_id'] = 'documentId'
  @_hash['invoice_number'] = 'invoiceNumber'
  @_hash['received_at'] = 'receivedAt'
  @_hash['tags'] = 'tags'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
53
54
# File 'lib/freight_financials_webhook_ingestion_api/models/upload_response_data.rb', line 50

def self.nullables
  %w[
    tags
  ]
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
46
47
# File 'lib/freight_financials_webhook_ingestion_api/models/upload_response_data.rb', line 40

def self.optionals
  %w[
    document_id
    invoice_number
    received_at
    tags
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



110
111
112
113
114
115
# File 'lib/freight_financials_webhook_ingestion_api/models/upload_response_data.rb', line 110

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} document_id: #{@document_id.inspect}, invoice_number:"\
  " #{@invoice_number.inspect}, received_at: #{@received_at.inspect}, tags: #{@tags.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_custom_received_atObject



97
98
99
# File 'lib/freight_financials_webhook_ingestion_api/models/upload_response_data.rb', line 97

def to_custom_received_at
  DateTimeHelper.to_rfc3339(received_at)
end

#to_sObject

Provides a human-readable string representation of the object.



102
103
104
105
106
107
# File 'lib/freight_financials_webhook_ingestion_api/models/upload_response_data.rb', line 102

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} document_id: #{@document_id}, invoice_number: #{@invoice_number},"\
  " received_at: #{@received_at}, tags: #{@tags}, additional_properties:"\
  " #{@additional_properties}>"
end