Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add, remove recipients #72

Closed
wants to merge 3 commits into from
Closed
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
49 changes: 49 additions & 0 deletions pydocusign/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ def post(self, *args, **kwargs):
"""Shortcut to perform POST operations on DocuSign API."""
return self._request(method='POST', *args, **kwargs)

def put(self, *args, **kwargs):
"""Shortcut to perform PUT operations on DocuSign API."""
return self._request(method='PUT', *args, **kwargs)

def delete(self, *args, **kwargs):
"""Shortcut to perform DELETE operations on DocuSign API."""
return self._request(method='DELETE', *args, **kwargs)
Expand Down Expand Up @@ -399,6 +403,51 @@ def get_envelope_recipients(self, envelopeId):
envelopeId=envelopeId)
return self.get(url)

def delete_envelope_recipients(self, envelopeId, recipientIds):
"""DELETE to /accounts/{accountId}/envelopes/{envelopeId}/recipients
and return JSON.

``recipientIds`` is a list of ``recipientId`` values for recipients
which will be deleted from the envelope

NOTE: only `Signer` type recipients are currently supported
"""
if isinstance(recipientIds, basestring):
recipientIds = [recipientIds]
if not self.account_url:
self.login_information()
url = '/accounts/{accountId}/envelopes/{envelopeId}/recipients' \
.format(accountId=self.account_id,
envelopeId=envelopeId)
data = {
'signers': [{'recipientId': x} for x in recipientIds]
}
return self.delete(url, data=data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simple test would be to check all that formatting:

def test_delete_envelope...(self):
    client = ...
    with patch('DocusignClient.delete') as delete:
        client.delete_enveleop_recipients(...)

This way we have coverage of this unit of code. The integration with docusign process is another test strategy that could be done with in-house integration plateform.


def delete_envelope_recipient(self, envelopeId, recipientId):
"""Remove a recipient, by id, from an envelope."""
return self.delete_envelope_recipients(envelopeId, [recipientId])

def add_envelope_recipients(self, envelopeId, recipients):
"""PUT to {account}/envelopes/{envelopeId}/recipients and return
JSON.

"""
if not self.account_url:
self.login_information()
url = '/accounts/{accountId}/envelopes/{envelopeId}/recipients' \
.format(accountId=self.account_id,
envelopeId=envelopeId)
data = {
'signers': [signer.to_dict() for signer in recipients]
}
return self.put(url, data=data)

def add_envelope_recipient(self, envelopeId, recipient):
"""Add a recipient (`Signer` or `Role`) to an envelope
"""
return self.add_envelope_recipients(envelopeId, [recipient])

def post_recipient_view(self, authenticationMethod=None,
clientUserId='', email='', envelopeId='',
returnUrl='', userId='', userName=''):
Expand Down