Esempio n. 1
0
def createRecipients(signer1, cc1):
    recipients = Recipients()
    recipients.signers = [signer1]
    recipients.carbon_copies = [cc1]
    return recipients
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