Пример #1
0
 def get_view(cls, envelope_id, envelope_args, user, authentication_method='None'):
     """Get the recipient view
     Parameters:
         envelope_id (str): Envelope ID
         envelope_args (dict): Parameters of the document
         user (dict): User information
         authentication_method (str): Authentication method
     Returns:
         URL to the recipient view UI
     """
     # Create the recipient view request object
     recipient_view_request = RecipientViewRequest(
         authentication_method=authentication_method,
         client_user_id=envelope_args['signer_client_id'],
         recipient_id='1',
         return_url=envelope_args['ds_return_url'],
         user_name=f"{user['first_name']} {user['last_name']}",
         email=user['email']
     )
     # Obtain the recipient view URL for the signing ceremony
     # Exceptions will be caught by the calling function
     ds_client = DsClient.get_instance()
     envelope_api = EnvelopesApi(ds_client.api_client)
     results = envelope_api.create_recipient_view(
         ds_client.account_id,
         envelope_id,
         recipient_view_request=recipient_view_request
     )
     return results
Пример #2
0
    def get_view(envelope_id, envelope_args, student, session, authentication_method='None'):
        """Get the recipient view
        Parameters:
            envelope_id (str): envelope ID
            envelope_args (dict): parameters of the document
            student (dict): student information
            authentication_method (str): authentication method
        Returns:
            URL to the recipient view UI
        """
        access_token = session.get('access_token')
        account_id = session.get('account_id')

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

        envelope_api = EnvelopesApi(ds_client)
        results = envelope_api.create_recipient_view(
            account_id,
            envelope_id,
            recipient_view_request=recipient_view_request
        )
        return results
Пример #3
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
Пример #4
0
    def worker(cls, args):
        """
        Create the envelope and the embedded Signing Ceremony
        1. Create the envelope request object using composite template to
           add the new document
        2. Send the envelope
        3. Make the recipient view request object
        4. Get the recipient view (Signing Ceremony) url
        """
        envelope_args = args["envelope_args"]
        # 1. Create the envelope request object
        envelope_definition = cls.make_envelope(envelope_args)

        # 2. call Envelopes::create API method
        # Exceptions will be caught by the calling function
        api_client = create_api_client(base_path=args["base_path"],
                                       access_token=args["access_token"])

        envelope_api = EnvelopesApi(api_client)
        results = envelope_api.create_envelope(
            account_id=args["account_id"],
            envelope_definition=envelope_definition)
        envelope_id = results.envelope_id

        # 3. Create the Recipient View request object
        authentication_method = "None"  # How is this application authenticating
        # the signer? See the "authenticationMethod" definition
        # https://goo.gl/qUhGTm
        recipient_view_request = RecipientViewRequest(
            authentication_method=authentication_method,
            client_user_id=envelope_args["signer_client_id"],
            recipient_id="1",
            return_url=envelope_args["ds_return_url"],
            user_name=envelope_args["signer_name"],
            email=envelope_args["signer_email"])
        # 4. Obtain the recipient_view_url for the signing ceremony
        # Exceptions will be caught by the calling function
        results = envelope_api.create_recipient_view(
            account_id=args["account_id"],
            envelope_id=envelope_id,
            recipient_view_request=recipient_view_request)

        return {"envelope_id": envelope_id, "redirect_url": results.url}
