diff --git a/.gitignore b/.gitignore index c61cfec..8d56382 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .coverage tests/__pycache__/ veryfi/__pycache__/ +.idea/* diff --git a/NEWS.md b/NEWS.md index 077abda..cfc09e6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ CHANGES ======= +3.2.0 +----- +* Add support to add tags on existing documents 3.1.1 ----- diff --git a/README.md b/README.md index 3bf35db..0024bc9 100755 --- a/README.md +++ b/README.md @@ -152,6 +152,8 @@ veryfi_client.update_document(id=12345, vendor=new_vendor, category=new_category ## Need help? +Visit https://docs.veryfi.com/ to access integration guides and usage notes in the Veryfi API Documentation Portal + If you run into any issue or need help installing or using the library, please contact support@veryfi.com. If you found a bug in this library or would like new features added, then open an issue or pull requests against this repo! diff --git a/tests/test_client.py b/tests/test_client.py index 62c8c55..8c95e8f 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -367,3 +367,17 @@ def test_get_documents(): **{"created_lt": "2021-07-22+00:00:00"}, ) assert d == mock + + +@responses.activate +def test_tags(): + mock_doc_id = 169985445 + mock_resp = {"id": 6673474, "name": "tag_123"} + client = Client(client_id="v", client_secret="w", username="o", api_key="c") + responses.put( + f"{client.versioned_url}/partner/documents/{mock_doc_id}/tags/", + json=mock_resp, + status=200, + ) + d = client.add_tag(mock_doc_id, "tag_123") + assert d == mock_resp diff --git a/veryfi/client.py b/veryfi/client.py index 760a575..f24ae8c 100644 --- a/veryfi/client.py +++ b/veryfi/client.py @@ -61,7 +61,7 @@ def _get_headers(self) -> Dict: :return: Dictionary with headers """ final_headers = { - "User-Agent": "Python Veryfi-Python/3.0.0", + "User-Agent": "Python Veryfi-Python/3.2.0", "Accept": "application/json", "Content-Type": "application/json", "Client-Id": self.client_id, @@ -387,3 +387,14 @@ def delete_line_item(self, document_id, line_item_id): endpoint_name = f"/documents/{document_id}/line-items/{line_item_id}" request_arguments = {} self._request("DELETE", endpoint_name, request_arguments) + + def add_tag(self, document_id, tag_name): + """ + Add a new tag on an existing document. + :param document_id: ID of the document you'd like to update + :param tag_name: name of the new tag + :return: Added tag data + """ + endpoint_name = f"/documents/{document_id}/tags/" + request_arguments = {"name": tag_name} + return self._request("PUT", endpoint_name, request_arguments)