Пример #1
0
    def get_view(envelope_id, envelope_args, student, session, authentication_method='None'):
        """Get the recipient view
        Parameters:
            envelope_id (str): envelope ID
            envelope_args (dict): parameters of the document
            student (dict): student information
            authentication_method (str): authentication method
        Returns:
            URL to the recipient view UI
        """
        access_token = session.get('access_token')
        account_id = session.get('account_id')

        # Create the RecipientViewRequest object
        recipient_view_request = RecipientViewRequest(
            authentication_method=authentication_method,
            client_user_id=envelope_args['signer_client_id'],
            recipient_id='1',
            return_url=envelope_args['ds_return_url'],
            user_name=f"{student['first_name']} {student['last_name']}",
            email=student['email']
        )
        # Obtain the recipient view URL for the signing ceremony
        # Exceptions will be caught by the calling function
        ds_client = DsClient.get_configured_instance(access_token)

        envelope_api = EnvelopesApi(ds_client)
        results = envelope_api.create_recipient_view(
            account_id,
            envelope_id,
            recipient_view_request=recipient_view_request
        )
        return results
def saveDoc(envelopeId, orderNumber):
    try:
        # api_client object created when checkToken() function was called in aws_worker
        api_client.set_default_header("Authorization", "Bearer " + api_client.token)
        accountID = get_account_id()
        envelope_api = EnvelopesApi(api_client)
        
        results_file = envelope_api.get_document(accountID , "combined" , envelopeId)

        # Create the output directory if needed
        output_directory = os.path.join(current_directory, r'output')
        if not os.path.exists(output_directory):
            os.makedirs(output_directory)
            if(not os.path.exists(output_directory)):
                print(date() + "Failed to create directory")

        filePath = os.path.join(current_directory, "output",  ds_config("OUTPUT_FILE_PREFIX") + orderNumber + ".pdf")
        # Cannot create a file when file with the same name already exists
        if(os.path.exists(filePath)):
            # Remove the existing file
            os.remove(filePath)
        # Save the results file in the output directory and change the name of the file
        os.rename(results_file,filePath)
        
    # Create a file
    except ApiException as e:
        print(date() + "API exception: {}. saveDoc error".format(e))

        # Catch exception while fetching and saving docs for envelope
    except Exception as e:
        print(date() + "Error while fetching and saving docs for envelope {}, order {}".format(envelopeId, orderNumber))
        print(date() + "saveDoc error {}".format(e))
Пример #3
0
    def worker(args):
        """
        This function does the work of creating the envelope in
        draft mode and returning a URL for the sender"s view
        """

        # Step 1. Create the envelope with "created" (draft) status
        args["envelope_args"]["status"] = "created"
        # Using worker from example 002
        results = Eg002Controller.worker(args)
        envelope_id = results["envelope_id"]

        # Step 2. Create the sender view
        view_request = ReturnUrlRequest(return_url=args["ds_return_url"])
        # 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)
        results = envelope_api.create_sender_view(
            account_id=args["account_id"],
            envelope_id=envelope_id,
            return_url_request=view_request
        )

        # Switch to Recipient and Documents view if requested by the user
        url = results.url
        if args["starting_view"] == "recipient":
            url = url.replace("send=1", "send=0")

        return {"envelope_id": envelope_id, "redirect_url": url}
Пример #4
0
 def get(self, request, envelope_id):
     envelopes_api = EnvelopesApi(get_api_client())
     context = {
         'envelope_recipients': envelopes_api.list_recipients(ACCOUNT_ID, envelope_id),
         'envelope': envelopes_api.get_envelope(ACCOUNT_ID, envelope_id)
     }
     return render(request, 'envelopes/envelope_detail.html', context=context)
Пример #5
0
 def send_envelope(self):
     self.check_token()
     envelope = self.create_envelope()
     envelope_api = EnvelopesApi(SendEnvelope.api_client)
     results = envelope_api.create_envelope(SendEnvelope.accountID,
                                            envelope_definition=envelope)
     return results
