forked from docusign/code-examples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.py
45 lines (37 loc) · 1.49 KB
/
controller.py
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
42
43
44
45
from docusign_esign import AccountsApi, PermissionProfile
from flask import session, request
from ....consts import settings
from ....docusign import create_api_client
class Eg024Controller:
@staticmethod
def get_args():
"""Get required session and request arguments"""
args = {
"account_id": session["ds_account_id"], # represent your {ACCOUNT_ID}
"base_path": session["ds_base_path"],
"access_token": session["ds_access_token"], # represent your {ACCESS_TOKEN}
"permission_profile_name": request.form.get("permission_profile_name"),
"settings": settings
}
return args
@staticmethod
def worker(args):
"""
1. Create an api client
2. Create a permission profile object
3. Create the permission profile using the SDK
"""
# Step 2. Construct your API request headers
api_client = create_api_client(base_path=args["base_path"], access_token=args["access_token"])
# Step 3. Construct your request body
permission_profile = PermissionProfile(
permission_profile_name=args["permission_profile_name"],
settings=args["settings"]
)
# Step 4. Call the eSignature REST API
account_api = AccountsApi(api_client)
response = account_api.create_permission_profile(
account_id=args["account_id"],
permission_profile=permission_profile
)
return response