-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new create sign request function with different required pa…
…rams
- Loading branch information
Showing
5 changed files
with
182 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,13 @@ 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, 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. | ||
The [`client.create_sign_request_v2(signers, files=None, parent_folder_id=None, 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) or template_id of the sign request template. You need to include at least one signer that will receive the Sign Request. | ||
|
||
Example with files: | ||
|
||
<!-- sample post_sign_requests --> | ||
|
||
```python | ||
source_file = { | ||
'id': '12345', | ||
|
@@ -32,12 +35,23 @@ files = [source_file] | |
|
||
signer = { | ||
'name': 'John Doe', | ||
'email': '[email protected]' | ||
'email': '[email protected]' | ||
} | ||
signers = [signer] | ||
|
||
parent_folder_id = '123456789' | ||
new_sign_request = client.create_sign_request(files, signers, parent_folder_id) | ||
new_sign_request = client.create_sign_request_v2(signers, files) | ||
print(f'(Sign Request ID: {new_sign_request.id})') | ||
``` | ||
|
||
Example with sign template | ||
|
||
```python | ||
signer = { | ||
'name': 'John Doe', | ||
'email': '[email protected]' | ||
} | ||
|
||
new_sign_request = client.create_sign_request_v2(signers, template_id = '12345') | ||
print(f'(Sign Request ID: {new_sign_request.id})') | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1819,6 +1819,11 @@ def test_create_sign_request(mock_client, mock_box_session, mock_sign_request_re | |
parent_folder_id = '12345' | ||
|
||
data = json.dumps({ | ||
'signers': [ | ||
{ | ||
'email': signer['email'] | ||
} | ||
], | ||
'source_files': [ | ||
{ | ||
'id': source_file['id'], | ||
|
@@ -1829,11 +1834,6 @@ def test_create_sign_request(mock_client, mock_box_session, mock_sign_request_re | |
'type': source_file2['type'] | ||
} | ||
], | ||
'signers': [ | ||
{ | ||
'email': signer['email'] | ||
} | ||
], | ||
'parent_folder': | ||
{ | ||
'id': parent_folder_id, | ||
|
@@ -1858,6 +1858,39 @@ def test_create_sign_request(mock_client, mock_box_session, mock_sign_request_re | |
assert new_sign_request['declined_redirect_url'] == declined_redirect_url | ||
assert new_sign_request['template_id'] == template_id | ||
|
||
def test_create_sign_request_v2(mock_client, mock_box_session, mock_sign_request_response): | ||
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' | ||
|
||
signer = { | ||
'email': '[email protected]' | ||
} | ||
signers = [signer] | ||
|
||
data = json.dumps({ | ||
'signers': [ | ||
{ | ||
'email': signer['email'] | ||
} | ||
], | ||
'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_v2( | ||
signers, | ||
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) | ||
assert new_sign_request['signers'][0]['email'] == signer['email'] | ||
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): | ||
# pylint:disable=redefined-outer-name | ||
|