Skip to content

Commit

Permalink
Fix for issue hellosign#44
Browse files Browse the repository at this point in the history
Commit based on PR hellosign#50 that was never merged.
Added code to incorporate functionality for attachments with signer
requests
  • Loading branch information
oconnor-sn authored and neillom committed Feb 28, 2020
1 parent b602128 commit fa91de1
Show file tree
Hide file tree
Showing 2 changed files with 2,472 additions and 5 deletions.
36 changes: 31 additions & 5 deletions hellosign_sdk/hsclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def send_signature_request(self, test_mode=False, client_id=None, files=None, fi
title=None, subject=None, message=None, signing_redirect_url=None,
signers=None, cc_email_addresses=None, form_fields_per_document=None,
use_text_tags=False, hide_text_tags=False, custom_fields=None,
metadata=None, allow_decline=False, allow_reassign=False, signing_options=None):
metadata=None, allow_decline=False, allow_reassign=False, signing_options=None, attachments=False):
''' Creates and sends a new SignatureRequest with the submitted documents
Creates and sends a new SignatureRequest with the submitted documents.
Expand Down Expand Up @@ -414,6 +414,12 @@ def send_signature_request(self, test_mode=False, client_id=None, files=None, fi
signing_options (dict, optional): Allows the requester to specify the types allowed for creating a signature. Defaults to account settings.
attachments (list of dict): A list of attachments, which each has the following attributes:
name (str): The name of attachment
instructions (str): The instructions for uploading the attachment
signer_index (int): The signer's index whose needs to upload the attachments, see signers parameter for more details
required (bool, optional): Determines if the attachment must be uploaded
Returns:
A SignatureRequest object
Expand Down Expand Up @@ -445,7 +451,8 @@ def send_signature_request(self, test_mode=False, client_id=None, files=None, fi
'metadata': metadata,
'allow_decline': allow_decline,
'allow_reassign': allow_reassign,
'signing_options': signing_options
'signing_options': signing_options,
'attachments': attachments
}

return self._send_signature_request(**params)
Expand Down Expand Up @@ -625,7 +632,7 @@ def send_signature_request_embedded(self, test_mode=False, client_id=None,
files=None, file_urls=None, title=None, subject=None, message=None,
signing_redirect_url=None, signers=None, cc_email_addresses=None,
form_fields_per_document=None, use_text_tags=False, hide_text_tags=False,
metadata=None, allow_decline=False, allow_reassign=False, signing_options=None):
metadata=None, allow_decline=False, allow_reassign=False, signing_options=None, attachments=None):
''' Creates and sends a new SignatureRequest with the submitted documents
Creates a new SignatureRequest with the submitted documents to be signed
Expand Down Expand Up @@ -679,6 +686,13 @@ def send_signature_request_embedded(self, test_mode=False, client_id=None,
signing_options (dict, optional): Allows the requester to specify the types allowed for creating a signature. Defaults to account settings.
attachments (list of dict): A list of attachments, which each has the following attributes:
name (str): The name of attachment
instructions (str): The instructions for uploading the attachment
signer_index (int): The signer's index whose needs to upload the attachments, see signers parameter for more details
required (bool, optional): Determines if the attachment must be uploaded
Returns:
A SignatureRequest object
Expand Down Expand Up @@ -711,7 +725,8 @@ def send_signature_request_embedded(self, test_mode=False, client_id=None,
'allow_decline': allow_decline,
'allow_reassign': allow_reassign,
'signing_options': signing_options,
'is_for_embedded_signing': True
'is_for_embedded_signing': True,
'attachments': attachments
}

return self._send_signature_request(**params)
Expand Down Expand Up @@ -1862,7 +1877,7 @@ def _send_signature_request(self, test_mode=False, client_id=None, files=None,
signing_redirect_url=None, signers=None, custom_fields=None,
cc_email_addresses=None, form_fields_per_document=None, use_text_tags=False,
hide_text_tags=False, metadata=None, allow_decline=False, allow_reassign=False,
signing_options=None, is_for_embedded_signing=False):
signing_options=None, is_for_embedded_signing=False, attachments=None):
''' To share the same logic between send_signature_request &
send_signature_request_embedded functions
Expand Down Expand Up @@ -1911,6 +1926,13 @@ def _send_signature_request(self, test_mode=False, client_id=None, files=None,
is_for_embedded_signing (bool): send_signature_request and send_signature_request_embedded share the same sending logic. To differenciate the two calls embedded requests are now flagged.
attachments (list of dict): A list of attachments, which each has the following attributes:
name (str): The name of attachment
instructions (str): The instructions for uploading the attachment
signer_index (int): The signer's index whose needs to upload the attachments, see signers parameter for more details
required (bool, optional): Determines if the attachment must be uploaded
Returns:
A SignatureRequest object
Expand Down Expand Up @@ -2048,6 +2070,9 @@ def _send_signature_request_with_template(self, test_mode=False, client_id=None,
# Signing options
signing_options_payload = HSFormat.format_signing_options(signing_options, 'signing_options')

# Attachments
attachments_payload = HSFormat.format_dict_list(attachments, 'attachments')

# Template ids
template_ids_payload = {}
if template_ids:
Expand Down Expand Up @@ -2088,6 +2113,7 @@ def _send_signature_request_with_template(self, test_mode=False, client_id=None,
data.update(signing_options_payload)
data.update(template_ids_payload)
data.update(file_urls_payload)
data.update(attachments_payload)

request = self._get_request()
response = request.post(url, data=data, files=files_payload)
Expand Down
Loading

0 comments on commit fa91de1

Please sign in to comment.