Skip to content

Commit f76bba0

Browse files
authored
Merge pull request #41 from veryfi/feature/add-tag-function
Add tag function
2 parents 4fbf71c + 8dda212 commit f76bba0

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.coverage
22
tests/__pycache__/
33
veryfi/__pycache__/
4+
.idea/*

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
CHANGES
22
=======
3+
3.2.0
4+
-----
5+
* Add support to add tags on existing documents
36

47
3.1.1
58
-----

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ veryfi_client.update_document(id=12345, vendor=new_vendor, category=new_category
152152

153153

154154
## Need help?
155+
Visit https://docs.veryfi.com/ to access integration guides and usage notes in the Veryfi API Documentation Portal
156+
155157
If you run into any issue or need help installing or using the library, please contact support@veryfi.com.
156158

157159
If you found a bug in this library or would like new features added, then open an issue or pull requests against this repo!

tests/test_client.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,17 @@ def test_get_documents():
367367
**{"created_lt": "2021-07-22+00:00:00"},
368368
)
369369
assert d == mock
370+
371+
372+
@responses.activate
373+
def test_tags():
374+
mock_doc_id = 169985445
375+
mock_resp = {"id": 6673474, "name": "tag_123"}
376+
client = Client(client_id="v", client_secret="w", username="o", api_key="c")
377+
responses.put(
378+
f"{client.versioned_url}/partner/documents/{mock_doc_id}/tags/",
379+
json=mock_resp,
380+
status=200,
381+
)
382+
d = client.add_tag(mock_doc_id, "tag_123")
383+
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.0.0",
64+
"User-Agent": "Python Veryfi-Python/3.2.0",
6565
"Accept": "application/json",
6666
"Content-Type": "application/json",
6767
"Client-Id": self.client_id,
@@ -387,3 +387,14 @@ def delete_line_item(self, document_id, line_item_id):
387387
endpoint_name = f"/documents/{document_id}/line-items/{line_item_id}"
388388
request_arguments = {}
389389
self._request("DELETE", endpoint_name, request_arguments)
390+
391+
def add_tag(self, document_id, tag_name):
392+
"""
393+
Add a new tag on an existing document.
394+
:param document_id: ID of the document you'd like to update
395+
:param tag_name: name of the new tag
396+
:return: Added tag data
397+
"""
398+
endpoint_name = f"/documents/{document_id}/tags/"
399+
request_arguments = {"name": tag_name}
400+
return self._request("PUT", endpoint_name, request_arguments)

0 commit comments

Comments
 (0)