Class: TqlOtrFactoringDataExchange::DocumentsApi
- Defined in:
- lib/tql_otr_factoring_data_exchange/apis/documents_api.rb
Overview
DocumentsApi
Constant Summary
Constants inherited from BaseApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#upload_document(file, metadata) ⇒ ApiResponse
Upload a document via ‘multipart/form-data` and associate it with an invoice.
-
#upload_document_base64(body) ⇒ ApiResponse
Upload a document as a base64-encoded string in a JSON request body and associate it with an invoice.
Methods inherited from BaseApi
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from TqlOtrFactoringDataExchange::BaseApi
Instance Method Details
#upload_document(file, metadata) ⇒ ApiResponse
Upload a document via ‘multipart/form-data` and associate it with an invoice. The request contains two parts:
-
file — the raw binary document content
-
metadata — a JSON string containing the invoice ID, document type, optional file name, and key-value tags (e.g., ‘“shortage”: “2”`, `“palletCount”: “14”`)
**Supported document types** are listed in the ‘DocumentType` enum. Accepted asynchronously — returns `202` with a document receipt. To upload multiple documents, make one request per document. content. the document upload, provided as the `metadata` part of the `multipart/form-data` request. Specifies the invoice linkage, document classification, and optional tags.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/tql_otr_factoring_data_exchange/apis/documents_api.rb', line 25 def upload_document(file, ) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/documents', Server::DEFAULT) .multipart_param(new_parameter(file, key: 'file') .is_required(true) .default_content_type('application/octet-stream')) .multipart_param(new_parameter(StringIO.new(.to_json), key: 'metadata') .is_required(true) .default_content_type('application/json')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('bearerAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(DocumentUploadResponse.method(:from_hash)) .is_api_response(true) .local_error('400', "Validation error — missing required fields or invalid document'\ ' type.\n", ProblemDetailsErrorException)) .execute end |
#upload_document_base64(body) ⇒ ApiResponse
Upload a document as a base64-encoded string in a JSON request body and associate it with an invoice. Use this endpoint when ‘multipart/form-data` is inconvenient (e.g., from environments that prefer pure JSON payloads). **Supported document types** are listed in the `DocumentType` enum. Accepted asynchronously — returns `202` with a document receipt. To upload multiple documents, make one request per document. payload containing the base64-encoded document content along with invoice linkage, document type, and optional tags.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/tql_otr_factoring_data_exchange/apis/documents_api.rb', line 60 def upload_document_base64(body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/documents/base64', Server::DEFAULT) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('bearerAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(DocumentUploadResponse.method(:from_hash)) .is_api_response(true) .local_error('400', "Validation error — missing required fields or invalid document'\ ' type.\n", ProblemDetailsErrorException)) .execute end |