Пример #6
0
def make_envelope(file, sender, signer_name, signer_email, token):
    file.seek(0)
    content_bytes = file.read()
    base64_file_content = base64.b64encode(content_bytes).decode('ascii')

    document = Document(document_base64=base64_file_content,
                        name='DocuScan Terms',
                        file_extension='html',
                        document_id=1)

    signer = Signer(email=signer_email,
                    name=signer_name,
                    recipient_id='1',
                    routing_order='1')

    envelope_definition = EnvelopeDefinition(
        email_subject='Please sign these terms',
        documents=[document],
        recipients=Recipients(signers=[signer]),
        status='sent')

    api_client = ApiClient()
    api_client.host = 'https://demo.docusign.net/restapi'
    api_client.set_default_header('Authorization', 'Bearer ' + token)

    envelope_api = EnvelopesApi(api_client)
    results = envelope_api.create_envelope(
        sender['accounts'][0]['account_id'],
        envelope_definition=envelope_definition)
    return results
    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
Пример #8
0
 def get_view(cls, envelope_id, envelope_args, user, authentication_method='None'):
     """Get the recipient view
     Parameters:
         envelope_id (str): Envelope ID
         envelope_args (dict): Parameters of the document
         user (dict): User information
         authentication_method (str): Authentication method
     Returns:
         URL to the recipient view UI
     """
     # Create the recipient view request object
     recipient_view_request = RecipientViewRequest(
         authentication_method=authentication_method,
         client_user_id=envelope_args['signer_client_id'],
         recipient_id='1',
         return_url=envelope_args['ds_return_url'],
         user_name=f"{user['first_name']} {user['last_name']}",
         email=user['email']
     )
     # Obtain the recipient view URL for the signing ceremony
     # Exceptions will be caught by the calling function
     ds_client = DsClient.get_instance()
     envelope_api = EnvelopesApi(ds_client.api_client)
     results = envelope_api.create_recipient_view(
         ds_client.account_id,
         envelope_id,
         recipient_view_request=recipient_view_request
     )
     return results
Пример #9
0
    def determine_is_signed(self, envelope_id):
        """
        Queries docusign for a particular envelope to see if the user signed it or not
        :param envelope_id: (String) -> The envelope_id of the document that is being checked
        :return: (boolean) -> True: The document is signed
                              False: The document is not signed or error
        """

        # Initialize the envelope api
        envelopes_api = EnvelopesApi()

        try:
            # Queries docusign for the envelope and checks the status of the document
            #   if it is completed, then it is signed, otherwise it still hasn't been signed
            if envelopes_api.list_recipients(
                    self.account_id,
                    envelope_id).signers[0].status == 'completed':
                return True
            else:
                return False

        except ApiException as e:
            logger.error(
                "\nException in {0} when calling DocuSign API: {1}".format(
                    DocusignWrapper.determine_is_signed.__name__, e))
            return False
Пример #10
0
    def list(self):
        self.check_token()

        envelope_api = EnvelopesApi(ListEnvelopes.api_client)
        from_date = (datetime.now() + timedelta(days=-30)).strftime("%Y/%m/%d")
        return envelope_api.list_status_changes(ListEnvelopes.accountID,
                                                from_date=from_date)
Пример #11
0
    def get_document(self, document_id, envelope_id):
        self.check_token()

        envelope_api = EnvelopesApi(Envelope.api_client)
        document = envelope_api.get_document(Envelope.accountID, document_id, envelope_id, certificate=False)
        os.rename(document, '/home/phamvantoanb/Workspaces/sun/python/nicigas/' + Envelope.accountID + "-" + envelope_id
                  + "-" + document_id + '.pdf')
