forked from docusign/code-examples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.py
More file actions
41 lines (32 loc) · 1.51 KB
/
controller.py
File metadata and controls
41 lines (32 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from datetime import datetime, timedelta
from docusign_esign import EnvelopesApi
from flask import session
from ....docusign import create_api_client
class Eg003Controller:
@staticmethod
def get_args():
"""Get request and session arguments"""
return {
"account_id": session["ds_account_id"],
"base_path": session["ds_base_path"],
"access_token": session["ds_access_token"],
}
@staticmethod
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