예제 #1
0
    def make_envelope(cls, args):
        """
        Creates envelope
        args -- parameters for the envelope:
        signer_email, signer_name, signer_client_id
        returns an envelope definition
        """

        # create the envelope definition
        envelope_definition = EnvelopeDefinition(
            status="sent",  # requests that the envelope be created and sent.
            template_id=args["template_id"]
        )
        # Create template role elements to connect the signer and cc recipients
        # to the template
        signer = TemplateRole(
            email=args["signer_email"],
            name=args["signer_name"],
            role_name="signer"
        )
        # Create a cc template role.
        cc = TemplateRole(
            email=args["cc_email"],
            name=args["cc_name"],
            role_name="cc"
        )

        # Add the TemplateRole objects to the envelope object
        envelope_definition.template_roles = [signer, cc]
        return envelope_definition
예제 #2
0
    def make_envelope(cls, args):
        """
        Creates the envelope definition object
        """
        # Create the envelope definition
        envelope_definition = EnvelopeDefinition(
            status="sent",
            template_id=args["template_id"],
            brand_id=args["brand_id"]
        )

        signer = TemplateRole(
            email=args["signer_email"],
            name=args["signer_name"],
            role_name="signer"
        )

        # In case, we have cc we add him to envelope definition
        if args["cc_email"] and args["cc_name"]:
            cc = TemplateRole(
                email=args["cc_email"],
                name=args["cc_name"],
                role_name="cc"
            )

            envelope_definition.template_roles = [signer, cc]

        else:
            envelope_definition.template_roles = [signer]

        return envelope_definition
예제 #3
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
예제 #4
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
예제 #5
0
    def make_draft_envelope(cls):
        """
            Creates the envelope
        """

        # Open the example file
        with open(path.join(demo_docs_path, DS_CONFIG["doc_pdf"]),
                  "rb") as file:
            content_bytes = file.read()
        base64_file_content = base64.b64encode(content_bytes).decode("ascii")

        document = Document(document_base64=base64_file_content,
                            name="lorem",
                            file_extension="pdf",
                            document_id=2)

        envelope_definition = EnvelopeDefinition(
            email_subject="Please Sign",
            documents=[document],
            status="created",
            envelope_id_stamping="true",
            recipients={},
        )

        return envelope_definition
예제 #6
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
예제 #7
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
예제 #8
0
    def make_envelope(cls, args):
        """
        Creates envelope
        args -- parameters for the envelope:
        signer_email, signer_name, signer_client_id
        returns an envelope definition
        """

        # document 1 (pdf) has tag /sn1/
        #
        # The envelope has one recipient.
        # recipient 1 - signer
        with open(path.join(demo_docs_path, DS_CONFIG["doc_pdf"]), "rb") as file:
            content_bytes = file.read()
        base64_file_content = base64.b64encode(content_bytes).decode("ascii")

        # Create the document model
        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=args["signer_email"],
            name=args["signer_name"],
            recipient_id="1",
            routing_order="1",
            # Setting the client_user_id marks the signer as embedded
            client_user_id=args["signer_client_id"]
        )

        # Create a sign_here tab (field on the document)
        sign_here = SignHere(
            # DocuSign SignHere field/tab
            anchor_string="/sn1/",
            anchor_units="pixels",
            anchor_y_offset="10",
            anchor_x_offset="20"
        )

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

        # 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 Recipients object wants arrays for each recipient type
            recipients=Recipients(signers=[signer]),
            status="sent"  # requests that the envelope be created and sent.
        )

        return envelope_definition
예제 #9
0
def make_envelope():
    with open(f'{BASE_DIR}/document.pdf', 'rb') as pdf_file:
        content_bytes = pdf_file.read()
    base64_file_content = base64.b64encode(content_bytes).decode('ascii')
    document = Document(document_base64=base64_file_content, name='Employee Contract',
                        file_extension='pdf', document_id='1')
    signer = Signer(email='*****@*****.**', name='M Aaqib', recipient_id='1', routing_order='1')
    sign_here = SignHere(anchor_string='**Employee Signature**', anchor_units='pixels',
                         anchor_y_offset='10', anchor_x_offset='20')
    signer.tabs = Tabs(sign_here_tabs=[sign_here])
    recipients = Recipients(signers=[signer])
    envelope_definition = EnvelopeDefinition(email_subject='Please sign this document set', documents=[document],
                                             recipients=recipients, status='sent')
    return envelope_definition
예제 #10
0
    def get(self, request, *args, **kwargs):
        api_client = get_api_client()
        bulk_envelopes_api = BulkEnvelopesApi(api_client)
        recipient_1 = BulkSendingCopyRecipient(role_name='signer', name='Aaqib 1', email='*****@*****.**')
        recipient_2 = BulkSendingCopyRecipient(role_name='signer', name='Aaqib 2', email='*****@*****.**')
        bulk_copies = [
            BulkSendingCopy(recipients=[recipient_1], custom_fields=[]),
            BulkSendingCopy(recipients=[recipient_2], custom_fields=[]),
        ]
        bulk_sending_list = BulkSendingList(name='employee_contract', bulk_copies=bulk_copies)
        bulk_list = bulk_envelopes_api.create_bulk_send_list(ACCOUNT_ID, bulk_sending_list=bulk_sending_list)
        bulk_list_id = bulk_list.list_id

        envelopes_api = EnvelopesApi(api_client)
        with open(f'{BASE_DIR}/document.pdf', 'rb') as pdf_file:
            content_bytes = pdf_file.read()
        base64_file_content = base64.b64encode(content_bytes).decode('ascii')
        document = Document(document_base64=base64_file_content, name='Employee Contract',
                            file_extension='pdf', document_id='1')
        envelope_definition = EnvelopeDefinition(email_subject='Please sign this document set', documents=[document],
                                                 recipients={}, status='created', envelope_id_stamping='true')
        envelope = envelopes_api.create_envelope(account_id=ACCOUNT_ID, envelope_definition=envelope_definition)
        envelope_id = envelope.envelope_id

        text_custom_fields = TextCustomField(name='mailingListId', required='false', show='false', value=bulk_list_id)
        custom_fields = CustomFields(list_custom_fields=[], text_custom_fields=[text_custom_fields])
        envelopes_api.create_custom_fields(account_id=ACCOUNT_ID, envelope_id=envelope_id, custom_fields=custom_fields)

        signer = Signer(name='Multi Bulk Recipient::signer', email='*****@*****.**',
                        role_name='signer', note='', routing_order='1', status='created', delivery_method='email',
                        recipient_id='13', recipient_type='signer')
        envelopes_api.create_recipient(ACCOUNT_ID, envelope_id, recipients=Recipients(signers=[signer]))
        bulk_send_request = BulkSendRequest(envelope_or_template_id=envelope_id)
        batch = bulk_envelopes_api.create_bulk_send_request(ACCOUNT_ID, bulk_list_id,
                                                            bulk_send_request=bulk_send_request)

        time.sleep(10)
        from_date = (datetime.utcnow() - timedelta(seconds=60)).isoformat()
        envelopes = envelopes_api.list_status_changes(ACCOUNT_ID, status='sent', from_date=from_date).envelopes
        for envelope in envelopes:
            env, created = SigEnvelope.objects.get_or_create(envelope_id=envelope.envelope_id)
            if created:
                sign_request = SignRequest.objects.create(envelope=env, status_date_time=envelope.status_date_time)
                recipients = envelopes_api.list_recipients(ACCOUNT_ID, envelope.envelope_id)
                Recipient.objects.create(sign_request=sign_request, email=recipients.signers[0].email,
                                         recipient_id=recipients.signers[0].recipient_id)
        return redirect('esign:envelope_list')
예제 #11
0
    def worker(cls, args):
        """
        1. Call the envelope update method
        """

        # Create the envelope definition
        env = EnvelopeDefinition(workflow=Workflow(
            workflow_status="in_progress"))

        # Exceptions will be caught by the calling function
        api_client = create_api_client(base_path=args["base_path"],
                                       access_token=args["access_token"])

        # 2. Call Envelopes::update API method
        # Exceptions will be caught by the calling function
        envelopes_api = EnvelopesApi(api_client)
        results = envelopes_api.update(account_id=args["account_id"],
                                       envelope_id=args["envelope_id"],
                                       envelope=env,
                                       resend_envelope=True)

        return {"envelope_id": results.envelope_id}
