Class: TqlOtrFactoringDataExchange::DocumentUploadMetadata

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/tql_otr_factoring_data_exchange/models/document_upload_metadata.rb

Overview

Metadata for the document upload, provided as the ‘metadata` part of the `multipart/form-data` request. Specifies the invoice linkage, document classification, and optional tags.

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(invoice_number:, document_type:, file_name: SKIP, tags: SKIP, additional_properties: nil) ⇒ DocumentUploadMetadata

Returns a new instance of DocumentUploadMetadata.



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/tql_otr_factoring_data_exchange/models/document_upload_metadata.rb', line 58

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

  @invoice_number = invoice_number
  @document_type = document_type
  @file_name = file_name unless file_name == SKIP
  @tags = tags unless tags == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#document_typeDocumentType

Document type classification used for categorizing uploaded documents.

Returns:



20
21
22
# File 'lib/tql_otr_factoring_data_exchange/models/document_upload_metadata.rb', line 20

def document_type
  @document_type
end

#file_nameString

Original file name, if available.

Returns:

  • (String)


24
25
26
# File 'lib/tql_otr_factoring_data_exchange/models/document_upload_metadata.rb', line 24

def file_name
  @file_name
end

#invoice_numberString

The factoring company’s invoice number this document is associated with.

Returns:

  • (String)


16
17
18
# File 'lib/tql_otr_factoring_data_exchange/models/document_upload_metadata.rb', line 16

def invoice_number
  @invoice_number
end

#tagsHash[String, String]

Arbitrary key-value metadata tags for this document. Keys and values are both strings. Use tags to annotate documents with operational data such as shortage counts, pallet quantities, seal numbers, etc.

Returns:

  • (Hash[String, String])


30
31
32
# File 'lib/tql_otr_factoring_data_exchange/models/document_upload_metadata.rb', line 30

def tags
  @tags
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  invoice_number = hash.key?('invoiceNumber') ? hash['invoiceNumber'] : nil
  document_type = hash.key?('documentType') ? hash['documentType'] : nil
  file_name = hash.key?('fileName') ? hash['fileName'] : SKIP
  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.
  DocumentUploadMetadata.new(invoice_number: invoice_number,
                             document_type: document_type,
                             file_name: file_name,
                             tags: tags,
                             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
# File 'lib/tql_otr_factoring_data_exchange/models/document_upload_metadata.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['invoice_number'] = 'invoiceNumber'
  @_hash['document_type'] = 'documentType'
  @_hash['file_name'] = 'fileName'
  @_hash['tags'] = 'tags'
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
54
55
56
# File 'lib/tql_otr_factoring_data_exchange/models/document_upload_metadata.rb', line 51

def self.nullables
  %w[
    file_name
    tags
  ]
end

.optionalsObject

An array for optional fields



43
44
45
46
47
48
# File 'lib/tql_otr_factoring_data_exchange/models/document_upload_metadata.rb', line 43

def self.optionals
  %w[
    file_name
    tags
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



104
105
106
107
108
109
# File 'lib/tql_otr_factoring_data_exchange/models/document_upload_metadata.rb', line 104

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

#to_sObject

Provides a human-readable string representation of the object.



96
97
98
99
100
101
# File 'lib/tql_otr_factoring_data_exchange/models/document_upload_metadata.rb', line 96

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