Пример #12
0
def send_document_for_signing(loan_id, signer_name, signer_email):
    APP_PATH = os.path.dirname(os.path.abspath(__file__))
    access_token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjY4MTg1ZmYxLTRlNTEtNGNlOS1hZjFjLTY4OTgxMjIwMzMxNyJ9.eyJUb2tlblR5cGUiOjUsIklzc3VlSW5zdGFudCI6MTU3NTY5MDA3NywiZXhwIjoxNTc1NzE4ODc3LCJVc2VySWQiOiI5YmM2MWNiZC1lMjA2LTQ4ZmYtOGE2OC1mZGM0ZGNlMWRhOWUiLCJzaXRlaWQiOjEsInNjcCI6WyJzaWduYXR1cmUiLCJjbGljay5tYW5hZ2UiLCJvcmdhbml6YXRpb25fcmVhZCIsImdyb3VwX3JlYWQiLCJwZXJtaXNzaW9uX3JlYWQiLCJ1c2VyX3JlYWQiLCJ1c2VyX3dyaXRlIiwiYWNjb3VudF9yZWFkIiwiZG9tYWluX3JlYWQiLCJpZGVudGl0eV9wcm92aWRlcl9yZWFkIiwiZHRyLnJvb21zLnJlYWQiLCJkdHIucm9vbXMud3JpdGUiLCJkdHIuZG9jdW1lbnRzLnJlYWQiLCJkdHIuZG9jdW1lbnRzLndyaXRlIiwiZHRyLnByb2ZpbGUucmVhZCIsImR0ci5wcm9maWxlLndyaXRlIiwiZHRyLmNvbXBhbnkucmVhZCIsImR0ci5jb21wYW55LndyaXRlIl0sImF1ZCI6ImYwZjI3ZjBlLTg1N2QtNGE3MS1hNGRhLTMyY2VjYWUzYTk3OCIsImF6cCI6ImYwZjI3ZjBlLTg1N2QtNGE3MS1hNGRhLTMyY2VjYWUzYTk3OCIsImlzcyI6Imh0dHBzOi8vYWNjb3VudC1kLmRvY3VzaWduLmNvbS8iLCJzdWIiOiI5YmM2MWNiZC1lMjA2LTQ4ZmYtOGE2OC1mZGM0ZGNlMWRhOWUiLCJhdXRoX3RpbWUiOjE1NzU2OTAwMDYsInB3aWQiOiIyZjA5MDc4Yy0yMzdiLTQ1ODMtYWI0MS1jOGM4NTg2MDllZmYifQ.wrcjGaFQTDAZ2NpYcT4i40hboJyc4s1NGNodhN0VEEWh-XuM5cmHJJQECEueGf3UA9taUjupFbI86JxMkpx9GqebBBNCT6UyHBq0GPbhy85nR2ktgYi6ZbcBJvxiLdWwd3IkrC0a-4GVAgqdp1pXVe79f4nPMmRzCvKMIsdlUUVcQCacPU7hgHNuZhwwPikQKO1WDEBCD8epv4qbil4_Er73It3-DNMNYa4yqaaQ64rb_xTOAwYZ4Ua3w6gW2Vot6zBIt-Gm1Go8GgDrzrAxES5W0e6DtQMUq48q9Kiba5YhdnZSXLC1yJIb2ma_p0j1NYW-Pu0WMjjK8Y_-4B6RpQ'
    account_id = '5959504'
    file_name_path = 'documents/approval_letter.pdf'
    base_path = 'https://demo.docusign.net/restapi'
    # Create the component objects for the envelope definition...
    with open(os.path.join(APP_PATH, file_name_path), "rb") as file:
        content_bytes = file.read()
    base64_file_content = base64.b64encode(content_bytes).decode('ascii')

    document = Document(  # create the DocuSign document object
        document_base64=base64_file_content,
        name='Approval Letter',  # can be different from actual file name
        file_extension='pdf',  # many different document types are accepted
        document_id=1  # a label used to reference the doc
    )

    # Create the signer recipient model
    signer = Signer(  # The signer
        email=signer_email,
        name=signer_name,
        recipient_id="1",
        routing_order="1")

    # Create a sign_here tab (field on the document)
    sign_here = SignHere(  # DocuSign SignHere field/tab
        document_id='1',
        page_number='1',
        recipient_id='1',
        tab_label='SignHereTab',
        x_position='195',
        y_position='147')

    # Add the tabs model (including the sign_here tab) to the signer
    signer.tabs = Tabs(sign_here_tabs=[
        sign_here
    ])  # The Tabs object wants arrays of the different field/tab types

    # Next, create the top level envelope definition and populate it.
    envelope_definition = EnvelopeDefinition(
        email_subject="Please sign this Approval Letter for your loan.",
        documents=[
            document
        ],  # The order in the docs array determines the order in the envelope
        recipients=Recipients(
            signers=[signer]
        ),  # The Recipients object wants arrays for each recipient type
        status="sent"  # requests that the envelope be created and sent.
    )

    # send envelope request
    api_client = ApiClient()
    api_client.host = base_path
    api_client.set_default_header("Authorization", "Bearer " + access_token)

    envelope_api = EnvelopesApi(api_client)
    results = envelope_api.create_envelope(
        account_id, envelope_definition=envelope_definition)
    return results