예제 #12
0
    def make_envelope(cls, args):
        """
        Creates envelope
        """

        # Open the example file
        with open(path.join(demo_docs_path, DS_CONFIG["doc_pdf"]),
                  "rb") as file:
            content_bytes = file.read()
        base64_file_content = base64.b64encode(content_bytes).decode("ascii")

        document = Document(document_base64=base64_file_content,
                            name="lorem",
                            file_extension="pdf",
                            document_id=1)

        signer = Signer(email=args["signer_email"],
                        name=args["signer_name"],
                        recipient_id="1",
                        routing_order="1")

        sign_here = SignHere(anchor_string="/sn1/",
                             anchor_units="pixels",
                             anchor_y_offset="572",
                             anchor_x_offset="75")

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

        envelope_definition = EnvelopeDefinition(
            email_subject="Please Sign",
            documents=[document],
            recipients=Recipients(signers=[signer]),
            status="sent",
            brand_id=args["brand_id"],
        )

        return envelope_definition
예제 #13
0
    def create_envelope(self):
        envelope_definition = EnvelopeDefinition()
        envelope_definition.email_subject = "Please sign this document sent from the Python SDK"

        doc1 = create_document("1", "Order acknowledgement", "html",
                               ENVELOPE_1_DOCUMENT_1)
        doc2 = create_document("2", "Battle Plan", "docx",
                               DSHelper.read_content(DOC_2_DOCX))
        doc3 = create_document("3", "Lorem Ipsum", "pdf",
                               DSHelper.read_content(DOC_3_PDF))

        # The order in the docs array determines the order in the envelope
        envelope_definition.documents = [doc1, doc2, doc3]
        # create a signer recipient to sign the document, identified by name and email
        # We're setting the parameters via the object creation
        signer1 = createSigner()
        # routingOrder (lower means earlier) determines the order of deliveries
        # to the recipients. Parallel routing order is supported by using the
        # same integer as the order for two or more recipients.

        # create a cc recipient to receive a copy of the documents, identified by name and email
        # We're setting the parameters via setters
        cc1 = createCarbonCopy()
        # Create signHere fields (also known as tabs) on the documents,
        # We're using anchor (autoPlace) positioning
        #
        # The DocuSign platform searches throughout your envelope's
        # documents for matching anchor strings. So the
        # sign_here_2 tab will be used in both document 2 and 3 since they
        # use the same anchor string for their "signer 1" tabs.
        sign_here1 = createSignHere("**signature_1**", "pixels", "20", "10")
        sign_here2 = createSignHere("/sn1/", "pixels", "20", "10")
        # Tabs are set per recipient / signer
        setSignerTabs(signer1, [sign_here1, sign_here2])
        # Add the recipients to the envelope object
        recipients = createRecipients(signer1, cc1)
        envelope_definition.recipients = recipients
        # Request that the envelope be sent by setting |status| to "sent".
        # To request that the envelope be created as a draft, set to "created"
        envelope_definition.status = "sent"

        return envelope_definition
예제 #14
0
def embedded_signing_ceremony():
    """
    The document <file_name> will be signed by <signer_name> via an
    embedded signing ceremony.
    """

    #
    # Step 1. The envelope definition is created.
    #         One signHere tab is added.
    #         The document path supplied is relative to the working directory
    #

    envDef = EnvelopeDefinition()
    envDef.email_subject = 'PLEASE GOD HELP ME, I NEED THIS WORKING!!'
    envDef.template_id = 'd5e617be-da0a-4431-9014-4575282f61d4'

    tRole = TemplateRole()
    tRole.role_name = 'Manager'
    tRole.name = 'Manuel Galvez'
    tRole.email = '*****@*****.**'
    tRole.client_user_id = clientUserId

    text_example = Text()
    text_example.tab_label = 'example'
    text_example.value = 'SIIII GRACIAS DIOS!! -- EXAMPLE'

    text_name = Text()
    text_name.tab_label = 'name'
    text_name.value = 'SIIII GRACIAS DIOS!! -- NAME'

    # text.document_id = '1'
    # text.page_number = '1'
    # text.recipient_id = '1'
    # text.x_position = '100'
    # text.y_position = '100'
    # text.scale_value = '0.5'

    tabs = Tabs()
    tabs.text_tabs = [text_example, text_name]

    tRole.tabs = tabs  # Tabs(text_tabs=[Text(name='example', value='SIiiiiiii Gracias DIOS')])

    envDef.template_roles = [tRole]

    name = TextCustomField(field_id='name', name='name', value='Manuel')
    last_name = TextCustomField(field_id='lastname',
                                name='lastname',
                                value='Galvez')
    testing = TextCustomField(field_id='testing', name='testing', value='Elks')
    manu = TextCustomField(field_id='manu', name='manu', value='manu')
    example = TextCustomField(field_id='example',
                              name='example',
                              value='Siiiiiiii')

    custom_fields = CustomFields(
        text_custom_fields=[example, name, last_name, testing, manu])

    envDef.custom_fields = custom_fields
    '''recipients = Recipients()

    # Create the signer recipient model
    signer = Signer(  # The signer
        email='*****@*****.**', name='Andres Vasquez', recipient_id="1", routing_order="1",
        client_user_id=clientUserId,  # Setting the client_user_id marks the signer as embedded
    )

    text = Text()
    text.document_id = '1'
    text.page_number = '1'
    text.recipient_id = '1'
    text.x_position = '100'
    text.y_position = '100'
    text.scale_value = '0.5'

    tabs = Tabs()
    tabs.text_tabs = [text]

    signer.tabs = tabs

    recipients.signers = [signer]
    envDef.recipients = recipients'''

    envDef.status = 'sent'

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

    envelope_api = EnvelopesApi(api_client)
    envelopeSummary = envelope_api.create_envelope(account_id,
                                                   envelope_definition=envDef)
    envelope_id = envelopeSummary.envelope_id

    print("Envelope {} has been sent to {} : {}".format(
        envelope_id, tRole.email, envelopeSummary))
    '''recipient_view_request = RecipientViewRequest(
        authentication_method='None', client_user_id=clientUserId,
        recipient_id='1', return_url=base_url + '/dsreturn',
        user_name='Andres Vasquez', email='*****@*****.**'
    )

    results = envelope_api.create_recipient_view(account_id, envelope_id, recipient_view_request=recipient_view_request)'''

    return ''  #results.url
예제 #15
0
def embedded_signing_ceremony(filename, vname, vemail):
    """
    The document <file_name> will be signed by <signer_name> via an
    embedded signing ceremony.
    """

    #
    # Step 1. The envelope definition is created.
    #         One signHere tab is added.
    #         The document path supplied is relative to the working directory
    #
    # Create the component objects for the envelope definition...

    with open(filename, "rb") as file:
        content_bytes = file.read()
    base64_file_content = base64.b64encode(content_bytes).decode('ascii')

    document = Document(
        document_base64=base64_file_content,
        name='IPFS 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(email=vemail,
                    name=vname,
                    recipient_id="1",
                    routing_order="1",
                    client_user_id=settings.DOCU_CLIENT_ID)

    sign_here = SignHere(document_id='1',
                         page_number='1',
                         recipient_id='1',
                         tab_label='IPFS Sign Request',
                         x_position='200',
                         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 IPFS",
        documents=[document],
        recipients=Recipients(signers=[signer]),
        status="sent")

    envelope_api = envelope_obj()
    results = envelope_api.create_envelope(
        settings.DOCU_ACCOUNT_ID, envelope_definition=envelope_definition)

    envelope_id = results.envelope_id
    recipient_view_request = RecipientViewRequest(
        authentication_method=settings.DOCU_AUTH_METHOD,
        client_user_id=settings.DOCU_CLIENT_ID,
        recipient_id='1',
        return_url=settings.DOCU_REDIRECT_URL,
        user_name=vname,
        email=vemail)

    results = envelope_api.create_recipient_view(
        settings.DOCU_ACCOUNT_ID,
        envelope_id,
        recipient_view_request=recipient_view_request)
    return results.url, envelope_id
