From f9d596d70b793d6bac516aa9fd72ca53dd282543 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 19 Aug 2026 19:53:43 +0000 Subject: [PATCH] Add get_any_document_tags for AnyDoc tags endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expose GET /any-documents/{document_id}/tags/ as Client.get_any_document_tags, with TypeScript typings and unit tests covering the request path and response shape. Co-authored-by: Alejandro Uribe Sánchez --- lib/anydocs/getAnyDocumentTags.js | 15 +++++++++++++++ lib/client/client.js | 1 + lib/types/Client.ts | 10 ++++++++++ test/main.test.js | 25 +++++++++++++++++++++++++ tests/main.test.ts | 14 ++++++++++++++ 5 files changed, 65 insertions(+) create mode 100644 lib/anydocs/getAnyDocumentTags.js diff --git a/lib/anydocs/getAnyDocumentTags.js b/lib/anydocs/getAnyDocumentTags.js new file mode 100644 index 0000000..1a8df60 --- /dev/null +++ b/lib/anydocs/getAnyDocumentTags.js @@ -0,0 +1,15 @@ +const Client = require('../client/constructor'); +/** + * Return all tags assigned to a specific any document. https://docs.veryfi.com/api/anydocs/get-A-doc-tags/ + * + * @memberof Client + * @param {number} document_id The unique identifier of the document. + * @param {Object} kwargs Additional request parameters + * @returns {JSON} List of tags assigned to a specific any document. + */ +Client.prototype.get_any_document_tags = async function (document_id, {...kwargs} = {}) { + let endpoint_name = `/any-documents/${document_id}/tags/`; + let request_arguments = {}; + let response = await this._request("GET", endpoint_name, request_arguments, kwargs, false); + return response['data']; +} diff --git a/lib/client/client.js b/lib/client/client.js index 6c0827c..d1d6675 100644 --- a/lib/client/client.js +++ b/lib/client/client.js @@ -1,6 +1,7 @@ const Client = require('../client/function'); require('../anydocs/deleteAnyDocument'); require('../anydocs/getAnyDocument'); +require('../anydocs/getAnyDocumentTags'); require('../anydocs/getAnyDocuments'); require('../anydocs/processAnyDocument'); require('../anydocs/processAnyDocumentBase64'); diff --git a/lib/types/Client.ts b/lib/types/Client.ts index d715ec6..5ff7483 100644 --- a/lib/types/Client.ts +++ b/lib/types/Client.ts @@ -317,6 +317,16 @@ export declare class Client { confidence_details?: boolean, {...kwargs}?: VeryfiExtraArgs): Promise; + /** + * Return all tags assigned to a specific any document. https://docs.veryfi.com/api/anydocs/get-A-doc-tags/ + * @memberof Client + * @param {number} document_id The unique identifier of the document. + * @param {Object} kwargs Additional request parameters + * @returns {Promise<{tags: Tag[]}>} List of tags assigned to a specific any document. + */ + public get_any_document_tags(document_id: number, + {...kwargs}?: VeryfiExtraArgs): Promise<{tags: Tag[]}>; + /** * Process any document and extract all the fields from it. https://docs.veryfi.com/api/anydocs/process-%E2%88%80-doc/ * @example diff --git a/test/main.test.js b/test/main.test.js index 9521ae2..1d15836 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -377,6 +377,31 @@ describe('Processing any documents', () => { } }); + test('Get any document tags', async () => { + try { + if (mock_responses) { + const mockResponse = require('../mocks/getTags.json'); + veryfi_client._request = jest.fn().mockResolvedValue(mockResponse); + } + const doc_id = 4559535; + let response = await veryfi_client.get_any_document_tags(doc_id); + expect(response.tags).toBeDefined(); + expect(response.tags.length).toBeGreaterThan(0); + expect(response.tags[0].name).toBeDefined(); + if (mock_responses) { + expect(veryfi_client._request).toHaveBeenCalledWith( + "GET", + `/any-documents/${doc_id}/tags/`, + {}, + {}, + false + ); + } + } catch (error) { + throw new Error(error); + } + }); + test('Process any document from file_path', async () => { try { if (mock_responses) { diff --git a/tests/main.test.ts b/tests/main.test.ts index ee15753..d8e9c0d 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -511,6 +511,20 @@ describe('Processing any documents', () => { } }); + test('Get any document tags', async () => { + try { + if (mock_responses) { + return assert(true) + } + let docs = await veryfi_client.get_any_documents(); + const doc_id = docs.results[0].id; + let response = await veryfi_client.get_any_document_tags(doc_id); + expect(response.tags).toBeDefined(); + } catch (error) { + throw new Error(error); + } + }); + test(`Get any doc with id `, async () => { try { if (mock_responses) {