Пример #5
0
    def worker(cls, args):
        """
        1. Create the envelope request object
        2. Send the envelope
        3. Create the Recipient View request object
        4. Obtain the recipient_view_url for the signing ceremony
        """
        envelope_args = args["envelope_args"]
        # 1. Create the envelope request object
        envelope_definition = cls.make_envelope(envelope_args)

        # 2. call Envelopes::create API method
        # Exceptions will be caught by the calling function
        api_client = create_api_client(
            base_path=args["base_path"],
            access_token=args["access_token"]
        )

        envelopes_api = EnvelopesApi(api_client)
        results = envelopes_api.create_envelope(account_id=args["account_id"], envelope_definition=envelope_definition)

        envelope_id = results.envelope_id
        app.logger.info(f"Envelope was created. EnvelopeId {envelope_id}")

        # 3. Create the RecipientViewRequest object
        recipient_view_request = RecipientViewRequest(
            authentication_method=authentication_method,
            client_user_id=envelope_args["signer_client_id"],
            recipient_id="1",
            return_url=envelope_args["ds_return_url"],
            user_name=envelope_args["signer_name"], email=envelope_args["signer_email"]
        )
        # 4. Obtain the recipient view URL for the signing ceremony
        # Exceptions will be caught by the calling function
        results = envelopes_api.create_recipient_view(
            account_id=args["account_id"],
            envelope_id=envelope_id,
            recipient_view_request=recipient_view_request
        )

        return {"envelope_id": envelope_id, "redirect_url": results.url}
Пример #6
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 testEmbeddedSigning(self):
        with open(SignTest1File, 'rb') as sign_file:
            file_contents = sign_file.read()

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

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

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

        # this value represents the client's unique identifier for the signer
        client_user_id = '2939'
        signer.client_user_id = client_user_id

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

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

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

        envelope_definition.status = 'sent'

        envelopes_api = EnvelopesApi()

        try:

            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 = 'Pat Developer'
            recipient_view_request.email = Username

            envelope_summary = envelopes_api.create_envelope(
                self.user_info.accounts[0].account_id,
                envelope_definition=envelope_definition)
            envelope_id = envelope_summary.envelope_id

            view_url = envelopes_api.create_recipient_view(
                self.user_info.accounts[0].account_id,
                envelope_id,
                recipient_view_request=recipient_view_request)

            assert view_url is not None
            assert view_url.url is not None

            # This Url should work in an Iframe or browser to allow signing
            print("ViewUrl is ", end="")
            pprint(view_url)

        except ApiException as e:
            print("\nException when calling DocuSign API: %s" % e)
            assert e is None  # make the test case fail in case of an API exception
    def testEmbeddedSigning(self):
        with open(SignTest1File, 'rb') as sign_file:
            file_contents = sign_file.read()

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

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

        # Add a recipient to sign the document
        email = Username
        name = 'Pat Developer'
        recipient_id_for_doc = '1'

        # this value represents the client's unique identifier for the signer
        client_user_id = '2939'

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

        # create sign here object with the properties
        sign_here = docusign.SignHere(document_id=document_id,
                                      page_number=page_number,
                                      recipient_id=recipient_id,
                                      x_position=x_position,
                                      y_position=y_position,
                                      scale_value=scale_value)

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

        signer = docusign.Signer(email=email,
                                 name=name,
                                 recipient_id=recipient_id_for_doc,
                                 client_user_id=client_user_id,
                                 tabs=tabs)

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

        status = 'sent'
        # create the envelope definition with the properties set
        envelope_definition = docusign.EnvelopeDefinition(
            email_subject=email_subject,
            email_blurb=email_blurb,
            documents=documents,
            recipients=recipients,
            status=status)

        envelopes_api = EnvelopesApi()

        try:

            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 = 'Pat Developer'
            recipient_view_request.email = Username

            envelope_summary = envelopes_api.create_envelope(
                self.user_info.accounts[0].account_id,
                envelope_definition=envelope_definition)
            envelope_id = envelope_summary.envelope_id

            view_url = envelopes_api.create_recipient_view(
                self.user_info.accounts[0].account_id,
                envelope_id,
                recipient_view_request=recipient_view_request)

            assert view_url is not None
            assert view_url.url is not None

            # This Url should work in an Iframe or browser to allow signing
            print("ViewUrl is ", end="")
            pprint(view_url)

        except ApiException as e:
            print("\nException when calling DocuSign API: %s" % e)
            assert e is None  # make the test case fail in case of an API exception
Пример #9
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. 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
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
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