예제 #16
0
    def create(cls, tpl, student, envelope_args):
        """Creates envelope
        Parameters:
            tpl (str): template path for the document
            student (dict): student information
            envelope_args (dict): parameters of the document
        Returns:
            EnvelopeDefinition object that will be submitted to Docusign
        """
        with open(path.join(TPL_PATH, tpl), 'r') as file:
            content_bytes = file.read()

        # Get base64 logo representation to paste it into the html
        with open(path.join(IMG_PATH, 'logo.png'), 'rb') as file:
            img_base64_src = base64.b64encode(file.read()).decode('utf-8')

        content_bytes = Environment(loader=BaseLoader).from_string(content_bytes)\
            .render(
                first_name=student['first_name'],
                last_name=student['last_name'],
                email=student['email'],
                major=student['major'],
                minor=student['minor'],
                img_base64_src=img_base64_src
            )
        base64_file_content = base64.b64encode(bytes(content_bytes,
                                                     'utf-8')).decode('ascii')

        # Create the document model
        document = Document(  # create the DocuSign document object
            document_base64=base64_file_content,
            name='Change minor/major field',
            file_extension='html',
            document_id=1)

        # Create the signer recipient model
        signer = Signer(  # The signer
            email=student['email'],
            name=f"{student['first_name']} {student['last_name']}",
            recipient_id='1',
            routing_order='1',
            # Setting the client_user_id marks the signer as embedded
            client_user_id=envelope_args['signer_client_id'])

        # Create a sign_here tab (field on the document)
        sign_here = SignHere(anchor_string='/signature_1/',
                             anchor_units='pixels',
                             anchor_y_offset='10',
                             anchor_x_offset='20')

        # Create a initials tab
        initial_here = InitialHere(anchor_string='/initials_1/',
                                   anchor_units='pixels',
                                   anchor_y_offset='10',
                                   anchor_x_offset='20')

        # Create email field
        email = Email(document_id='1',
                      page_number='1',
                      anchor_string='/email/',
                      anchor_units='pixels',
                      required=True,
                      value=student['email'],
                      locked=False,
                      anchor_y_offset='-5')
        signer.tabs = Tabs(sign_here_tabs=[sign_here],
                           email_tabs=[email],
                           initial_here_tabs=[initial_here])

        # Next, create the top level envelope definition and populate it.
        envelope_definition = EnvelopeDefinition(
            email_subject='Change minor/major field',
            documents=[document],
            # The Recipients object wants arrays for each recipient type
            recipients=Recipients(signers=[signer]),
            status='sent'  # requests that the envelope be created and sent.
        )

        return envelope_definition
예제 #17
0
    def create_with_payment(cls, tpl, student, activity_info, envelope_args):
        """Create envelope with payment feature included
        Parameters:
            tpl (str): template path for the document
            student (dict}: student information
            activity_info (dict): activity information for enrollment
            envelope_args (dict): parameters for the envelope
        Returns:
            EnvelopeDefinition object that will be submitted to Docusign
        """
        l1_name = activity_info['name']
        l1_price = activity_info['price']
        l1_description = f'${l1_price}'
        currency_multiplier = 100

        # Read template and fill it up
        with open(path.join(TPL_PATH, tpl), 'r') as file:
            content_bytes = file.read()

        # Get base64 logo representation to paste it into the html
        with open(path.join(IMG_PATH, 'logo.png'), 'rb') as file:
            img_base64_src = base64.b64encode(file.read()).decode('utf-8')
        content_bytes = Environment(
            loader=BaseLoader).from_string(content_bytes).render(
                user_name=f"{student['first_name']} {student['last_name']}",
                user_email=student['email'],
                activity_name=l1_name,
                activity_price=l1_price,
                img_base64_src=img_base64_src)

        base64_file_content = base64.b64encode(bytes(content_bytes,
                                                     'utf-8')).decode('ascii')

        # Create the envelope definition
        envelope_definition = EnvelopeDefinition(
            email_subject='Register for extra-curricular activity')

        # Create the document
        doc1 = Document(
            document_base64=base64_file_content,
            name='Order form',  # can be different from actual file name
            file_extension='html',  # Source data format.
            document_id='1'  # a label used to reference the doc
        )
        envelope_definition.documents = [doc1]

        # Create a signer recipient to sign the document
        signer1 = Signer(
            email=student['email'],
            name=f"{student['first_name']} {student['last_name']}",
            recipient_id='1',
            routing_order='1',
            client_user_id=envelope_args['signer_client_id'])
        sign_here1 = SignHere(anchor_string='/sn1/',
                              anchor_y_offset='10',
                              anchor_units='pixels',
                              anchor_x_offset='20')

        # Create number tab for the price
        numberl1e = Number(
            font='helvetica',
            font_size='size11',
            anchor_string='/l1e/',
            anchor_y_offset='-8',
            anchor_units='pixels',
            anchor_x_offset='-7',
            tab_label='l1e',
            formula=l1_price,
            required='true',
            locked='true',
            disable_auto_size='false',
        )

        # Create formula tab for the total
        formula_total = FormulaTab(
            font='helvetica',
            bold='true',
            font_size='size12',
            anchor_string='/l2t/',
            anchor_y_offset='-6',
            anchor_units='pixels',
            anchor_x_offset='30',
            tab_label='l2t',
            formula='[l1e]',
            round_decimal_places='2',
            required='true',
            locked='true',
            disable_auto_size='false',
        )

        # Create payment line items
        payment_line_iteml1 = PaymentLineItem(name=l1_name,
                                              description=l1_description,
                                              amount_reference='l1e')

        payment_details = PaymentDetails(
            gateway_account_id=envelope_args['gateway_account_id'],
            currency_code='USD',
            gateway_name=envelope_args['gateway_name'],
            line_items=[payment_line_iteml1])

        # Create hidden formula tab for the payment itself
        formula_payment = FormulaTab(
            tab_label='payment',
            formula=f'{l1_price} * {currency_multiplier}',
            round_decimal_places='2',
            payment_details=payment_details,
            hidden='true',
            required='true',
            locked='true',
            document_id='1',
            page_number='1',
            x_position='0',
            y_position='0')

        # Create tabs for signer
        signer1_tabs = Tabs(sign_here_tabs=[sign_here1],
                            formula_tabs=[formula_payment, formula_total],
                            number_tabs=[numberl1e])
        signer1.tabs = signer1_tabs

        # Add the recipients to the envelope object
        recipients = Recipients(signers=[signer1])
        envelope_definition.recipients = recipients

        # Request that the envelope be sent by setting |status| to 'sent'.
        envelope_definition.status = 'sent'

        return envelope_definition
