Пример #1
0
def create_stacked_lines(
    lines: List[str], start_y: int, line_spacing: int = 10, **kwargs
) -> List[dse.Text]:
    y = start_y
    result: List[dse.Text] = []

    # This is weird, originally it seemed like DocuSign respected
    # newlines, but then it didn't at some point, so we'll play it
    # safe and manually break up the lines for it.
    for line in lines:
        result.append(
            dse.Text(
                **kwargs,
                value=line,
                y_position=str(y),
            )
        )
        y += line_spacing

    return result
    def testDownLoadEnvelopeDocuments(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 Text tab somewhere on the document for the signer to sign
        text = docusign.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 = docusign.Tabs()
        tabs.text_tabs = [text]
        signer.tabs = tabs

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

        # send the envelope (otherwise it will be "created" in the Draft folder)
        envelope_definition.status = 'sent'

        envelopes_api = EnvelopesApi()
        try:
            docusign.configuration.api_client = self.api_client

            file1 = envelopes_api.get_document(
                self.user_info.accounts[0].account_id, 'combined',
                self.envelope_id)

            assert len(file1) > 0
            subprocess.call('open ' + file1, shell=True)

        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
Пример #3
0
    def testDownLoadEnvelopeDocuments(self):
        file_contents = open(sign_test1_file, 'rb').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 Text tab somewhere on the document for the signer to sign
        text = docusign.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 = docusign.Tabs()
        tabs.text_tabs = [text]
        signer.tabs = tabs

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

        # send the envelope (otherwise it will be "created" in the Draft folder)
        envelope_definition.status = 'sent'

        auth_api = AuthenticationApi()
        envelopes_api = EnvelopesApi()

        try:
            login_info = auth_api.login()
            assert login_info is not None
            assert len(login_info.login_accounts) > 0
            login_accounts = login_info.login_accounts
            assert login_accounts[0].account_id is not None

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

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

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

            file = envelopes_api.get_document(login_accounts[0].account_id,
                                              'combined',
                                              envelope_summary.envelope_id)
            assert len(file) > 0
            subprocess.call('open ' + file, shell=True)

        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 testDownLoadEnvelopeDocuments(self):
        with open(SignTest1File, 'rb') as sign_file:
            file_contents = sign_file.read()

        # Set properties and create an envelope to be signed
        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")
        document_name = 'TestFile.pdf'
        document_id = '1'
        doc = docusign.Document(document_base64=base64_doc,
                                name=document_name,
                                document_id=document_id)
        documents = [doc]

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

        # Create a Text tab somewhere on the document for the signer to sign
        text_document_id = '1'
        page_number = '1'
        recipient_id = '1'
        x_position = '100'
        y_position = '100'
        text = docusign.Text(document_id=text_document_id,
                             page_number=page_number,
                             recipient_id=recipient_id,
                             x_position=x_position,
                             y_position=y_position)

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

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

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

        # send the envelope (otherwise it will be "created" in the Draft folder)
        status = 'sent'

        # create an envelope to be signed
        envelope_definition = docusign.EnvelopeDefinition(
            email_subject=email_subject,
            email_blurb=email_blurb,
            documents=documents,
            recipients=recipients,
            status=status)

        envelopes_api = EnvelopesApi()
        try:
            docusign.configuration.api_client = self.api_client

            file1 = envelopes_api.get_document(
                self.user_info.accounts[0].account_id, 'combined',
                self.envelope_id)

            assert len(file1) > 0
            subprocess.call('open ' + file1, shell=True)

        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
Пример #5
0
def createEnv(repReports=extractReport(),
              template_id="a07ff1a4-d135-459a-ac45-e5b1f3f5e021",
              api_client=dsAuth(),
              template_role_name='Rep',
              template_role_cc='Rep Manager'):
    docusign.configuration.api_client = api_client
    data_labels = {
        "CaseNum_Label":
        ["CNum_1", "CNum_2", "CNum_3", "CNum_4", "CNum_5", "CNum_6"],
        "DateEsc_Label":
        ["Date_1", "Date_2", "Date_3", "Date_4", "Date_5", "Date_6"],
        "Subject_Label": [
            "Subject_1", "Subject_2", "Subject_3", "Subject_4", "Subject_5",
            "Subject_6"
        ],
        "CaseRes_Label": [
            "Resolution_1", "Resolution_2", "Resolution_3", "Resolution_4",
            "Resolution_5", "Resolution_6"
        ],
        "T3": ["T3_1", "T3_2", "T3_3", "T3_4", "T3_5", "T3_6"],
        "Link": ["Link_1", "Link_2", "Link_3", "Link_4", "Link_5", "Link_6"]
    }
    # repEmails = get_emails()
    sentListOut = []
    env_count = 0
    # loop through each rep
    for key, val in repReports.items():
        if key != "Bug Backlog" and val[
                'MgrEmail'] != 'n/a':  # '*****@*****.**':  # and val['Email'].lower() == '*****@*****.**':
            # create an envelope to be signed
            envelope_definition = docusign.EnvelopeDefinition()
            if val['MgrEmail'] == '*****@*****.**' or val['Email'].lower() \
                    in ("*****@*****.**","*****@*****.**","*****@*****.**"):
                envelope_definition.email_subject = 'Tier 3 case escalation feedback - ' \
                                                    'here\'s what happened with your recent previously owned cases'
                envelope_definition.email_blurb = 'Hello ' + key.split(' ')[
                    0] + ', \n\nI\'m sending these out to you tier 3 reps as well now so if another tier 3 or dev ' \
                         'support takes on your cases we can close the loop on these as well. \n\nFeel free to message ' \
                         'me for any suggestions on how to make this program even better. \n\nThanks for reading,' \
                         '\n\nKevin\'s Autofeedbacker bot'
            else:
                envelope_definition.email_subject = 'Tier 3 case escalation feedback - here\'s what happened with ' \
                                                    'your recent escalated cases'
                envelope_definition.email_blurb = 'Hello ' + key.split(' ')[
                    0] + ', \n\nWe\'re starting a new program intended to provide you with a followup on how the cases ' \
                         'you escalated to tier 3 were resolved. The purpose of this is to learn from these cases, ' \
                         'we know you\'re too busy to check up on all of those so we\'re making it easy with these ' \
                         'weekly reports. If you\'re missing any cases we may still be working on them so stay tuned. ' \
                         'Feel free to reach out to the tier 3 rep who closed these cases for more details on what ' \
                         'they did. \n\nFeel free to message Kevin Alber for any suggestions on how to make this ' \
                         'program even better. \n\nThanks for reading,\n\nKevin\'s Autofeedbacker bot'

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

            # create manager email notification, need to test

            mgr_emailNotification = docusign.RecipientEmailNotification()
            mgr_emailNotification.email_subject = 'Tier 3 case escalation feedback - here\'s what happened with ' + \
                                                  key.split(' ')[0] + '\'s recent escalated cases'
            mgr_emailNotification.email_body = 'Hello ' + val['MgrEmail'].split('.')[
                0].title() + ', \n\n We\'re starting a new program intended to provide your reps with feedback on cases ' \
                             'that they escalated to tier 3 so they can learn from them and you can better coach them. ' \
                             'Please let me, Kevin Alber, know if you have any feedback about this process. \n\nThanks ' \
                             'for reading,\n\nKevin\'s Autofeedbacker bot'

            # create a template role with a valid template_id and role_name and assign signer info
            t_role = docusign.TemplateRole()
            t_role.role_name = template_role_name
            t_role.name = key
            if test_mode == 1:
                t_role.email = '*****@*****.**'  # for real send
            else:
                t_role.email = val['Email']
                print("Envelope going to rep: " + val['Email'])

            # mgr role on template
            t_role_cc = docusign.TemplateRole()
            t_role_cc.role_name = template_role_cc
            t_role_cc.name = val['MgrEmail'].split('@')[0].replace(
                '.', ' ').title()  # might want to just add this to spreadsheet
            if test_mode == 1 or val[
                    'MgrEmail'] == '*****@*****.**':
                t_role_cc.email = '*****@*****.**'  #
            else:
                t_role_cc.email = val['MgrEmail']
            t_role_cc.email_notification = mgr_emailNotification

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

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

            # notif = Notification()
            # notif.use_account_defaults = "True"

            # envelope_definition.notification = notif
            auth_api = AuthenticationApi()
            envelopes_api = EnvelopesApi()

            # create draft
            try:
                login_info = auth_api.login(
                    api_password='******', include_account_id_guid='true')  ###
                assert login_info is not None
                assert len(login_info.login_accounts) > 0
                login_accounts = login_info.login_accounts
                assert login_accounts[0].account_id is not None

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

                envelope_summary = envelopes_api.create_envelope(
                    login_accounts[0].account_id,
                    envelope_definition=envelope_definition)
                assert envelope_summary is not None
                assert envelope_summary.envelope_id is not None
                assert envelope_summary.status == 'created'
                env_count += 1
                # print("Envelope Created Summary: ", end="")
                # pprint(envelope_summary)
            except ApiException as e:
                print("\nException when calling DocuSign API: %s" % e)
                assert e is None  # make the test case fail in case of an API exception

            # get array of tab objects on the current envelope
            tab_array = envelopes_api.get_page_tabs(
                login_accounts[0].account_id, 1, envelope_summary.envelope_id,
                1).text_tabs

            # iterate through each case as row in envelope
            row = 0
            tab_list = []
            for v in val['Cases']:
                if row < 6:
                    label = 'CaseNum_Label'
                    target_tab = next(
                        (x for x in tab_array
                         if x.tab_label == data_labels[label][row]), None)
                    assert target_tab is not None
                    t_col1 = docusign.Text()
                    t_col1.tab_label = data_labels[label][row - 1]
                    t_col1.value = str(v['CaseNumber'])
                    t_col1.tab_id = target_tab.tab_id
                    t_col1.documentId = "1"
                    t_col1.recipientId = "1"
                    t_col1.pageNumber = 1
                    tab_list.append(t_col1)
                    # print(str(v['CaseNumber']))
                    sentListOut.append(v['CaseNumber'])

                    label = 'DateEsc_Label'
                    target_tab = next(
                        (x for x in tab_array
                         if x.tab_label == data_labels[label][row]), None)
                    assert target_tab is not None
                    t_col2 = docusign.Text()
                    t_col2.tab_label = data_labels[label][row]
                    t_col2.value = v['DateEscalated']
                    t_col2.tab_id = target_tab.tab_id
                    t_col2.documentId = "1"
                    t_col2.recipientId = "1"
                    t_col2.pageNumber = 1
                    tab_list.append(t_col2)

                    # subMaxChar = charLimit(19, 10, v['Subject'])
                    if len(v['Subject']) > 160:
                        extra = '...'
                    else:
                        extra = ''

                    label = 'Subject_Label'
                    target_tab = next(
                        (x for x in tab_array
                         if x.tab_label == data_labels[label][row]), None)
                    assert target_tab is not None
                    t_col3 = docusign.Text()
                    t_col3.tab_label = data_labels[label][row]
                    t_col3.disable_auto_size = 'True'
                    t_col3.height = '200'
                    t_col3.value = v['Subject'][:160] + extra
                    t_col3.tab_id = target_tab.tab_id
                    t_col3.documentId = "1"
                    t_col3.recipientId = "1"
                    t_col3.pageNumber = 1
                    tab_list.append(t_col3)

                    if len(v['CaseResolution']) > 184:
                        extra = '...'
                    else:
                        extra = ''

                    label = 'CaseRes_Label'
                    target_tab = next(
                        (x for x in tab_array
                         if x.tab_label == data_labels[label][row]), None)
                    assert target_tab is not None
                    t_col4 = docusign.Text()
                    t_col4.tab_label = data_labels[label][row]
                    t_col4.disable_auto_size = 'True'
                    t_col4.height = '200'
                    t_col4.value = v['CaseResolution'][:184] + extra
                    t_col4.tab_id = target_tab.tab_id
                    t_col4.documentId = "1"
                    t_col4.recipientId = "1"
                    t_col4.pageNumber = 1
                    tab_list.append(t_col4)

                    label = 'T3'
                    target_tab = next(
                        (x for x in tab_array
                         if x.tab_label == data_labels[label][row]), None)
                    assert target_tab is not None
                    t_col5 = docusign.Text()
                    t_col5.tab_label = data_labels[label][row]
                    t_col5.value = v['T3RepName']
                    t_col5.tab_id = target_tab.tab_id
                    t_col5.documentId = "1"
                    t_col5.recipientId = "1"
                    t_col5.pageNumber = 1
                    tab_list.append(t_col5)

                    label = 'Link'
                    target_tab = next(
                        (x for x in tab_array
                         if x.tab_label == data_labels[label][row]), None)
                    assert target_tab is not None
                    t_col6 = docusign.Text()
                    t_col6.tab_label = "#HREF_" + data_labels[label][row]
                    t_col6.name = v['link']
                    t_col6.value = 'Go to Case'
                    t_col6.tab_id = target_tab.tab_id
                    t_col6.documentId = "1"
                    t_col6.recipientId = "1"
                    t_col6.pageNumber = 1
                    tab_list.append(t_col6)

                    row += 1
                else:
                    print("We're over 6 cases for rep" + val['Email'] +
                          ", dropped case " + str(v['CaseNumber']))

            # now update those tabs using my list of tab definitions, then update status to sent
            tabs = docusign.Tabs()
            tabs.text_tabs = tab_list
            envelopes_api.update_tabs(login_accounts[0].account_id,
                                      envelope_summary.envelope_id,
                                      1,
                                      tabs=tabs)
            envelope_definition.status = 'sent'
            envelope_summary2 = envelopes_api.update(
                login_accounts[0].account_id,
                envelope_summary.envelope_id,
                envelope=envelope_definition)
            if test_mode != 1:
                updateSentList(sentListOut)

            # print("Sent: " +str(key)+ " envId: " + ) # + "EnvelopeSummary: ", end="")
            # pprint(envelope_summary2)
    print("Count: " + str(env_count))
Пример #6
0
# create a template role with a valid template_id and role_name and assign signer info
t_role = docusign.TemplateRole()
t_role.role_name = template_role_name
t_role.name = 'Smitty Developer'
t_role.email = "*****@*****.**"

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'

text_tab = docusign.Text()
text_tab.tab_label = "Basic"
text_tab.value = "Fire Goodwill Message"

number_tab = docusign.Number()
number_tab.tab_label = "MonitorPay"
number_tab.value = 5.99

tabs = docusign.Tabs()
# tabs.sign_here_tabs = [sign_here]
tabs.text_tabs = [text_tab]
tabs.number_tabs = [number_tab]
t_role.tabs = tabs

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