Skip to content

Commit

Permalink
Update sign request template id
Browse files Browse the repository at this point in the history
  • Loading branch information
congminh1254 committed Aug 11, 2023
1 parent a89958b commit c1d2ba9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
10 changes: 5 additions & 5 deletions boxsdk/client/client.py
Expand Up @@ -1522,10 +1522,10 @@ def create_sign_request(
email_message: Optional[Iterable] = None,
email_subject: Optional[str] = None,
external_id: Optional[str] = None,
sign_template_id: Optional[str] = None,
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.
Expand Down Expand Up @@ -1555,15 +1555,15 @@ def create_sign_request(
Subject of sign request email. This is cleaned by sign request. If this field is not passed, a default subject will be used.
:param external_id:
This can be used to reference an ID in an external system that the sign request is related to.
:param sign_template_id:
ID of Sign template to apply.
:param is_document_preparation_needed:
Indicates if the sender should receive a prepare_url in the response to complete document preparation via UI.
:param redirect_url:
The URL that a signer will be redirected to after signing a document.
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
"""
Expand Down Expand Up @@ -1598,8 +1598,8 @@ def create_sign_request(
body['redirect_url'] = redirect_url
if declined_redirect_url:
body['declined_redirect_url'] = declined_redirect_url
if sign_template_id:
body['template_id'] = sign_template_id
if template_id:
body['template_id'] = template_id

box_response = self._session.post(url, data=json.dumps(body))
response = box_response.json()
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/sign_requests.md
Expand Up @@ -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 -->
Expand Down
8 changes: 6 additions & 2 deletions test/unit/client/test_client.py
Expand Up @@ -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

Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion test/unit/object/test_sign_request.py
Expand Up @@ -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

Expand Down

0 comments on commit c1d2ba9

Please sign in to comment.