Ejemplo n.º 1
0
 def get(self, request, envelope_id):
     envelopes_api = EnvelopesApi(get_api_client())
     context = {
         'envelope_recipients': envelopes_api.list_recipients(ACCOUNT_ID, envelope_id),
         'envelope': envelopes_api.get_envelope(ACCOUNT_ID, envelope_id)
     }
     return render(request, 'envelopes/envelope_detail.html', context=context)
Ejemplo n.º 2
0
    def determine_is_signed(self, envelope_id):
        """
        Queries docusign for a particular envelope to see if the user signed it or not
        :param envelope_id: (String) -> The envelope_id of the document that is being checked
        :return: (boolean) -> True: The document is signed
                              False: The document is not signed or error
        """

        # Initialize the envelope api
        envelopes_api = EnvelopesApi()

        try:
            # Queries docusign for the envelope and checks the status of the document
            #   if it is completed, then it is signed, otherwise it still hasn't been signed
            if envelopes_api.list_recipients(
                    self.account_id,
                    envelope_id).signers[0].status == 'completed':
                return True
            else:
                return False

        except ApiException as e:
            logger.error(
                "\nException in {0} when calling DocuSign API: {1}".format(
                    DocusignWrapper.determine_is_signed.__name__, e))
            return False
Ejemplo n.º 3
0
    def worker(args):
        """
        1. Call the envelope recipients list 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)
        # 1. Call the envelope recipients list method
        results = envelope_api.list_recipients(account_id=args["account_id"], envelope_id=args["envelope_id"])

        return results
Ejemplo n.º 4
0
    def get(self, request, *args, **kwargs):
        api_client = get_api_client()
        bulk_envelopes_api = BulkEnvelopesApi(api_client)
        recipient_1 = BulkSendingCopyRecipient(role_name='signer', name='Aaqib 1', email='*****@*****.**')
        recipient_2 = BulkSendingCopyRecipient(role_name='signer', name='Aaqib 2', email='*****@*****.**')
        bulk_copies = [
            BulkSendingCopy(recipients=[recipient_1], custom_fields=[]),
            BulkSendingCopy(recipients=[recipient_2], custom_fields=[]),
        ]
        bulk_sending_list = BulkSendingList(name='employee_contract', bulk_copies=bulk_copies)
        bulk_list = bulk_envelopes_api.create_bulk_send_list(ACCOUNT_ID, bulk_sending_list=bulk_sending_list)
        bulk_list_id = bulk_list.list_id

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

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

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

        time.sleep(10)
        from_date = (datetime.utcnow() - timedelta(seconds=60)).isoformat()
        envelopes = envelopes_api.list_status_changes(ACCOUNT_ID, status='sent', from_date=from_date).envelopes
        for envelope in envelopes:
            env, created = SigEnvelope.objects.get_or_create(envelope_id=envelope.envelope_id)
            if created:
                sign_request = SignRequest.objects.create(envelope=env, status_date_time=envelope.status_date_time)
                recipients = envelopes_api.list_recipients(ACCOUNT_ID, envelope.envelope_id)
                Recipient.objects.create(sign_request=sign_request, email=recipients.signers[0].email,
                                         recipient_id=recipients.signers[0].recipient_id)
        return redirect('esign:envelope_list')
Ejemplo n.º 5
0
    def list_documents(self, envelope_id):
        """
        Just prints out all the information associated with an envelope on docusign
        :param envelope_id: (string) -> The envelope_id for the envelope that is desired
        """

        # Initializes the envelope
        envelopes_api = EnvelopesApi()

        try:
            # Lists recipients of an envelope and you can check whether or not it has been signed
            print(envelopes_api.list_recipients(self.account_id, envelope_id))

        except ApiException as e:
            logger.error(
                "\nException in {0} when calling DocuSign API: {1}".format(
                    DocusignWrapper.list_documents.__name__, e))
            assert e is None  # make the test case fail in case of an API exception
Ejemplo n.º 6
0
    def testListTabs(self):
        # For this the template Role should be manager
        template_role_name = 'Manager'

        # 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.'

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

        # create a template role with a valid templateId and roleName and assign signer info
        role_name = template_role_name
        name = 'Pat Developer'
        email = Username
        t_role = docusign.TemplateRole(role_name=role_name,
                                       name=name,
                                       email=email)

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

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

        # create the envelope definition with the properties set
        envelope_definition = docusign.EnvelopeDefinition(
            email_subject=email_subject,
            email_blurb=email_blurb,
            template_id=template_id,
            template_roles=template_roles,
            status=status)
        try:
            envelopes_api = EnvelopesApi()

            # Create Envelope with the new role
            envelope_summary = envelopes_api.create_envelope(
                self.user_info.accounts[0].account_id,
                envelope_definition=envelope_definition)
            # Read the new Envelope
            created_envelope = envelopes_api.get_envelope(
                account_id=self.user_info.accounts[0].account_id,
                envelope_id=envelope_summary.envelope_id)

            recipients = envelopes_api.list_recipients(
                account_id=self.user_info.accounts[0].account_id,
                envelope_id=created_envelope.envelope_id)

            tabs = envelopes_api.list_tabs(
                account_id=self.user_info.accounts[0].account_id,
                envelope_id=created_envelope.envelope_id,
                recipient_id=recipients.signers[0].recipient_id)
            list_tabs = tabs.list_tabs

            assert list_tabs is not None

        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
        except Exception 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