peopledoc / pydocusign

Python client for DocuSign signature API
Other
18 stars 21 forks source link

DocuSignException in post_recipient_view when recipient's name change is not reflected in database #102

Open smcoll opened 7 years ago

smcoll commented 7 years ago

Narrowing in on a non-callback issue mentioned in https://github.com/novafloss/django-docusign/issues/65...

If a user has changed their name using the DocuSign interface while signing, and that name change is not reflected in the database, pydocusignEnvelope.post_recipient_view will raise an exception via DocuSignClient.post_recipient_view:

DocuSignException: DocuSign request failed: POST https://na2.docusign.net/restapi/v2/accounts/<account-id>/envelopes/<envelope_id>/views/recipient returned code 400 while expecting code 201; Message: {  
  "errorCode": "UNKNOWN_ENVELOPE_RECIPIENT",  
  "message": "The recipient you have identified is not a valid recipient of the specified envelope."  
} ;

This is because the lookup includes a name that no longer matches the recipient name in DocuSign's database.

According to https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST%20API%20References/Post%20Recipient%20View.htm, clientUserId can be used in conjuction with userId in lieu of email+userName to do the lookup. In our case, userName is out of sync with DocuSign, but clientUserId+userId would work.

My proposal is to only use email and userName in the POST data if ~clientUserId~userId is unavailable. This would prevent the exception in the case of an out-of-sync name where the more reliable ~clientUserId~userId can be used instead.

To do this, we would need to only pass the defined keyword arguments to DocuSignClient.post_recipient_view in the POST data, and determine which keyword arguments to use in the method call in pydocusignEnvelope.post_recipient_view.

zebuline commented 7 years ago

@smcoll thank you for the ticket; it is very clear and seems to be legit. Unfortunately I have no time this month for working on pydocusign. If you want to propose a PR, you are more than welcome.