Class: TqlOtrFactoringDataExchange::Base64DocumentUploadRequest

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

Overview

JSON request to upload a document as a base64-encoded string, linked to an invoice.

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:, document:, tags: SKIP, additional_properties: nil) ⇒ Base64DocumentUploadRequest

Returns a new instance of Base64DocumentUploadRequest.



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document_upload_request.rb', line 55

def initialize(invoice_number:, document_type:, document:, 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
  @document = document
  @tags = tags unless tags == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#documentBase64Document

An optional document to include with the request, encoded as a base64 string.

Returns:



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

def document
  @document
end

#document_typeDocumentType

Document type classification used for categorizing uploaded documents.

Returns:



19
20
21
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document_upload_request.rb', line 19

def document_type
  @document_type
end

#invoice_numberString

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

Returns:

  • (String)


15
16
17
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document_upload_request.rb', line 15

def invoice_number
  @invoice_number
end

#tagsHash[String, String]

Arbitrary key-value metadata tags for this document.

Returns:

  • (Hash[String, String])


28
29
30
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document_upload_request.rb', line 28

def tags
  @tags
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document_upload_request.rb', line 68

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
  document = Base64Document.from_hash(hash['document']) if hash['document']
  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.
  Base64DocumentUploadRequest.new(invoice_number: invoice_number,
                                  document_type: document_type,
                                  document: document,
                                  tags: tags,
                                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



31
32
33
34
35
36
37
38
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document_upload_request.rb', line 31

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

.nullablesObject

An array for nullable fields



48
49
50
51
52
53
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document_upload_request.rb', line 48

def self.nullables
  %w[
    document
    tags
  ]
end

.optionalsObject

An array for optional fields



41
42
43
44
45
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document_upload_request.rb', line 41

def self.optionals
  %w[
    tags
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



100
101
102
103
104
105
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document_upload_request.rb', line 100

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

#to_sObject

Provides a human-readable string representation of the object.



93
94
95
96
97
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document_upload_request.rb', line 93

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