A Python module for connecting to the Adobe Echosign REST API, without the hassle of dealing with the JSON formatting for requests/responses and the REST endpoints and their varying requirements
The most up to date documentation can be found on pyEchosign's RTD page.
In order to interact with the API, you need to create an instance of
EchosignAccount, which will allow you to send/retrieve
agreements, documents, etc.
Note that this module does not handle the OAuth process, gaining an access token must be done outside of this module.
from pyEchosign import * token = 'My Access Token' account = EchosignAccount(token) # When the access token is refreshed account.access_token = 'new access token'
from pyEchosign import * account = EchosignAccount('') agreement = Agreement(account, name='My Agreement') # MIME type is optional - it will be inferred from the file extension by Adobe if not provided file = TransientDocument(account, 'To be Signed.pdf', 'some bytes', 'application/pdf') agreement.files = [file] # If your document utilizes merge fields, you can specify which fields should be merged with what values. # If you have no idea what this is, just ignore it - it's not required :) merge_fields = [dict(field_name='some_field_name', default_value='some default value')] recipients = [Recipient('firstname.lastname@example.org'), Recipient('email@example.com')] agreement.send(recipients, merge_fields=merge_fields, ccs=['firstname.lastname@example.org'])
This method retrieves the most recent 9 agreements from the account. A query can be specified to search through the account's agreements.
from pyEchosign import * account = EchosignAccount('') agreements = account.get_agreements() agreements >>> Some Agreement Title agreements = account.get_agreements('query') agreements >>> 'Some Agreement Title with the Word query In It'
You can either cancel an agreement, which will make it still visible on the user's Manage page, or delete it which removes it entirely.
from pyEchosign import * account = EchosignAccount('') agreements = account.get_agreements() agreement = agreements print(agreement.status) >>> Agreement.Status.OUT_FOR_SIGNATURE agreement.cancel() # Still visible, but no longer waiting for signature print(agreement.status) >>> Agreement.Status.RECALLED agreement.delete() # and now it's gone
Most classes contain two methods to facilitate the process of receiving JSON from the REST API and turning that into
Python classes. One,
json_to_X() will handle the JSON formatting for a single instance, while the second -
json_to_Xs() processes JSON for multiple instances. Generally, the latter is simply returning a list comprehension that
calls the former.
While this is primarily useful for internal purposes - every method retrieving an
Agreement from the API will call
Agreement.json_to_agreement() for example - the methods are not private and available for use. Any changes to their
interface will only be made following deprecation warnings.
All protected and private methods; and any classes, functions, or methods found under
pyEchosign.utils are subject to
change without deprecation warnings however.