Ejemplo n.º 1
0
    def list(self):
        self.check_token()

        envelope_api = EnvelopesApi(ListEnvelopes.api_client)
        from_date = (datetime.now() + timedelta(days=-30)).strftime("%Y/%m/%d")
        return envelope_api.list_status_changes(ListEnvelopes.accountID,
                                                from_date=from_date)
Ejemplo n.º 2
0
 def get(self, request, *args, **kwargs):
     envelopes_api = EnvelopesApi(get_api_client())
     context = {}
     from_date = (datetime.utcnow() - timedelta(days=60)).isoformat()
     # retrieve all envelopes of last 2 months
     context['envelope_list'] = envelopes_api.list_status_changes(ACCOUNT_ID, status='sent, delivered',
                                                                  from_date=from_date).envelopes
     return render(request, 'envelopes/envelope_list.html', context=context)
Ejemplo n.º 3
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.º 4
0
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
Ejemplo n.º 5
0
 def list(cls, envelope_args, user_documents):
     """Get status changes for one or more envelopes
     Parameters:
         envelope_args (dict): Document parameters
         user_documents (list): Documents signed by user
     Returns:
         EnvelopesInformation
     """
     ds_client = DsClient.get_instance()
     envelope_api = EnvelopesApi(ds_client.api_client)
     envelopes_info = envelope_api.list_status_changes(
         ds_client.account_id,
         from_date=envelope_args['from_date'],
         include='recipients'
     )
     if not envelopes_info.envelopes:
         return []
     results = [env.to_dict() for env in envelopes_info.envelopes
                if env.envelope_id in user_documents]
     return results
Ejemplo n.º 6
0
    def worker(args):
        """
        1. Call the envelope status change method to list the envelopes
           that have changed in the last 10 days
        """
        # 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)

        # The Envelopes::listStatusChanges method has many options
        # See https://developers.docusign.com/esign-rest-api/reference/Envelopes/Envelopes/listStatusChanges

        # The list status changes call requires at least a from_date OR
        # a set of envelopeIds. Here we filter using a from_date.
        # Here we set the from_date to filter envelopes for the last month
        # Use ISO 8601 date format
        # 1. Call the envelope status change method to list the envelopes
        from_date = (datetime.utcnow() - timedelta(days=30)).isoformat()
        results = envelope_api.list_status_changes(account_id=args["account_id"], from_date=from_date)

        return results
Ejemplo n.º 7
0
    def list(envelope_args, user_documents, session):
        """Get status changes for one or more envelopes
        Parameters:
            envelope_args (dict): document parameters
            user_documents (list): documents signed by user
        Returns:
            EnvelopesInformation
        """
        access_token = session.get('access_token')
        account_id = session.get('account_id')

        ds_client = DsClient.get_configured_instance(access_token)
        envelope_api = EnvelopesApi(ds_client)
        envelopes_info = envelope_api.list_status_changes(
            account_id,
            from_date=envelope_args['from_date'],
            include='recipients'
        )
        if not envelopes_info.envelopes:
            return []
        results = [env.to_dict() for env in envelopes_info.envelopes
                   if env.envelope_id in user_documents]
        return results