예제 #18
0
    def send_envelope(self):
        self.check_token()

        # document 1 (html) has sign here anchor tag **signature_1**
        # document 2 (docx) has sign here anchor tag /sn1/
        # document 3 (pdf)  has sign here anchor tag /sn1/
        #
        # The envelope has two recipients.
        # recipient 1 - signer
        # recipient 2 - cc
        # The envelope will be sent first to the signer.
        # After it is signed, a copy is sent to the cc person.

        args = {
            'signer_email': DSConfig.signer_email(),
            'signer_name': DSConfig.signer_name(),
            'cc_email': DSConfig.cc_email(),
            'cc_name': DSConfig.cc_name(),
        }

        # create the envelope definition
        env = EnvelopeDefinition(email_subject='Please sign this document set')
        doc1_b64 = base64.b64encode(bytes(self.create_document1(args),
                                          'utf-8')).decode('ascii')

        # read files 2 and 3 from a local directory
        # The reads could raise an exception if the file is not available!
        with open(path.join(demo_docs_path, DOC_2_DOCX), "rb") as file:
            doc2_docx_bytes = file.read()
        doc2_b64 = base64.b64encode(doc2_docx_bytes).decode('ascii')
        with open(path.join(demo_docs_path, DOC_3_PDF), "rb") as file:
            doc3_pdf_bytes = file.read()
        doc3_b64 = base64.b64encode(doc3_pdf_bytes).decode('ascii')

        # Create the document models
        document1 = Document(  # create the DocuSign document object
            document_base64=doc1_b64,
            name='Order acknowledgement',
            # can be different from actual file name
            file_extension='html',  # many different document types are accepted
            document_id='1'  # a label used to reference the doc
        )
        document2 = Document(  # create the DocuSign document object
            document_base64=doc2_b64,
            name='Battle Plan',  # can be different from actual file name
            file_extension='docx',  # many different document types are accepted
            document_id='2'  # a label used to reference the doc
        )
        document3 = Document(  # create the DocuSign document object
            document_base64=doc3_b64,
            name='Lorem Ipsum',  # can be different from actual file name
            file_extension='pdf',  # many different document types are accepted
            document_id='3'  # a label used to reference the doc
        )
        # The order in the docs array determines the order in the envelope
        env.documents = [document1, document2, document3]

        # Create the signer recipient model
        signer1 = Signer(email=args['signer_email'],
                         name=args['signer_name'],
                         recipient_id="1",
                         routing_order="1")
        # routingOrder (lower means earlier) determines the order of deliveries
        # to the recipients. Parallel routing order is supported by using the
        # same integer as the order for two or more recipients.

        # create a cc recipient to receive a copy of the documents
        cc1 = CarbonCopy(email=args['cc_email'],
                         name=args['cc_name'],
                         recipient_id="2",
                         routing_order="2")

        # Create signHere fields (also known as tabs) on the documents,
        # We're using anchor (autoPlace) positioning
        #
        # The DocuSign platform searches throughout your envelope's
        # documents for matching anchor strings. So the
        # signHere2 tab will be used in both document 2 and 3 since they
        #  use the same anchor string for their "signer 1" tabs.
        sign_here1 = SignHere(anchor_string='**signature_1**',
                              anchor_units='pixels',
                              anchor_y_offset='10',
                              anchor_x_offset='20')
        sign_here2 = SignHere(anchor_string='/sn1/',
                              anchor_units='pixels',
                              anchor_y_offset='10',
                              anchor_x_offset='20')

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

        # Add the recipients to the envelope object
        recipients = Recipients(signers=[signer1], carbon_copies=[cc1])
        env.recipients = recipients

        # Request that the envelope be sent by setting |status| to "sent".
        # To request that the envelope be created as a draft, set to "created"
        env.status = "sent"

        envelope_api = EnvelopesApi(SendEnvelope.api_client)
        results = envelope_api.create_envelope(SendEnvelope.accountID,
                                               envelope_definition=env)

        return results
예제 #19
0
def embedded_signing_ceremony():
    """
    The document <file_name> will be signed by <signer_name> via an
    embedded signing ceremony.
    """

    #
    # Step 1. The envelope definition is created.
    #         One signHere tab is added.
    #         The document path supplied is relative to the working directory
    #
    # 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",
        client_user_id=
        client_user_id,  # Setting the client_user_id marks the signer as embedded
    )

    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.
    )
    #
    #  Step 2. Create/send the envelope.
    #
    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)

    #
    # Step 3. The envelope has been created.
    #         Request a Recipient View URL (the Signing Ceremony URL)
    #
    envelope_id = results.envelope_id
    recipient_view_request = RecipientViewRequest(
        authentication_method=authentication_method,
        client_user_id=client_user_id,
        recipient_id='1',
        return_url=base_url + '/dsreturn',
        user_name=signer_name,
        email=signer_email)

    results = envelope_api.create_recipient_view(
        account_id, envelope_id, recipient_view_request=recipient_view_request)

    #
    # Step 4. The Recipient View URL (the Signing Ceremony URL) has been received.
    #         Redirect the user's browser to it.
    #
    return results.url
def embedded_signing_ceremony():
    """
    The document <file_name> will be signed by <signer_name> via an
    embedded signing ceremony.
    """

    #
    # Step 1. The envelope definition is created.
    #         One signHere tab is added.
    #         The document path supplied is relative to the working directory
    #

    env_def = EnvelopeDefinition()
    env_def.email_subject = 'PLEASE GOD HELP ME, I NEED THIS WORKING!!'
    env_def.template_id = template_id

    t_role = TemplateRole()
    t_role.role_name = role_name
    t_role.name = user_name
    t_role.email = user_email
    t_role.client_user_id = client_user_id

    text_example = Text()
    text_example.tab_label = 'example'
    text_example.value = 'SIIII GRACIAS DIOS!! -- EXAMPLE'

    text_name = Text()
    text_name.tab_label = 'name'
    text_name.value = 'SIIII GRACIAS DIOS!! -- NAME'

    text_name2 = Text()
    text_name2.tab_label = 'name2'
    text_name2.value = 'SIIII GRACIAS DIOS!! -- NAME2'

    text = Text()
    text.document_id = '1'
    text.page_number = '1'
    text.recipient_id = '1'
    text.x_position = '100'
    text.y_position = '100'
    text.scale_value = '0.5'
    text.value = 'THANKS GOD!!'

    title_label = Title()
    title_label.tab_label = 'lablel_example'
    title_label.value = 'LendingFront'

    tabs = Tabs()
    tabs.text_tabs = [text_example, text_name, text_name2, text]
    tabs.title_tabs = [title_label]
    t_role.tabs = tabs

    env_def.template_roles = [t_role]
    env_def.status = environment_status

    #
    #  Step 2. Create/send the envelope.
    #
    api_client = ApiClient()
    api_client.host = base_path
    api_client.set_default_header("Authorization", "Bearer " + access_token)

    envelope_api = EnvelopesApi(api_client)
    envelope_summary = envelope_api.create_envelope(
        account_id, envelope_definition=env_def)
    envelope_id = envelope_summary.envelope_id

    print("Envelope {} has been sent to {}".format(envelope_id, t_role.email))

    return 'Works!'
예제 #21
0
    def make_envelope(cls, args):
        """
        Creates envelope
        Uses compositing templates to add a new document to the existing template
        returns an envelope definition

        The envelope request object uses Composite Template to
        include in the envelope:
        1. A template stored on the DocuSign service
        2. An additional document which is a custom HTML source document
        """

        # 1. Create Recipients for server template. Note that Recipients object
        #    is used, not TemplateRole
        #
        # Create a signer recipient for the signer role of the server template
        signer1 = Signer(
            email=args["signer_email"],
            name=args["signer_name"],
            role_name="signer",
            recipient_id="1",
            # Adding clientUserId transforms the template recipient
            # into an embedded recipient:
            client_user_id=args["signer_client_id"]
        )
        # Create the cc recipient
        cc1 = CarbonCopy(
            email=args["cc_email"],
            name=args["cc_name"],
            role_name="cc",
            recipient_id="2"
        )
        # Recipients object:
        recipients_server_template = Recipients(
            carbon_copies=[cc1],
            signers=[signer1]
        )

        # 2. create a composite template for the Server template + roles
        comp_template1 = CompositeTemplate(
            composite_template_id="1",
            server_templates=[
                ServerTemplate(sequence="1", template_id=args["template_id"])
            ],
            # Add the roles via an inlineTemplate
            inline_templates=[
                InlineTemplate(sequence="1",
                               recipients=recipients_server_template)
            ]
        )

        # Next, create the second composite template that will
        # include the new document.
        #
        # 3. Create the signer recipient for the added document
        #    starting with the tab definition:
        sign_here1 = SignHere(
            anchor_string="**signature_1**",
            anchor_y_offset="10",
            anchor_units="pixels",
            anchor_x_offset="20"
        )
        signer1_tabs = Tabs(sign_here_tabs=[sign_here1])

        # 4. Create Signer definition for the added document
        signer1_added_doc = Signer(
            email=args["signer_email"],
            name=args["signer_name"],
            role_name="signer",
            recipient_id="1",
            client_user_id=args["signer_client_id"],
            tabs=signer1_tabs
        )
        # 5. The Recipients object for the added document.
        #    Using cc1 definition from above.
        recipients_added_doc = Recipients(
            carbon_copies=[cc1], signers=[signer1_added_doc])
        # 6. Create the HTML document that will be added to the envelope
        doc1_b64 = base64.b64encode(bytes(cls.create_document1(args), "utf-8")) \
            .decode("ascii")
        doc1 = Document(
            document_base64=doc1_b64,
            name="Appendix 1--Sales order",  # can be different from
            # actual file name
            file_extension="html",
            document_id="1"
        )
        # 6. create a composite template for the added document
        comp_template2 = CompositeTemplate(
            composite_template_id="2",
            # Add the recipients via an inlineTemplate
            inline_templates=[
                InlineTemplate(sequence="2", recipients=recipients_added_doc)
            ],
            document=doc1
        )
        # 7. create the envelope definition with the composited templates
        envelope_definition = EnvelopeDefinition(
            status="sent",
            composite_templates=[comp_template1, comp_template2]
        )

        return envelope_definition
