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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ as kwargs.
* List via ```client.templates.list(...)``` or ```client.templates.paged_list(...)```
* Retrieve via ```client.templates.retrieve(...)```
* Update via ```client.templates.update(...)```
* Delete via ```client.templates.delete(...)```
* Create Preparation Session via ```client.templates.create_preparation_session(...)```

### Envelope Template Related
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = blueink-client-python
version = 1.5.0
version = 1.6.0
author = Blueink
author_email = pypi@blueink.com
description = Python Client for Blueink eSignature API
Expand Down
3 changes: 3 additions & 0 deletions src/blueink/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@
EVENT_BUNDLE_ERROR="bundle_error",
EVENT_BUNDLE_CANCELLED="bundle_cancelled",
EVENT_BUNDLE_SIGNER_REASSIGNED="bundle_signer_reassigned",
EVENT_DOC_TEMPLATE_CREATED="doc_template_created",
EVENT_DOC_TEMPLATE_UPDATED="doc_template_updated",
EVENT_DOC_TEMPLATE_DELETED="doc_template_deleted",
EVENT_PACKET_VIEWED="packet_viewed",
EVENT_PACKET_COMPLETE="packet_complete",
EVENT_PACKET_DECLINED="packet_declined",
Expand Down
1 change: 1 addition & 0 deletions src/blueink/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class TEMPLATES:
LIST = "/templates/"
RETRIEVE = "/templates/${template_id}/"
UPDATE = "/templates/${template_id}/"
DELETE = "/templates/${template_id}/"
CREATE_PREPARATION_SESSION = "/templates/preparation_session/"


Expand Down
18 changes: 18 additions & 0 deletions src/blueink/subclients/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ def update(self, template_id: str, data: dict) -> NormalizedResponse:
url = self.build_url(endpoints.TEMPLATES.UPDATE, template_id=template_id)
return self._requests.patch(url, json=data)

def delete(self, template_id: str) -> NormalizedResponse:
"""Soft-delete a Document Template.

The API disables the template and removes it from account libraries
(HTTP 204). Globally shared templates cannot be deleted (HTTP 403).

Args:
template_id:

Returns:
NormalizedResponse object
"""
url = self.build_url(endpoints.TEMPLATES.DELETE, template_id=template_id)
return self._requests.delete(url)

def create_preparation_session(self, data: dict) -> NormalizedResponse:
"""Create an embedded template preparation session.

Expand All @@ -86,6 +101,9 @@ def create_preparation_session(self, data: dict) -> NormalizedResponse:
data: configuration for the preparation session. Supported keys:
- template_id (str, optional): slug of an existing template to edit
- redirect_url (str, optional): URL to redirect to after preparation
- allowed_data_flow_tags (list[str], optional): exact tag names or
namespace-prefix patterns such as ``acme:*``. An empty list allows
no tags; omit the field to leave the session unfiltered.

Returns:
NormalizedResponse object with keys:
Expand Down
16 changes: 16 additions & 0 deletions src/blueink/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,22 @@ def test_template_update_url(self):
)
self.assert_equal(url, f"{self.BASE_URL}/templates/T-abc123/")

def test_template_delete_url(self):
client = self._client()
url = client.templates.build_url(
endpoints.TEMPLATES.DELETE, template_id="T-abc123"
)
self.assert_equal(url, f"{self.BASE_URL}/templates/T-abc123/")

def test_event_type_includes_doc_template_events(self):
values = EVENT_TYPE.values()
self.assert_equal(EVENT_TYPE.EVENT_DOC_TEMPLATE_CREATED, "doc_template_created")
self.assert_equal(EVENT_TYPE.EVENT_DOC_TEMPLATE_UPDATED, "doc_template_updated")
self.assert_equal(EVENT_TYPE.EVENT_DOC_TEMPLATE_DELETED, "doc_template_deleted")
self.assert_in("doc_template_created", values)
self.assert_in("doc_template_updated", values)
self.assert_in("doc_template_deleted", values)

def test_bundle_update_url(self):
client = self._client()
url = client.bundles.build_url(endpoints.BUNDLES.UPDATE, bundle_id="B-abc123")
Expand Down
Loading