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
Exemple #2
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 create_api_client(base_path, access_token):
    """Create api client and construct API headers"""
    api_client = ApiClient()
    api_client.host = base_path
    api_client.set_default_header(header_name="Authorization", header_value=f"Bearer {access_token}")

    return api_client
def get_api_client_by_jwt_authorization_flow():
    """
        This method create a ApiClient object and configure it using
        JWT authorization flow.
    """

    api_client = ApiClient()
    api_client.host = DS_CONFIG['base_path']

    # IMPORTANT NOTE:
    # the first time you ask for a JWT access token, you should grant access by making the following call
    # get DocuSign OAuth authorization url:
    oauth_login_url = api_client.get_jwt_uri(DS_CONFIG['integrator_key'],
                                             DS_CONFIG['redirect_uri'],
                                             DS_CONFIG['oauth_base_url'])
    # open DocuSign OAuth authorization url in the browser, login and grant access
    # web_browser.open_new_tab(oauth_login_url)
    print(oauth_login_url)
    # END OF NOTE

    # configure the ApiClient to asynchronously get an access token and store it

    # Get the application Path
    app_path_keys = os.path.dirname(os.path.abspath(__file__)).replace(
        'stable', 'keys/')
    app_path_keys += DS_CONFIG['private_key_filename']

    api_client.configure_jwt_authorization_flow(app_path_keys,
                                                DS_CONFIG['oauth_base_url'],
                                                DS_CONFIG['integrator_key'],
                                                DS_CONFIG['user_admin_id'],
                                                3600)

    return api_client
Exemple #5
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
Exemple #6
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
Exemple #7
0
def envelope_obj():
    api_client = ApiClient()
    privatekey = os.path.join(settings.BASE_DIR, "keys", "private_key")
    api_client.host = settings.DOCU_BASE_URL
    api_client.configure_jwt_authorization_flow(privatekey,
                                                settings.DOCU_OAUTH_BASE_URL,
                                                settings.DOCU_INTEGRATOR_KEY,
                                                settings.DOCU_ACCOUNT_USERNAME,
                                                5001)
    return EnvelopesApi(api_client)
def get_api_client_by_access_token():
    """
        This method create a ApiClient object and configure it using
        Token Access Control.
    """

    api_client = ApiClient()
    api_client.host = DS_CONFIG['base_path']
    api_client.set_default_header("Authorization",
                                  "Bearer " + DS_CONFIG['access_token'])

    return api_client
Exemple #9
0
def get_envelopes_api():
    """
       Lists the user's envelopes created in the last 10 days
       """


    #
    # Step 2. Get and display the results
    #
    api_client = ApiClient()
    api_client.host = base_path
    api_client.set_default_header("Authorization", "Bearer " + access_token)

    envelope_api = EnvelopesApi(api_client)
    return envelope_api
def list_envelopes():
    """
    Lists the user's envelopes created in the last 10 days
    """
    
    #
    # Step 1. Prepare the options object
    #
    from_date = pendulum.now().subtract(days=10).to_iso8601_string()
    #
    # Step 2. Get and display the results
    # 
    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.list_status_changes(account_id, from_date = from_date)
    return results
Exemple #11
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
Exemple #12
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
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!'
Exemple #14
0
def get_api_client():
    api_client = ApiClient()
    api_client.host = BASE_PATH
    api_client.set_default_header('Authorization', f'Bearer {get_access_token()}')
    return api_client
Exemple #15
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
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 = 'Lending Front'
    tRole.email = '*****@*****.**'
    tRole.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]
    tRole.tabs = tabs

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

    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')
    '''item_name = ListItem(text='name', value='Allen')
    item_lastname = ListItem(text='lastname', value='Galvez')
    item_testing = ListItem(text='testing', value='testing')
    item_manu = ListItem(text='manu', value='manu')

    listcf = ListCustomField(list_items=[item_name, item_lastname, item_testing, item_manu])'''

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

    envDef.custom_fields = custom_fields
    # envDef.recipients

    #
    print('*&**&*^&*&^%$#$%^&*(*&^%$#@!@#$%^&')
    print('')

    #
    #  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)
    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))
    '''client_user_id = '2939'


    return_url = 'http://www.docusign.com/developer-center'
    recipient_view_request = docusign.RecipientViewRequest()
    recipient_view_request.return_url = return_url
    recipient_view_request.client_user_id = client_user_id
    recipient_view_request.authentication_method = 'email'
    recipient_view_request.user_name = 'Manuel Galvez'
    recipient_view_request.email = '*****@*****.**'

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

    recipient_view_request = RecipientViewRequest(
        authentication_method='None',
        client_user_id=client_user_id,
        recipient_id='1',
        return_url=base_url + '/dsreturn',
        user_name='Lending Front',
        email='*****@*****.**')

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

    return results.url
Exemple #17
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
    #

    env_def = EnvelopeDefinition()
    env_def.email_subject = 'PLEASE GOD HELP ME, I NEED THIS WORKING!!'
    # env_def.template_id = 'd5e617be-da0a-4431-9014-4575282f61d4'
    env_def.template_id = '57e2a00c-b8b5-415c-8c8b-db31d75e8253'

    t_role = TemplateRole()
    t_role.role_name = 'Cliente'
    t_role.name = 'Alejandro Galvez'
    t_role.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 = '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)
    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))
    ''''
    recipient_view_request = RecipientViewRequest(
        authentication_method='None', client_user_id=client_user_id,
        recipient_id='1', return_url=base_url + '/dsreturn',
        user_name='Lending Front', email='*****@*****.**'
    )

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

    return results.url
    '''

    return ''
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 = name
    t_role.email = 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

    # Create the signer recipient model
    signer = Signer(  # The signer
        email=email,
        name=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

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

    env_def.recipients = recipients
    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)

    # authentication_api = AuthenticationApi()
    # authentication_api.api_client = api_client
    # access_token = authentication_api.get_o_auth_token()

    # accessToken = api_client.   GetOAuthToken(client_id, client_secret, true, AccessCode);
    # Console.WriteLine("Access_token: " + accessToken);

    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))

    recipient_view_request = RecipientViewRequest(
        authentication_method=authentication_method,
        client_user_id=client_user_id,
        recipient_id='1',
        return_url=base_url + '/dsreturn',
        user_name=name,
        email=email)

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

    return results.url