def embedded_signing_ceremony():
    """
    The document <file_name> will be signed by <signer_name> via an
    embedded signing ceremony.
    """

    #
    # Step 1. Create and define the API Client.
    #

    api_client = get_api_client_by_jwt_authorization_flow()

    #
    # Step 2. The envelope definition is created.
    #         One signHere tab is added.
    #         The document path supplied is relative to the working directory
    #

    env_def = EnvelopeDefinition()
    env_def.email_subject = 'Sign the document needed to finish the loan process!!'
    env_def.template_id = DS_CONFIG['template_id']

    t_role = TemplateRole()
    t_role.role_name = DS_CONFIG['signer_role']
    t_role.name = DS_CONFIG['signer_name']
    t_role.email = DS_CONFIG['signer_email']
    t_role.client_user_id = DS_CONFIG['client_user_id']

    text_name = Text()
    text_name.tab_label = 'name'
    text_name.value = 'Jonathan'

    text_last_name = Text()
    text_last_name.tab_label = 'last_name'
    text_last_name.value = 'Vallejo'

    tabs = Tabs()
    tabs.text_tabs = [text_name, text_last_name]
    t_role.tabs = tabs

    env_def.template_roles = [t_role]
    env_def.status = DS_CONFIG['environment_status']

    #
    #  Step 3. Create/send the envelope.
    #

    envelope_api = EnvelopesApi(api_client)
    envelope_summary = envelope_api.create_envelope(
        DS_CONFIG['account_id'], envelope_definition=env_def)
    envelope_id = envelope_summary.envelope_id

    print("Envelope {} has been sent to {} and the summary id: {}".format(
        envelope_id, t_role.email, envelope_summary))

    #
    #  Step 4. Create/send the Recipient View Request in order to get a URL to sign the document.
    #

    recipient_view_request = RecipientViewRequest(
        authentication_method=DS_CONFIG['authentication_method'],
        client_user_id=DS_CONFIG['client_user_id'],
        recipient_id='1',
        return_url=DS_CONFIG['app_url'] +
        '/ds_return?envelope_id={}'.format(envelope_id),
        user_name=DS_CONFIG['signer_name'],
        email=DS_CONFIG['signer_email'])

    results = envelope_api.create_recipient_view(
        DS_CONFIG['account_id'],
        envelope_id,
        recipient_view_request=recipient_view_request)

    return results.url
예제 #23
0
    def make_envelope(cls, args):
        """
        Creates envelope
        Document 1: An HTML document.
        Document 2: A Word .docx document.
        Document 3: A PDF document.
        DocuSign will convert all of the documents to the PDF format.
        The recipients" field tags are placed using <b>anchor</b> strings.
        """

        # document 1 (html) has sign here anchor tag **signature_1**
        # document 2 (docx) has sign here anchor tag /sn1/
        # document 3 (pdf)  has sign here anchor tag /sn1/
        #
        # The envelope has two recipients.
        # recipient 1 - signer
        # recipient 2 - cc
        # The envelope will be sent first to the signer.
        # After it is signed, a copy is sent to the cc person.

        # create the envelope definition
        env = EnvelopeDefinition(email_subject="Please sign this document set")
        doc1_b64 = base64.b64encode(bytes(cls.create_document1(args),
                                          "utf-8")).decode("ascii")
        # read files 2 and 3 from a local directory
        # The reads could raise an exception if the file is not available!
        with open(path.join(demo_docs_path, DS_CONFIG["doc_docx"]),
                  "rb") as file:
            doc2_docx_bytes = file.read()
        doc2_b64 = base64.b64encode(doc2_docx_bytes).decode("ascii")
        with open(path.join(demo_docs_path, DS_CONFIG["doc_pdf"]),
                  "rb") as file:
            doc3_pdf_bytes = file.read()
        doc3_b64 = base64.b64encode(doc3_pdf_bytes).decode("ascii")

        # Create the document models
        document1 = Document(  # create the DocuSign document object
            document_base64=doc1_b64,
            name=
            "Order acknowledgement",  # can be different from actual file name
            file_extension="html",  # many different document types are accepted
            document_id="1"  # a label used to reference the doc
        )
        document2 = Document(  # create the DocuSign document object
            document_base64=doc2_b64,
            name="Battle Plan",  # can be different from actual file name
            file_extension="docx",  # many different document types are accepted
            document_id="2"  # a label used to reference the doc
        )
        document3 = Document(  # create the DocuSign document object
            document_base64=doc3_b64,
            name="Lorem Ipsum",  # can be different from actual file name
            file_extension="pdf",  # many different document types are accepted
            document_id="3"  # a label used to reference the doc
        )
        # The order in the docs array determines the order in the envelope
        env.documents = [document1, document2, document3]

        # Create the signer recipient model
        signer1 = Signer(email=args["signer_email"],
                         name=args["signer_name"],
                         recipient_id="1",
                         routing_order="1")
        # routingOrder (lower means earlier) determines the order of deliveries
        # to the recipients. Parallel routing order is supported by using the
        # same integer as the order for two or more recipients.

        # create a cc recipient to receive a copy of the documents
        cc1 = CarbonCopy(email=args["cc_email"],
                         name=args["cc_name"],
                         recipient_id="2",
                         routing_order="2")

        # Create signHere fields (also known as tabs) on the documents,
        # We"re using anchor (autoPlace) positioning
        #
        # The DocuSign platform searches throughout your envelope"s
        # documents for matching anchor strings. So the
        # signHere2 tab will be used in both document 2 and 3 since they
        # use the same anchor string for their "signer 1" tabs.
        sign_here1 = SignHere(anchor_string="**signature_1**",
                              anchor_units="pixels",
                              anchor_y_offset="10",
                              anchor_x_offset="20")

        sign_here2 = SignHere(anchor_string="/sn1/",
                              anchor_units="pixels",
                              anchor_y_offset="10",
                              anchor_x_offset="20")

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

        # Add the recipients to the envelope object
        recipients = Recipients(signers=[signer1], carbon_copies=[cc1])
        env.recipients = recipients

        # Request that the envelope be sent by setting |status| to "sent".
        # To request that the envelope be created as a draft, set to "created"
        env.status = args["status"]

        return env