Пример #13
0
def embedded_signing_ceremony(signer_email, signer_name, signer_id, signer_file_path, signer_file_name, form_filled_type):

    with open(os.path.join(APP_PATH, signer_file_path), "rb") as file:
        content_bytes = file.read()
    base64_file_content = base64.b64encode(content_bytes).decode('ascii')

    document = Document(document_base64 = base64_file_content, name = signer_file_name, file_extension = 'pdf', document_id = 1)

    signer = Signer(email = signer_email, name = signer_name, recipient_id = "1", routing_order = "1", client_user_id = signer_id)

    sign_here = SignHere(document_id = '1', page_number = '1', recipient_id = '1', tab_label = 'SignHereTab', x_position = '300', y_position = '650')
    
    signer.tabs = Tabs(sign_here_tabs = [sign_here])

    envelope_definition = EnvelopeDefinition(
        email_subject = "Please sign this document sent from the Python SDK",
        documents = [document], 
        recipients = Recipients(signers = [signer]),
        status = "sent"
    )

    api_client = ApiClient()
    api_client.host = base_path
    api_client.set_default_header("Authorization", "Bearer " + access_token)

    envelope_api = EnvelopesApi(api_client)
    
    results = envelope_api.create_envelope(account_id, envelope_definition=envelope_definition)

    envelope_id = results.envelope_id
    
    recipient_view_request = RecipientViewRequest(authentication_method = "email", client_user_id = signer_id, recipient_id = '1', return_url = base_url + form_filled_type, user_name = signer_name, email = signer_email)

    results = envelope_api.create_recipient_view(account_id, envelope_id, recipient_view_request = recipient_view_request)
    return results.url
Пример #14
0
def send_document_for_signing():
    """
    Sends the document <file_name> to be signed by <signer_name> via <signer_email>
    """

    # Create the component objects for the envelope definition...
    with open(os.path.join(APP_PATH, file_name_path), "rb") as file:
        content_bytes = file.read()
    base64_file_content = base64.b64encode(content_bytes).decode('ascii')

    document = Document(  # create the DocuSign document object 
        document_base64=base64_file_content,
        name='Example document',  # can be different from actual file name
        file_extension='pdf',  # many different document types are accepted
        document_id=1  # a label used to reference the doc
    )

    # Create the signer recipient model
    signer = Signer(  # The signer
        email=signer_email,
        name=signer_name,
        recipient_id="1",
        routing_order="1")

    # Create a sign_here tab (field on the document)
    sign_here = SignHere(  # DocuSign SignHere field/tab
        document_id='1',
        page_number='1',
        recipient_id='1',
        tab_label='SignHereTab',
        x_position='195',
        y_position='147')

    # Add the tabs model (including the sign_here tab) to the signer
    signer.tabs = Tabs(sign_here_tabs=[
        sign_here
    ])  # The Tabs object wants arrays of the different field/tab types

    # Next, create the top level envelope definition and populate it.
    envelope_definition = EnvelopeDefinition(
        email_subject="Please sign this document sent from the Python SDK",
        documents=[
            document
        ],  # The order in the docs array determines the order in the envelope
        recipients=Recipients(
            signers=[signer]
        ),  # The Recipients object wants arrays for each recipient type
        status="sent"  # requests that the envelope be created and sent.
    )

    # Ready to go: send the envelope request
    api_client = ApiClient()
    api_client.host = base_path
    api_client.set_default_header("Authorization", "Bearer " + access_token)

    envelope_api = EnvelopesApi(api_client)
    results = envelope_api.create_envelope(
        account_id, envelope_definition=envelope_definition)
    return results
