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
14 changes: 14 additions & 0 deletions lib/anydocs/deleteAnyDocumentTag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const Client = require('../client/constructor');
/**
* Unlink a tag from a specific any document. https://docs.veryfi.com/api/anydocs/unlink-a-tag-from-a-A-doc/
*
* @memberof Client
* @param {string} document_id ID of the document you'd like to unlink the tag from
* @param {string} tag_id ID of the tag you'd like to unlink
* @return {JSON} response about the unlinked tag.
*/
Client.prototype.delete_any_document_tag = async function (document_id, tag_id) {
let endpoint_name = `/any-documents/${document_id}/tags/${tag_id}/`;
let request_arguments = {};
return this._request("DELETE", endpoint_name, request_arguments);
}
1 change: 1 addition & 0 deletions lib/client/client.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Client = require('../client/function');
require('../anydocs/deleteAnyDocument');
require('../anydocs/deleteAnyDocumentTag');
require('../anydocs/getAnyDocument');
require('../anydocs/getAnyDocumentTags');
require('../anydocs/getAnyDocuments');
Expand Down
10 changes: 10 additions & 0 deletions lib/types/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,16 @@ export declare class Client {
public get_any_document_tags(document_id: number,
{...kwargs}?: VeryfiExtraArgs): Promise<{tags: Tag[]}>;

/**
* Unlink a tag from a specific any document. https://docs.veryfi.com/api/anydocs/unlink-a-tag-from-a-A-doc/
*
* @memberof Client
* @param {string} document_id ID of the document you'd like to unlink the tag from
* @param {string} tag_id ID of the tag you'd like to unlink
* @return {Promise<any>} response about the unlinked tag.
*/
public delete_any_document_tag(document_id: string, tag_id: string): Promise<any>;
Comment on lines +334 to +338

/**
* Process any document and extract all the fields from it. https://docs.veryfi.com/api/anydocs/process-%E2%88%80-doc/
* @example
Expand Down
22 changes: 22 additions & 0 deletions test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,28 @@ describe('Processing any documents', () => {
}
});

test('Unlink a tag from an any document', async () => {
try {
if (mock_responses) {
const mockResponse = require('../mocks/deleteTags.json');
veryfi_client._request = jest.fn().mockResolvedValue(mockResponse);
}
const doc_id = 4559535;
const tag_id = 12345;
let response = await veryfi_client.delete_any_document_tag(doc_id, tag_id);
expect(response).toBeDefined();
if (mock_responses) {
expect(veryfi_client._request).toHaveBeenCalledWith(
"DELETE",
`/any-documents/${doc_id}/tags/${tag_id}/`,
{}
);
}
} catch (error) {
throw new Error(error);
}
});

test('Get any document tags', async () => {
try {
if (mock_responses) {
Expand Down
16 changes: 16 additions & 0 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,22 @@ describe('Processing any documents', () => {
}
});

test('Unlink a tag from an any document', async () => {
try {
if (mock_responses) {
return assert(true)
}
let docs = await veryfi_client.get_any_documents();
const doc_id = docs.results[0].id;
const tags = await veryfi_client.get_any_document_tags(doc_id);
const tag_id = tags.tags[0].id;
let response = await veryfi_client.delete_any_document_tag(doc_id, tag_id);
expect(response).toBeDefined();
} catch (error) {
throw new Error(error);
}
});

test('Get any document tags', async () => {
try {
if (mock_responses) {
Expand Down
Loading