예제 #24
0
def embedded_signing_ceremony():
    """
    The document <file_name> will be signed by <signer_name> via an
    embedded signing ceremony.
    """

    #
    # Step 1. The envelope definition is created.
    #         One signHere tab is added.
    #         The document path supplied is relative to the working directory
    #
    '''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')

    # Create the document model
    '''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
    )'''
    '''text_field = docusign.Text(
        tab_label='name',  # tab_label must exactly match the field you created in the Docusign GUI
        value='Manuel'  # value, as far as I can tell, must be a string.
    )

    docusign.Tabs(text_tabs=[text_field])'''

    patient_first_name = TextCustomField(name='name',
                                         value='Allen',
                                         show='true',
                                         required='false')
    patient_last_name = TextCustomField(name='lastname',
                                        value='Elks',
                                        show='true',
                                        required='false')
    custom_fields = CustomFields(
        text_custom_fields=[patient_first_name, patient_last_name])

    # envelope_definition.custom_fields = custom_fields

    # Custome fields
    custom_fields_old = CustomFields(['name'], ['Manuel'])

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

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

    # 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.
        custom_fields = custom_fields
    )'''

    envDef = EnvelopeDefinition()
    envDef.email_subject = 'PLEASE GOD HELP ME, I NEED THIS WORKING!!'
    envDef.template_id = 'd5e617be-da0a-4431-9014-4575282f61d4'

    tRole = TemplateRole()
    tRole.role_name = 'Manager'
    tRole.name = 'Manuel Alejandro Galvez'
    tRole.email = '*****@*****.**'

    envDef.template_roles = [tRole]
    envDef.status = 'sent'
    envDef.custom_fields = custom_fields

    #
    #  Step 2. Create/send the envelope.
    #
    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=envDef)

    #
    # Step 3. The envelope has been created.
    #         Request a Recipient View URL (the Signing Ceremony URL)
    #
    envelope_id = results.envelope_id
    recipient_view_request = RecipientViewRequest(
        authentication_method=authentication_method,
        client_user_id=client_user_id,
        recipient_id='1',
        return_url=base_url + '/dsreturn',
        user_name=signer_name,
        email=signer_email)

    results = envelope_api.create_recipient_view(account_id, envelope_id)
    #recipient_view_request = recipient_view_request)

    #
    # Step 4. The Recipient View URL (the Signing Ceremony URL) has been received.
    #         Redirect the user's browser to it.
    #
    return results.url
예제 #25
0
    def make_envelope(cls, args):
        """
        Creates envelope
        args -- parameters for the envelope:
        signer_email, signer_name, signer_client_id
        returns an envelope definition
        """

        # Document 1 (PDF) has tag /sn1/
        #
        # The envelope has one recipient:
        # recipient 1 - signer
        with open(path.join(demo_docs_path, DS_CONFIG["doc_salary_docx"]), "rb") as file:
            content_bytes = file.read()
        base64_file_content = base64.b64encode(content_bytes).decode("ascii")

        # Create the document model
        document = Document(  # Create the DocuSign document object
            document_base64=base64_file_content,
            name="Lorem Ipsum",  # Can be different from the actual filename
            file_extension="docx",  # 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=args["signer_email"], name=args["signer_name"],
            recipient_id="1", routing_order="1",
            # Setting the client_user_id marks the signer as embedded
            client_user_id=args["signer_client_id"]
        )

        # Create a SignHere tab (field on the document)
        sign_here = SignHere(  # DocuSign SignHere field/tab
            anchor_string="/sn1/", anchor_units="pixels",
            anchor_y_offset="10", anchor_x_offset="20"
        )

        text_legal = Text(
            anchor_string="/legal/", anchor_units="pixels",
            anchor_y_offset="-9", anchor_x_offset="5",
            font="helvetica", font_size="size11",
            bold="true", value=args["signer_name"],
            locked="false", tab_id="legal_name",
            tab_label="Legal name")

        text_familar = Text(
            anchor_string="/familiar/", anchor_units="pixels",
            anchor_y_offset="-9", anchor_x_offset="5",
            font="helvetica", font_size="size11",
            bold="true", value=args["signer_name"],
            locked="false", tab_id="familar_name",
            tab_label="Familiar name")

        salary = 123000

        text_salary = Text(
            anchor_string="/salary/",
            anchor_units="pixels",
            anchor_y_offset="-9",
            anchor_x_offset="5",
            font="helvetica",
            font_size="size11",
            bold="true",
            value="${:.2f}".format(salary),
            locked="true",
            tab_id="salary",
            tab_label="Salary")

        salary_custom_field = TextCustomField(
            name="salary",
            required="false",
            show="true",  # Yes, include in the CoC
            value=str(salary)
        )
        cf = CustomFields(text_custom_fields=[salary_custom_field])
        # Add the tabs model (including the SignHere tab) to the signer
        # The Tabs object wants arrays of the different field/tab types
        signer.tabs = Tabs(sign_here_tabs=[sign_here], text_tabs=[text_legal, text_familar, text_salary])

        # 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 Recipients object wants arrays for each recipient type
            recipients=Recipients(signers=[signer]),
            custom_fields=cf,
            status="sent"  # Requests that the envelope be created and sent
        )

        return envelope_definition
예제 #26
0
    def create_with_payment(cls, tpl, user, insurance_info, envelope_args):
        """Create envelope with payment feature included
        Parameters:
            tpl (str): Template path for the document
            user (dict}: User information
            insurance_info (dict): Insurance information for enrollment
            envelope_args (dict): Parameters for the envelope
        Returns:
            EnvelopeDefinition object that will be submitted to Docusign
        """
        currency_multiplier = 100
        discount_percent = 5
        insurance_rate_percent = 10

        # Read template and fill it up
        with open(path.join(TPL_PATH, tpl), 'r') as file:
            content_bytes = file.read()

        # Get base64 logo representation to paste it into the HTML file
        with open(path.join(IMG_PATH, 'logo.png'), 'rb') as file:
            img_base64_src = base64.b64encode(file.read()).decode('utf-8')
        content_bytes = Environment(
            loader=BaseLoader).from_string(content_bytes).render(
                user_name=f"{user['first_name']} {user['last_name']}",
                user_email=user['email'],
                address=f"{user['street']}, {user['city']}, {user['state']}",
                zip_code=user['zip_code'],
                detail_1=insurance_info['detail1']['name'],
                detail_2=insurance_info['detail2']['name'],
                value_detail_1=insurance_info['detail1']['value'],
                value_detail_2=insurance_info['detail2']['value'],
                img_base64_src=img_base64_src)

        base64_file_content = base64.b64encode(bytes(content_bytes,
                                                     'utf-8')).decode('ascii')

        # Create the envelope definition
        envelope_definition = EnvelopeDefinition(
            email_subject='Buy New Insurance')

        # Create the document
        doc1 = Document(
            document_base64=base64_file_content,
            name=
            'Insurance order form',  # Can be different from actual file name
            file_extension='html',  # Source data format
            document_id='1'  # A label used to reference the doc
        )
        envelope_definition.documents = [doc1]

        # Create a signer recipient to sign the document
        signer1 = Signer(email=user['email'],
                         name=f"{user['first_name']} {user['last_name']}",
                         recipient_id='1',
                         routing_order='1',
                         client_user_id=envelope_args['signer_client_id'])
        sign_here1 = SignHere(
            anchor_string='/sn1/',
            anchor_y_offset='10',
            anchor_units='pixels',
            anchor_x_offset='20',
        )

        # Create number tabs for the coverage amount and deductible
        coverage = Number(
            font='helvetica',
            font_size='size11',
            anchor_string='/l1e/',
            anchor_y_offset='-7',
            anchor_units='pixels',
            tab_label='l1e',
            required='true',
        )

        deductible = Number(
            font='helvetica',
            font_size='size11',
            anchor_string='/l2e/',
            anchor_y_offset='-7',
            anchor_units='pixels',
            tab_label='l2e',
            required='true',
        )

        # Create checkbox and trigger tabs to apply the discount
        checkbox = Checkbox(
            font='helvetica',
            font_size='size11',
            anchor_string='/cb/',
            anchor_y_offset='-4',
            anchor_units='pixels',
            anchor_x_offset='-8',
            tab_label='checkbox',
            height='50',
            bold='true',
        )

        trigger = FormulaTab(
            anchor_string='/trigger/',
            font_color='white',
            anchor_y_offset='10',
            tab_label='trigger',
            conditional_parent_label='checkbox',
            conditional_parent_value='on',
            formula='1',
            required='true',
            locked='true',
        )

        discount = FormulaTab(
            font='helvetica',
            font_size='size11',
            bold='true',
            anchor_string='/dt/',
            anchor_y_offset='-4',
            anchor_units='pixels',
            anchor_x_offset='0',
            tab_label='discount',
            formula=f"if([trigger] > 0, {discount_percent}, 0)",
            round_decimal_places='0',
            locked='true',
        )

        # Create a formula tab for the insurance price
        total = f'([l1e]-[l2e]) * {insurance_rate_percent}/100'

        formula_total = FormulaTab(
            font='helvetica',
            bold='true',
            font_size='size12',
            anchor_string='/l4t/',
            anchor_y_offset='-6',
            anchor_units='pixels',
            anchor_x_offset='84',
            tab_label='l4t',
            formula=f'({total}) - (({total}) * [discount]/100)',
            round_decimal_places='2',
            required='true',
            locked='true',
        )

        # Create payment line item
        payment_line_iteml1 = PaymentLineItem(name='Insurance payment',
                                              description='$[l4t]',
                                              amount_reference='l4t')

        payment_details = PaymentDetails(
            gateway_account_id=envelope_args['gateway_account_id'],
            currency_code='USD',
            gateway_name=envelope_args['gateway_name'],
            line_items=[payment_line_iteml1])

        # Create a hidden formula tab for the payment itself
        formula_payment = FormulaTab(
            tab_label='payment',
            formula=f'([l4t]) * {currency_multiplier}',
            round_decimal_places='2',
            payment_details=payment_details,
            hidden='true',
            required='true',
            locked='true',
            document_id='1',
            page_number='1',
            x_position='0',
            y_position='0')

        # Create tabs for the signer
        signer1_tabs = Tabs(
            sign_here_tabs=[sign_here1],
            number_tabs=[coverage, deductible],
            formula_tabs=[formula_payment, formula_total, discount, trigger],
            checkbox_tabs=[checkbox])
        signer1.tabs = signer1_tabs

        # Add the recipients to the envelope object
        recipients = Recipients(signers=[signer1])
        envelope_definition.recipients = recipients

        # Request that the envelope be sent by setting status to 'sent'
        envelope_definition.status = 'sent'

        return envelope_definition
