Repository: box/box-python-sdk
Pull request #834 (2023-08-01 18:33:18)

feat: Support create sign request calls with sign template IDs

coveralls: ## Pull Request Test Coverage Report for [Build 5831971824](https://coveralls.io/builds/61930938)

* **2** of **2**   **(100.0%)**  changed or added relevant lines in **1** file are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage increased (+**0.003%**) to **93.528%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/61930938/badge)](https://coveralls.io/builds/61930938) |
| :-- | --: |
| Change from base [Build 5725071206](https://coveralls.io/builds/61700063): |  0.003% |
| Covered Lines: | 3454 |
| Relevant Lines: | 3693 |

---
##### 💛  - [Coveralls](https://coveralls.io)


Patch:
diff --git a/boxsdk/client/client.py b/boxsdk/client/client.py
index 1e32e66..ebe1a20 100644
--- a/boxsdk/client/client.py
+++ b/boxsdk/client/client.py
@@ -1525,6 +1525,7 @@ def create_sign_request(
             is_document_preparation_needed: Optional[bool] = None,
             redirect_url: Optional[str] = None,
             declined_redirect_url: Optional[str] = None,
+            template_id: Optional[str] = None,
     ) -> dict:
         """
         Used to create a new sign request.
@@ -1561,6 +1562,8 @@ def create_sign_request(
             If no declined redirect URL is specified, this URL will be used for decline actions as well.
         :param declined_redirect_url:
             The URL that a signer will be redirected to after declining to sign a document.
+        :param template_id:
+            The ID of the sign template to use for the sign request.
         :returns:
             A dictionary representing a created SignRequest
         """
@@ -1595,6 +1598,9 @@ def create_sign_request(
             body['redirect_url'] = redirect_url
         if declined_redirect_url:
             body['declined_redirect_url'] = declined_redirect_url
+        if template_id:
+            body['template_id'] = template_id
+
         box_response = self._session.post(url, data=json.dumps(body))
         response = box_response.json()
         return self.translator.translate(
diff --git a/docs/usage/sign_requests.md b/docs/usage/sign_requests.md
index 75a6570..120595a 100644
--- a/docs/usage/sign_requests.md
+++ b/docs/usage/sign_requests.md
@@ -19,7 +19,7 @@ A Sign Request can refer to one or more Box Files and can be sent to one or more
 Create Sign Request
 ------------------------
 
-The [`client.create_sign_request(files, signers, parent_folder_id, prefill_tags=None, are_reminders_enabled=None, are_text_signatures_enabled=None, days_valid=None, email_message=None, email_subject=None, external_id=None, is_document_preparation_needed=None, redirect_url=None, declined_redirect_url=None)`][create-sign-request]
+The [`client.create_sign_request(files, signers, parent_folder_id, prefill_tags=None, are_reminders_enabled=None, are_text_signatures_enabled=None, days_valid=None, email_message=None, email_subject=None, external_id=None, is_document_preparation_needed=None, redirect_url=None, declined_redirect_url=None, template_id=None)`][create-sign-request]
 method will create a Sign Request. You need to provide at least one file and up to 10 files (from which the signing document will be created) with at least one signer to receive the Sign Request.
 
 <!-- sample post_sign_requests -->


Test patch:
diff --git a/test/unit/client/test_client.py b/test/unit/client/test_client.py
index 0a4b7b4..a5058a7 100644
--- a/test/unit/client/test_client.py
+++ b/test/unit/client/test_client.py
@@ -1658,7 +1658,8 @@ def mock_sign_request_response():
                 }
             }
         ],
-        'status': 'converting'
+        'status': 'converting',
+        'template_id': '123075213-af2c8822-3ef2-4952-8557-52d69c2fe9cb'
     }
     return mock_sign_request
 
@@ -1688,6 +1689,7 @@ def test_create_sign_request(mock_client, mock_box_session, mock_sign_request_re
     expected_url = f'{API.BASE_API_URL}/sign_requests'
     redirect_url = 'https://www.box.com/accepted'
     declined_redirect_url = 'https://www.box.com/declined'
+    template_id = '123075213-af2c8822-3ef2-4952-8557-52d69c2fe9cb'
     source_file = {
         'id': '12345',
         'type': 'file'
@@ -1727,12 +1729,13 @@ def test_create_sign_request(mock_client, mock_box_session, mock_sign_request_re
         },
         'redirect_url': redirect_url,
         'declined_redirect_url': declined_redirect_url,
+        'template_id': template_id
     })
     mock_box_session.post.return_value.json.return_value = mock_sign_request_response
 
     new_sign_request = mock_client.create_sign_request(
         files, signers, parent_folder_id,
-        redirect_url=redirect_url, declined_redirect_url=declined_redirect_url)
+        redirect_url=redirect_url, declined_redirect_url=declined_redirect_url, template_id=template_id)
 
     mock_box_session.post.assert_called_once_with(expected_url, data=data)
     assert isinstance(new_sign_request, SignRequest)
@@ -1741,6 +1744,7 @@ def test_create_sign_request(mock_client, mock_box_session, mock_sign_request_re
     assert new_sign_request['parent_folder']['id'] == parent_folder_id
     assert new_sign_request['redirect_url'] == redirect_url
     assert new_sign_request['declined_redirect_url'] == declined_redirect_url
+    assert new_sign_request['template_id'] == template_id
 
 
 def test_file_request(mock_client):
diff --git a/test/unit/object/test_sign_request.py b/test/unit/object/test_sign_request.py
index 5e23d7b..b3a7909 100644
--- a/test/unit/object/test_sign_request.py
+++ b/test/unit/object/test_sign_request.py
@@ -107,7 +107,8 @@ def mock_sign_request_response():
                 }
             }
         ],
-        'status': 'cancelled'
+        'status': 'cancelled',
+        'template_id': '123075213-af2c8822-3ef2-4952-8557-52d69c2fe9cb'
     }
     return mock_sign_request