def testListDocuments(self): auth_api = AuthenticationApi() envelopes_api = EnvelopesApi() try: login_info = auth_api.login() assert login_info is not None assert len(login_info.login_accounts) > 0 login_accounts = login_info.login_accounts assert login_accounts[0].account_id is not None base_url, _ = login_accounts[0].base_url.split('/v2') self.api_client.host = base_url docusign.configuration.api_client = self.api_client docs_list = envelopes_api.list_documents( login_accounts[0].account_id, self.envelope_id) assert docs_list is not None assert (docs_list.envelope_id == self.envelope_id) print("EnvelopeDocumentsResult: ", end="") pprint(docs_list) except ApiException as e: print("\nException when calling DocuSign API: %s" % e) assert e is None # make the test case fail in case of an API exception
def ds_return(): # # Step 5. Get the envelop id from the request. # print(request.args) envelope_id = request.args.get('envelope_id') # # Step 6. Create and define the API Client. # api_client = get_api_client_by_jwt_authorization_flow() # # Step 7. The envelope definition is created and ready to access list documents # envelope_api = EnvelopesApi(api_client) docs_list = envelope_api.list_documents(DS_CONFIG['account_id'], envelope_id) print("EnvelopeDocumentsResult:\n{0}", docs_list) # # Step 8. Retrieve the document based on list documents and the envelope id # document_id = docs_list.envelope_documents[0].document_id data = envelope_api.get_document(DS_CONFIG['account_id'], document_id, envelope_id) print(data) # # Step 9. Process the document in order to gat a base64 string to be showed into the html iframe # with open(os.path.join(data), "rb") as document: content_bytes = document.read() base64_file_content = base64.b64encode(content_bytes).decode('ascii') print(base64_file_content) return ''' <html lang="en"> <body> <iframe name="LendingFront" src="data:application/pdf;base64, {file}" height="700" width="700"></iframe> </body> </html> '''.format(event=request.args.get('event'), file=base64_file_content)
def worker(args): """ 1. Call the EnvelopeDocuments::list method """ # Exceptions will be caught by the calling function api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"]) envelope_api = EnvelopesApi(api_client) # 1. Call the EnvelopeDocuments::list method results = envelope_api.list_documents(account_id=args["account_id"], envelope_id=args["envelope_id"]) return results