예제 #27
0
    def create_claim(cls, tpl, claim, envelope_args):
        """Creates claim document
        Parameters:
            tpl (str): Template path for the document
            claim (dict): Claim information
            envelope_args (dict): Parameters of the document
        Returns:
            EnvelopeDefinition object that will be submitted to Docusign
        """
        with open(path.join(TPL_PATH, tpl), 'r') as file:
            content_bytes = file.read()

        # Get base64 logo representation to paste it into the HTML file
        with open(path.join(IMG_PATH, 'logo.png'), 'rb') as file:
            img_base64_src = base64.b64encode(file.read()).decode('utf-8')

        content_bytes = Environment(loader=BaseLoader).from_string(
            content_bytes) \
            .render(
            first_name=claim['first_name'],
            last_name=claim['last_name'],
            email=claim['email'],
            street=claim['street'],
            city=claim['city'],
            state=claim['state'],
            zip_code=claim['zip_code'],
            type=claim['type'],
            timestamp=claim['timestamp'],
            description=claim['description'],
            img_base64_src=img_base64_src
        )

        base64_file_content = base64.b64encode(bytes(content_bytes,
                                                     'utf-8')).decode('ascii')

        # Create the document model
        document = Document(  # Create the DocuSign document object
            document_base64=base64_file_content,
            name='Submit a Claim',
            file_extension='html',
            document_id=1)

        # Create the signer recipient model
        signer = Signer(  # The signer
            email=claim['email'],
            name=f"{claim['first_name']} {claim['last_name']}",
            recipient_id='1',
            routing_order='1',
            # Setting the client_user_id marks the signer as embedded
            client_user_id=envelope_args['signer_client_id'])

        # Create a sign_here tab (field on the document)
        sign_here = SignHere(anchor_string='/signature_1/',
                             anchor_units='pixels',
                             anchor_y_offset='10',
                             anchor_x_offset='20')

        # Create an initials tab
        initial_here = InitialHere(anchor_string='/initials_1/',
                                   anchor_units='pixels',
                                   anchor_y_offset='10',
                                   anchor_x_offset='20')

        # Create an email field
        email = Email(document_id='1',
                      page_number='1',
                      anchor_string='/email/',
                      anchor_units='pixels',
                      required=True,
                      value=claim['email'],
                      locked=False,
                      anchor_y_offset='-5')
        signer_attachment_tabs = SignerAttachment(anchor_string='/attachment/',
                                                  anchor_y_offset='-20',
                                                  anchor_units='pixels',
                                                  anchor_x_offset='20',
                                                  optional='true')
        signer.tabs = Tabs(
            sign_here_tabs=[sign_here],
            email_tabs=[email],
            initial_here_tabs=[initial_here],
            signer_attachment_tabs=[signer_attachment_tabs],
        )

        # Create the top-level envelope definition and populate it
        envelope_definition = EnvelopeDefinition(
            email_subject='Submit a Claim',
            documents=[document],
            # The Recipients object takes arrays for each recipient type
            recipients=Recipients(signers=[signer]),
            status='sent'  # Requests that the envelope be created and sent
        )

        return envelope_definition