Пример #15
0
 def get(self, request, *args, **kwargs):
     envelopes_api = EnvelopesApi(get_api_client())
     context = {}
     from_date = (datetime.utcnow() - timedelta(days=60)).isoformat()
     # retrieve all envelopes of last 2 months
     context['envelope_list'] = envelopes_api.list_status_changes(ACCOUNT_ID, status='sent, delivered',
                                                                  from_date=from_date).envelopes
     return render(request, 'envelopes/envelope_list.html', context=context)
    def testRequestASignature(self):
        with open(SignTest1File, 'rb') as sign_file:
            file_contents = sign_file.read()

        # create an envelope to be signed
        envelope_definition = docusign.EnvelopeDefinition()
        envelope_definition.email_subject = 'Please Sign my Python SDK Envelope'
        envelope_definition.email_blurb = 'Hello, Please sign my Python SDK Envelope.'

        # add a document to the envelope
        doc = docusign.Document()
        base64_doc = base64.b64encode(file_contents).decode("utf-8")
        doc.document_base64 = base64_doc
        doc.name = 'TestFile.pdf'
        doc.document_id = '1'
        envelope_definition.documents = [doc]

        # Add a recipient to sign the document
        signer = docusign.Signer()
        signer.email = Username
        signer.name = 'Pat Developer'
        signer.recipient_id = '1'

        # Create a SignHere tab somewhere on the document for the signer to sign
        sign_here = docusign.SignHere()
        sign_here.document_id = '1'
        sign_here.page_number = '1'
        sign_here.recipient_id = '1'
        sign_here.x_position = '100'
        sign_here.y_position = '100'
        sign_here.scale_value = '0.5'

        tabs = docusign.Tabs()
        tabs.sign_here_tabs = [sign_here]
        signer.tabs = tabs

        recipients = docusign.Recipients()
        recipients.signers = [signer]
        envelope_definition.recipients = recipients

        envelope_definition.status = 'sent'

        envelopes_api = EnvelopesApi()

        try:
            envelope_summary = envelopes_api.create_envelope(
                self.user_info.accounts[0].account_id,
                envelope_definition=envelope_definition)
            assert envelope_summary is not None
            assert envelope_summary.envelope_id is not None
            assert envelope_summary.status == 'sent'

            print("EnvelopeSummary: ", end="")
            pprint(envelope_summary)

        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
Пример #17
0
    def send_template(self, name, email):
        webbrowser.open_new_tab(self._oauth_login_url)
        print(self._oauth_login_url)

        self._api_client.configure_jwt_authorization_flow(
            self._private_key_filename, self._oauth_base_url, self._integrator_key, self._user_id, 3600)

        docusign.configuration.api_client = self._api_client

        template_role_name = 'Needs to sign'

        # create an envelope to be signed
        envelope_definition = docusign.EnvelopeDefinition()
        envelope_definition.email_subject = 'Please Sign my Python SDK Envelope'
        envelope_definition.email_blurb = 'Hello, Please sign my Python SDK Envelope.'

        # assign template information including ID and role(s)
        envelope_definition.template_id = self._template_id

        # create a template role with a valid template_id and role_name and assign signer info
        t_role = docusign.TemplateRole()
        t_role.role_name = template_role_name
        t_role.name = name
        t_role.email = email

        # create a list of template roles and add our newly created role
        # assign template role(s) to the envelope
        envelope_definition.template_roles = [t_role]

        # send the envelope by setting |status| to "sent". To save as a draft set to "created"
        envelope_definition.status = 'sent'

        auth_api = AuthenticationApi()
        envelopes_api = EnvelopesApi()

        try:
            login_info = auth_api.login(api_password='******', include_account_id_guid='true')
            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

            self._base_url, _ = login_accounts[0].base_url.split('/v2')
            self._api_client.host = self._base_url
            docusign.configuration.api_client = api_client

            envelope_summary = envelopes_api.create_envelope(login_accounts[0].account_id, envelope_definition=envelope_definition)
            assert envelope_summary is not None
            assert envelope_summary.envelope_id is not None
            assert envelope_summary.status == 'sent'

            print("EnvelopeSummary: ", end="")
            pprint(envelope_summary)

        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
Пример #18
0
 def get(self, request, *args, **kwargs):
     envelope_definition = make_envelope()
     envelopes_api = EnvelopesApi(get_api_client())
     results = envelopes_api.create_envelope(ACCOUNT_ID, envelope_definition=envelope_definition)
     sign_envelope = SigEnvelope.objects.create(envelope_id=results.envelope_id)
     sign_request = SignRequest.objects.create(envelope=sign_envelope, error_details=results.error_details,
                                               status_date_time=results.status_date_time)
     Recipient.objects.create(recipient_id='1', sign_request=sign_request, email='*****@*****.**')
     return JsonResponse({'envelope_id': results.envelope_id})
