Skip to content

Commit 4d569c3

Browse files
Add support to add multiple tags on existing documents
1 parent f7040b0 commit 4d569c3

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
CHANGES
22
=======
3+
3.4.1
4+
-----
5+
* Add support to add multiple tags on existing documents
6+
37
3.4.0
48
-----
59
* Add support to add tags on existing documents

tests/test_client.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,17 @@ def test_tags():
381381
)
382382
d = client.add_tag(mock_doc_id, "tag_123")
383383
assert d == mock_resp
384+
385+
386+
@responses.activate
387+
def test_multiple_tags():
388+
mock_doc_id = 169985445
389+
mock_resp = {"id": 6673474, "tags": ["tag_1", "tag_2", "tag_3"]}
390+
client = Client(client_id="v", client_secret="w", username="o", api_key="c")
391+
responses.put(
392+
f"{client.versioned_url}/partner/documents/{mock_doc_id}/tags/",
393+
json=mock_resp,
394+
status=200,
395+
)
396+
d = client.add_tags(mock_doc_id, ["tag_1", "tag_2", "tag_3"])
397+
assert d == mock_resp

veryfi/client.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _get_headers(self) -> Dict:
6161
:return: Dictionary with headers
6262
"""
6363
final_headers = {
64-
"User-Agent": "Python Veryfi-Python/3.4.0",
64+
"User-Agent": "Python Veryfi-Python/3.4.1",
6565
"Accept": "application/json",
6666
"Content-Type": "application/json",
6767
"Client-Id": self.client_id,
@@ -398,3 +398,14 @@ def add_tag(self, document_id, tag_name):
398398
endpoint_name = f"/documents/{document_id}/tags/"
399399
request_arguments = {"name": tag_name}
400400
return self._request("PUT", endpoint_name, request_arguments)
401+
402+
def add_tags(self, document_id, tags):
403+
"""
404+
Add multiple tags on an existing document.
405+
:param document_id: ID of the document you'd like to update
406+
:param tags: array of strings
407+
:return: Added tags data
408+
"""
409+
endpoint_name = f"/documents/{document_id}/tags/"
410+
request_arguments = {"tags": tags}
411+
return self._request("PUT", endpoint_name, request_arguments)

0 commit comments

Comments
 (0)