예제 #28
0
    def make_envelope(cls, args):
        """
        This function creates the envelope definition for the
        order form.
        document 1 (html) has multiple tags:
         /l1q/ and /l2q/ -- quantities: drop down
         /l1e/ and /l2e/ -- extended: payment lines
         /l3t/ -- total -- formula

        The envelope has two recipients.
          recipient 1 - signer
          recipient 2 - cc
        The envelope will be sent first to the signer.
        After it is signed, a copy is sent to the cc person.

        #################################################################
        #                                                               #
        # NOTA BENA: This method programmatically constructs the        #
        #            order form. For many use cases, it would be        #
        #            better to create the order form as a template      #
        #            using the DocuSign web tool as WYSIWYG             #
        #            form designer.                                     #
        #                                                               #
        #################################################################

        """

        # Order form constants
        l1_name = "Harmonica"
        l1_price = 5
        l1_description = f"${l1_price} each"
        l2_name = "Xylophone"
        l2_price = 150
        l2_description = f"${l2_price} each"
        currency_multiplier = 100

        # read the html file from a local directory
        # The read could raise an exception if the file is not available!
        doc1_file = "order_form.html"
        with open(path.join(demo_docs_path, doc1_file), "r") as file:
            doc1_html_v1 = file.read()

        # Substitute values into the HTML
        # Substitute for: {signerName}, {signerEmail}, {cc_name}, {cc_email}
        doc1_html_v2 = doc1_html_v1.replace("{signer_name}", args["signer_name"]) \
            .replace("{signer_email}", args["signer_email"]) \
            .replace("{cc_name}", args["cc_name"]) \
            .replace("{cc_email}", args["cc_email"])

        # create the envelope definition
        envelope_definition = EnvelopeDefinition(
            email_subject="Please complete your order")
        # add the document
        doc1_b64 = base64.b64encode(bytes(doc1_html_v2,
                                          "utf-8")).decode("ascii")
        doc1 = Document(
            document_base64=doc1_b64,
            name="Order form",  # can be different from actual file name
            file_extension="html",  # Source data format.
            document_id="1"  # a label used to reference the doc
        )
        envelope_definition.documents = [doc1]
        # create a signer recipient to sign the document
        signer1 = Signer(email=args["signer_email"],
                         name=args["signer_name"],
                         recipient_id="1",
                         routing_order="1")
        # create a cc recipient to receive a copy of the documents
        cc1 = CarbonCopy(email=args["cc_email"],
                         name=args["cc_name"],
                         recipient_id="2",
                         routing_order="2")
        # Create signHere fields (also known as tabs) on the documents,
        # We"re using anchor (autoPlace) positioning
        sign_here1 = SignHere(anchor_string="/sn1/",
                              anchor_y_offset="10",
                              anchor_units="pixels",
                              anchor_x_offset="20")
        list_item0 = ListItem(text="none", value="0")
        list_item1 = ListItem(text="1", value="1")
        list_item2 = ListItem(text="2", value="2")
        list_item3 = ListItem(text="3", value="3")
        list_item4 = ListItem(text="4", value="4")
        list_item5 = ListItem(text="5", value="5")
        list_item6 = ListItem(text="6", value="6")
        list_item7 = ListItem(text="7", value="7")
        list_item8 = ListItem(text="8", value="8")
        list_item9 = ListItem(text="9", value="9")
        list_item10 = ListItem(text="10", value="10")

        listl1q = List(font="helvetica",
                       font_size="size11",
                       anchor_string="/l1q/",
                       anchor_y_offset="-10",
                       anchor_units="pixels",
                       anchor_x_offset="0",
                       list_items=[
                           list_item0, list_item1, list_item2, list_item3,
                           list_item4, list_item5, list_item6, list_item7,
                           list_item8, list_item9, list_item10
                       ],
                       required="true",
                       tab_label="l1q")
        listl2q = List(font="helvetica",
                       font_size="size11",
                       anchor_string="/l2q/",
                       anchor_y_offset="-10",
                       anchor_units="pixels",
                       anchor_x_offset="0",
                       list_items=[
                           list_item0, list_item1, list_item2, list_item3,
                           list_item4, list_item5, list_item6, list_item7,
                           list_item8, list_item9, list_item10
                       ],
                       required="true",
                       tab_label="l2q")
        # create two formula tabs for the extended price on the line items
        formulal1e = FormulaTab(
            font="helvetica",
            font_size="size11",
            anchor_string="/l1e/",
            anchor_y_offset="-8",
            anchor_units="pixels",
            anchor_x_offset="105",
            tab_label="l1e",
            formula=f"[l1q] * {l1_price}",
            round_decimal_places="0",
            required="true",
            locked="true",
            disable_auto_size="false",
        )
        formulal2e = FormulaTab(
            font="helvetica",
            font_size="size11",
            anchor_string="/l2e/",
            anchor_y_offset="-8",
            anchor_units="pixels",
            anchor_x_offset="105",
            tab_label="l2e",
            formula=f"[l2q] * {l2_price}",
            round_decimal_places="0",
            required="true",
            locked="true",
            disable_auto_size="false",
        )
        # Formula for the total
        formulal3t = FormulaTab(
            font="helvetica",
            bold="true",
            font_size="size12",
            anchor_string="/l3t/",
            anchor_y_offset="-8",
            anchor_units="pixels",
            anchor_x_offset="50",
            tab_label="l3t",
            formula="[l1e] + [l2e]",
            round_decimal_places="0",
            required="true",
            locked="true",
            disable_auto_size="false",
        )
        # Payment line items
        payment_line_iteml1 = PaymentLineItem(name=l1_name,
                                              description=l1_description,
                                              amount_reference="l1e")
        payment_line_iteml2 = PaymentLineItem(name=l2_name,
                                              description=l2_description,
                                              amount_reference="l2e")
        payment_details = PaymentDetails(
            gateway_account_id=args["gateway_account_id"],
            currency_code="USD",
            gateway_name=args["gateway_name"],
            line_items=[payment_line_iteml1, payment_line_iteml2])
        # Hidden formula for the payment itself
        formula_payment = FormulaTab(
            tab_label="payment",
            formula=f"([l1e] + [l2e]) * {currency_multiplier}",
            round_decimal_places="0",
            payment_details=payment_details,
            hidden="true",
            required="true",
            locked="true",
            document_id="1",
            page_number="1",
            x_position="0",
            y_position="0")

        # Tabs are set per recipient / signer
        signer1_tabs = Tabs(
            sign_here_tabs=[sign_here1],
            list_tabs=[listl1q, listl2q],
            formula_tabs=[formulal1e, formulal2e, formulal3t, formula_payment])
        signer1.tabs = signer1_tabs

        # Add the recipients to the envelope object
        recipients = Recipients(signers=[signer1], carbon_copies=[cc1])
        envelope_definition.recipients = recipients

        # Request that the envelope be sent by setting |status| to "sent".
        # To request that the envelope be created as a draft, set to "created"
        envelope_definition.status = args["status"]

        return envelope_definition
예제 #29
0
    def worker(args):
        """
        1. Create an api client
        2. Create an envelope definition object
        3. Call the eSignature REST API using the SDK
        """
        # Step 1: Construct your API headers
        api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"])

        # Step 2: Construct your envelope
        envelope_definition = EnvelopeDefinition(
            email_subject="Please sign this document set"
        )

        # Open the example file
        with open(path.join(demo_docs_path, DS_CONFIG["doc_pdf"]), "rb") as file:
            content_bytes = file.read()
        base64_file_content = base64.b64encode(content_bytes).decode("ascii")

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

        envelope_definition.documents = [document1]
        envelope_definition.status = args["envelope_args"]["status"]

        signer1 = Signer(
            email=args["envelope_args"]["signer_email"],  # represents your {signer_email}
            name=args["envelope_args"]["signer_name"],  # represents your {signer_name}
            phone_authentication={"senderProvidedNumbers": [args["envelope_args"]["phone_number"]]},
            id_check_configuration_name="Phone Auth $",
            require_id_lookup="true",
            recipient_id="1",
            routing_order="1"
        )

        # Create your signature tab
        sign_here1 = SignHere(
            name="SignHereTab",
            x_position="75",
            y_position="572",
            tab_label="SignHereTab",
            page_number="1",
            document_id="1",
            # A 1- to 8-digit integer or 32-character GUID to match recipient IDs on your own systems.
            # This value is referenced in the Tabs element below to assign tabs on a per-recipient basis.
            recipient_id="1"  # represents your {RECIPIENT_ID}
        )

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

        # Tabs are set per recipient
        envelope_definition.recipients = Recipients(signers=[signer1])
        # Step 3: Call the eSignature REST API
        envelope_api = EnvelopesApi(api_client)
        results = envelope_api.create_envelope(account_id=args["account_id"], envelope_definition=envelope_definition)

        return results
예제 #30
0
    def make_envelope(cls, args):
        """
        Creates envelope
        args -- parameters for the envelope:
        signer_email, signer_name, signer_client_id
        returns an envelope definition
        """

        # Set the values for the fields in the template
        # List item
        list1 = List(value="green",
                     document_id="1",
                     page_number="1",
                     tab_label="list")

        # Checkboxes
        check1 = Checkbox(tab_label="ckAuthorization", selected="true")

        check3 = Checkbox(tab_label="ckAgreement", selected="true")

        radio_group = RadioGroup(
            group_name="radio1",
            radios=[Radio(value="white", selected="true")])

        text = Text(tab_label="text", value="Jabberywocky!")

        # We can also add a new tab (field) to the ones already in the template:
        text_extra = Text(document_id="1",
                          page_number="1",
                          x_position="280",
                          y_position="172",
                          font="helvetica",
                          font_size="size14",
                          tab_label="added text field",
                          height="23",
                          width="84",
                          required="false",
                          bold="true",
                          value=args["signer_name"],
                          locked="false",
                          tab_id="name")

        # Add the tabs model (including the SignHere tab) to the signer.
        # The Tabs object wants arrays of the different field/tab types
        # Tabs are set per recipient / signer
        tabs = Tabs(checkbox_tabs=[check1, check3],
                    radio_group_tabs=[radio_group],
                    text_tabs=[text, text_extra],
                    list_tabs=[list1])

        # create a signer recipient to sign the document, identified by name and email
        # We"re setting the parameters via the object creation
        signer = TemplateRole(  # The signer
            email=args["signer_email"],
            name=args["signer_name"],
            # Setting the client_user_id marks the signer as embedded
            client_user_id=args["signer_client_id"],
            role_name="signer",
            tabs=tabs)

        cc = TemplateRole(email=args["cc_email"],
                          name=args["cc_name"],
                          role_name="cc")

        # create an envelope custom field to save our application"s
        # data about the envelope

        custom_field = TextCustomField(
            name="app metadata item",
            required="false",
            show="true",  # Yes, include in the CoC
            value="1234567")

        cf = CustomFields(text_custom_fields=[custom_field])

        # Next, create the top level envelope definition and populate it.
        envelope_definition = EnvelopeDefinition(
            email_subject="Please sign this document sent from the Python SDK",
            # The Recipients object wants arrays for each recipient type
            template_id=session["template_id"],
            template_roles=[signer, cc],
            custom_fields=cf,
            status="sent"  # requests that the envelope be created and sent.
        )

        return envelope_definition