Пример #19
0
 def get(self, request, envelope_id):
     envelopes_api = EnvelopesApi(get_api_client())
     envelope = envelopes_api.get_envelope(ACCOUNT_ID, envelope_id)
     envelope.status = 'voided'
     envelope.voided_reason = 'changed my mind'
     envelope.purge_state = None
     envelopes_api.update(ACCOUNT_ID, envelope_id, envelope=envelope)
     SigEnvelope.objects.get(envelope_id=envelope_id).delete()
     return redirect('esign:envelope_list')
 def download(cls, args):
     """Download the specified document from the envelope"""
     ds_client = DsClient.get_instance()
     envelope_api = EnvelopesApi(ds_client.api_client)
     file_path = envelope_api.get_document(ds_client.account_id,
                                           args['document_id'],
                                           args['envelope_id'])
     (dirname, filename) = os.path.split(file_path)
     return send_from_directory(directory=dirname,
                                filename=filename,
                                as_attachment=True)
Пример #21
0
 def post(self, request, envelope_id):
     signer = Signer(email=request.POST['email'], name='Aaqib 2', recipient_id='2', routing_order='1')
     sign_here = SignHere(anchor_string='**Employee Signature**', anchor_units='pixels',
                          anchor_y_offset='10', anchor_x_offset='100')
     signer.tabs = Tabs(sign_here_tabs=[sign_here])
     recipients = Recipients(signers=[signer])
     envelopes_api = EnvelopesApi(get_api_client())
     envelope = envelopes_api.create_recipient(ACCOUNT_ID, envelope_id, recipients=recipients,
                                               resend_envelope='true')
     sign_request = SignRequest.objects.get(envelope=SigEnvelope.objects.get(envelope_id=envelope_id))
     Recipient.objects.create(email=request.POST['email'], recipient_id='2', sign_request=sign_request)
     return redirect(reverse('esign:envelope_detail', kwargs={'envelope_id': envelope_id}))
Пример #22
0
    def testRequestSignatureFromTemplate(self):
        template_role_name = 'Needs to sign'

        # create an envelope to be signed
        envelope_definition = docusign.EnvelopeDefinition()
        envelope_definition.email_subject = 'Please Sign my Python SDK Envelope'
        envelope_definition.email_blurb = 'Hello, Please sign my Python SDK Envelope.'

        # assign template information including ID and role(s)
        envelope_definition.template_id = template_id

        # create a template role with a valid templateId and roleName and assign signer info
        t_role = docusign.TemplateRole()
        t_role.role_name = template_role_name
        t_role.name = 'Pat Developer'
        t_role.email = username

        # create a list of template roles and add our newly created role
        # assign template role(s) to the envelope
        envelope_definition.template_roles = [t_role]

        # send the envelope by setting |status| to "sent". To save as a draft set to "created"
        envelope_definition.status = 'sent'

        auth_api = AuthenticationApi()
        envelopes_api = EnvelopesApi()

        try:
            login_info = auth_api.login(api_password='******',
                                        include_account_id_guid='true')
            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

            envelope_summary = envelopes_api.create_envelope(
                login_accounts[0].account_id,
                envelope_definition=envelope_definition)
            assert envelope_summary is not None
            assert envelope_summary.envelope_id is not None
            assert envelope_summary.status == 'sent'

            print("EnvelopeSummary: ", end="")
            pprint(envelope_summary)

        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
Пример #23
0
    def worker(args):
        """
        1. Call the envelope get method
        """

        # Exceptions will be caught by the calling function
        api_client = create_api_client(base_path=args["base_path"],
                                       access_token=args["access_token"])
        envelopes_api = EnvelopesApi(api_client)
        results = envelopes_api.get_form_data(account_id=args["account_id"],
                                              envelope_id=args["envelope_id"])

        return results
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)
Пример #25
0
    def setUp(self):
        self.api_client = docusign.ApiClient(base_path=BaseUrl,
                                             oauth_host_name=OauthHostName)
        self.api_client.rest_client.pool_manager.clear()

        docusign.configuration.api_client = self.api_client
        try:
            email_subject = 'Please Sign my Python SDK Envelope'
            email_blurb = 'Hello, Please sign my Python SDK Envelope.'
            template_id = TemplateId

            role_name = 'Needs to sign'
            name = 'Pat Developer'
            email = Username
            t_role = docusign.TemplateRole(role_name=role_name,
                                           name=name,
                                           email=email)
            # send the envelope by setting |status| to "sent". To save as a draft set to "created"
            status = 'sent'
            # create an envelope definition
            envelope_definition = docusign.EnvelopeDefinition(
                email_subject=email_subject,
                email_blurb=email_blurb,
                template_id=template_id,
                template_roles=[t_role],
                status=status)

            envelopes_api = EnvelopesApi()

            self.api_client.host = BaseUrl
            token = (self.api_client.request_jwt_user_token(
                client_id=IntegratorKey,
                user_id=UserId,
                oauth_host_name=OauthHostName,
                private_key_bytes=PrivateKeyBytes,
                expires_in=3600))
            self.user_info = self.api_client.get_user_info(token.access_token)
            self.api_client.rest_client.pool_manager.clear()
            docusign.configuration.api_client = self.api_client
            envelope_summary = envelopes_api.create_envelope(
                self.user_info.accounts[0].account_id,
                envelope_definition=envelope_definition)
            self.api_client.rest_client.pool_manager.clear()
            self.envelope_id = envelope_summary.envelope_id

        except ApiException as e:
            print("\nException when calling DocuSign API: %s" % e)
        except Exception as e:
            print("\nException when calling DocuSign API: %s" % e)
        self.api_client.rest_client.pool_manager.clear()
 def send(cls, envelope):
     """Send an envelope
     Parameters:
         envelope (object): EnvelopeDefinition object
     Returns:
         envelope_id (str): envelope ID
     """
     # Call Envelope API create method
     # Exceptions will be caught by the calling function
     ds_client = DsClient.get_instance()
     envelope_api = EnvelopesApi(ds_client.api_client)
     results = envelope_api.create_envelope(ds_client.account_id,
                                            envelope_definition=envelope)
     return results.envelope_id
    def testRequestSignatureFromTemplate(self):
        template_role_name = 'Needs to sign'

        # Set properties and create an envelope later on
        email_subject = 'Please Sign my Python SDK Envelope'
        email_blurb = 'Hello, Please sign my Python SDK Envelope.'

        # assign template information including ID and role(s)
        template_id = TemplateId

        # create a template role with a valid templateId and roleName and assign signer info
        role_name = template_role_name
        name = 'Pat Developer'
        email = Username
        t_role = docusign.TemplateRole(role_name=role_name,
                                       name=name,
                                       email=email)

        # create a list of template roles and add our newly created role
        # assign template role(s) to the envelope
        template_roles = [t_role]

        # send the envelope by setting |status| to "sent". To save as a draft set to "created"
        status = 'sent'

        # create the envelope definition with the properties set
        envelope_definition = docusign.EnvelopeDefinition(
            email_subject=email_subject,
            email_blurb=email_blurb,
            template_id=template_id,
            template_roles=template_roles,
            status=status)

        envelopes_api = EnvelopesApi()

        try:
            envelope_summary = envelopes_api.create_envelope(
                self.user_info.accounts[0].account_id,
                envelope_definition=envelope_definition)
            assert envelope_summary is not None
            assert envelope_summary.envelope_id is not None
            assert envelope_summary.status == 'sent'

            print("EnvelopeSummary: ", end="")
            pprint(envelope_summary)

        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
Пример #28
0
    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
Пример #29
0
    def download(args, session):
        """Download the specified document from the envelope"""
        access_token = session.get('access_token')
        account_id = session.get('account_id')

        ds_client = DsClient.get_configured_instance(access_token)
        envelope_api = EnvelopesApi(ds_client)
        file_path = envelope_api.get_document(
            account_id, args['document_id'], args['envelope_id']
        )
        (dirname, filename) = os.path.split(file_path)
        return send_from_directory(
            directory=dirname,
            filename=filename,
            as_attachment=True
        )
Пример #30
0
    def worker(cls, args):
        """
        1. Create the envelope request object
        2. Send the envelope
        """
        envelope_args = args["envelope_args"]
        # 1. Create the envelope request object
        envelope_definition = cls.make_envelope(envelope_args)

        # 2. call Envelopes::create API 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)
        results = envelope_api.create_envelope(account_id=args["account_id"], envelope_definition=envelope_definition)
        envelope_id = results.envelope_id
        return {"envelope_id": envelope_id}