Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/anydocs/getAnyDocumentTags.js
Original file line number Diff line number Diff line change
@@ -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'];
}
1 change: 1 addition & 0 deletions lib/client/client.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
10 changes: 10 additions & 0 deletions lib/types/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,16 @@ export declare class Client {
confidence_details?: boolean,
{...kwargs}?: VeryfiExtraArgs): Promise<JsonObject>;

/**
* 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
Expand Down
25 changes: 25 additions & 0 deletions test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 14 additions & 0 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading