From 7b170057b6b6b2e5531a436e8f7cb3c4358047b8 Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Thu, 24 Dec 2020 17:32:08 +0200 Subject: [PATCH 01/17] added CreateFormGroup API --- app/__init__.py | 1 + app/docusign/ds_client.py | 2 +- app/rooms/examples/__init__.py | 1 + .../eg007_create_form_group/__init__.py | 1 + .../eg007_create_form_group/controller.py | 38 ++++++++++++ .../examples/eg007_create_form_group/views.py | 59 +++++++++++++++++++ .../templates/eg007_create_form_group.html | 23 ++++++++ app/rooms/templates/home_rooms.html | 5 ++ requirements.txt | 3 +- 9 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 app/rooms/examples/eg007_create_form_group/__init__.py create mode 100644 app/rooms/examples/eg007_create_form_group/controller.py create mode 100644 app/rooms/examples/eg007_create_form_group/views.py create mode 100644 app/rooms/templates/eg007_create_form_group.html diff --git a/app/__init__.py b/app/__init__.py index 35e07044..786d6353 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -40,6 +40,7 @@ app.register_blueprint(rooms_examples.eg004) app.register_blueprint(rooms_examples.eg005) app.register_blueprint(rooms_examples.eg006) + app.register_blueprint(rooms_examples.eg007) else: app.register_blueprint(examples.eg001) app.register_blueprint(examples.eg002) diff --git a/app/docusign/ds_client.py b/app/docusign/ds_client.py index b700b5ec..6dfe78e8 100644 --- a/app/docusign/ds_client.py +++ b/app/docusign/ds_client.py @@ -16,7 +16,7 @@ ] ROOMS_SCOPES = [ - "room_forms","dtr.rooms.read", "dtr.rooms.write", + "room_forms", "dtr.rooms.read", "dtr.rooms.write", "dtr.documents.read", "dtr.documents.write", "dtr.profile.read", "dtr.profile.write", "dtr.company.read", "dtr.company.write" ] diff --git a/app/rooms/examples/__init__.py b/app/rooms/examples/__init__.py index c276a55a..65871b06 100644 --- a/app/rooms/examples/__init__.py +++ b/app/rooms/examples/__init__.py @@ -4,3 +4,4 @@ from .eg004_add_forms_to_room import eg004 from .eg005_get_rooms_with_filters import eg005 from .eg006_create_external_form_fill_session import eg006 +from .eg007_create_form_group import eg007 diff --git a/app/rooms/examples/eg007_create_form_group/__init__.py b/app/rooms/examples/eg007_create_form_group/__init__.py new file mode 100644 index 00000000..0e6d362e --- /dev/null +++ b/app/rooms/examples/eg007_create_form_group/__init__.py @@ -0,0 +1 @@ +from .views import eg007 diff --git a/app/rooms/examples/eg007_create_form_group/controller.py b/app/rooms/examples/eg007_create_form_group/controller.py new file mode 100644 index 00000000..4d420f06 --- /dev/null +++ b/app/rooms/examples/eg007_create_form_group/controller.py @@ -0,0 +1,38 @@ +from flask import session, request + +from app.rooms import create_rooms_api_client +from docusign_rooms import FormGroupForCreate, FormGroupsApi + + +class Eg007Controller: + @staticmethod + def get_args(): + """Get required session and request arguments""" + return { + "account_id": session["ds_account_id"], + # Represents your {ACCOUNT_ID} + "access_token": session["ds_access_token"], + # Represents your {ACCESS_TOKEN} + "form_group_name": request.form.get("form_group_name"), + } + + @staticmethod + def worker(args): + """ + 1. Create an API client with headers + 2. Create FormGroupForCreate object + 3. POST the form using SDK + """ + + # Step 1. Create an API with headers + api_client = create_rooms_api_client(access_token=args['access_token']) + + # Step 2. Create FormGroupForCreate object + form = FormGroupForCreate(name=args['form_group_name']) + + # Step 3. Post the form object using SDK + form_group_api = FormGroupsApi(api_client) + response = form_group_api.create_form_group(body=form, + account_id=args['account_id']) + + return response diff --git a/app/rooms/examples/eg007_create_form_group/views.py b/app/rooms/examples/eg007_create_form_group/views.py new file mode 100644 index 00000000..48d9d226 --- /dev/null +++ b/app/rooms/examples/eg007_create_form_group/views.py @@ -0,0 +1,59 @@ +import json +from os import path + +from docusign_rooms.client.api_exception import ApiException +from flask import Blueprint, render_template, current_app + +from app.docusign import authenticate +from app.error_handlers import process_error +from app.rooms.examples.eg007_create_form_group.controller import ( + Eg007Controller, +) + +eg = "eg007" # reference (and URL) for this example +eg007 = Blueprint(eg, __name__) + + +@eg007.route("/eg007", methods=["POST"]) +@authenticate(eg=eg) +def create_form_group(): + """ + 1. Get required arguments + 2. Call the worker method + 3. Render the response + """ + + # 1. Get required arguments + args = Eg007Controller.get_args() + + try: + # 2. Call the worker method to create a new form group + results = Eg007Controller.worker(args) + form_id = results.form_id + current_app.logger.info( + f"""Form Group "{args['form_group_name']}" has been created! + Form Group ID: {form_id}""" + ) + except ApiException as err: + return process_error(err) + + # 3. Render the response + return render_template( + "example_done.html", + title="Creating a room with data", + h1="Creating a room with data", + message=f"""The room "{args['room_name']}" has been created!
+ Room ID: {form_id}.""", + json=json.dumps(json.dumps(results.to_dict(), default=str)) + ) + + +@eg007.route("/eg007", methods=["GET"]) +@authenticate(eg=eg) +def get_view(): + """responds with the form for the example""" + return render_template( + "eg007_create_form_group.html", + title='Creating a form group', + source_file=path.basename(path.dirname(__file__)) + "/controller.py" + ) diff --git a/app/rooms/templates/eg007_create_form_group.html b/app/rooms/templates/eg007_create_form_group.html new file mode 100644 index 00000000..617732f3 --- /dev/null +++ b/app/rooms/templates/eg007_create_form_group.html @@ -0,0 +1,23 @@ + {% extends "base.html" %} +{% block content %} +

1. Creating a form group

+

This example demonstrates creating a DocuSign Form Group.

+{% if show_doc %} +

Documentation about this example.

+{% endif %} + +

API methods used: + Rooms::CreateFormGroup +

+ +
+
+ + +
+ + +
+ +{% endblock %} \ No newline at end of file diff --git a/app/rooms/templates/home_rooms.html b/app/rooms/templates/home_rooms.html index 84531fad..494b8eb7 100644 --- a/app/rooms/templates/home_rooms.html +++ b/app/rooms/templates/home_rooms.html @@ -68,6 +68,11 @@

6. Creating an external form fill sessionRooms::GetDocuments and Forms::CreateExternalFormFillSession

+

7. Creating a form group

+

This example demonstrates how to create a form group.

+

API methods used: + Rooms::CreateFormGroup +

diff --git a/requirements.txt b/requirements.txt index 4893861b..e3629f6a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ chardet==3.0.4 Click==7.0 cryptography==3.2.1 docusign-esign==3.6.0 -docusign-rooms==1.0.0b1 +docusign-rooms==1.1.0rc1 Flask==1.1.1 Flask-OAuthlib flask-wtf==0.14.3 @@ -30,4 +30,5 @@ virtualenv==16.7.5 virtualenv-clone==0.5.3 Werkzeug==0.16.0 wrapt==1.11.2 +pyjwt==1.7.1 From 560e3995a99dec932024195455b850060f6cb56d Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Thu, 24 Dec 2020 19:00:14 +0200 Subject: [PATCH 02/17] fixed response output --- app/rooms/examples/eg007_create_form_group/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/rooms/examples/eg007_create_form_group/views.py b/app/rooms/examples/eg007_create_form_group/views.py index 48d9d226..cc1dc10e 100644 --- a/app/rooms/examples/eg007_create_form_group/views.py +++ b/app/rooms/examples/eg007_create_form_group/views.py @@ -29,7 +29,7 @@ def create_form_group(): try: # 2. Call the worker method to create a new form group results = Eg007Controller.worker(args) - form_id = results.form_id + form_id = results.form_group_id current_app.logger.info( f"""Form Group "{args['form_group_name']}" has been created! Form Group ID: {form_id}""" @@ -40,9 +40,9 @@ def create_form_group(): # 3. Render the response return render_template( "example_done.html", - title="Creating a room with data", - h1="Creating a room with data", - message=f"""The room "{args['room_name']}" has been created!
+ title="Creating a form group", + h1="Creating a form group", + message=f"""The Form Group "{args['form_group_name']}" has been created!
Room ID: {form_id}.""", json=json.dumps(json.dumps(results.to_dict(), default=str)) ) From 67d203a572c0fa740182eadae26a64f4e8de36f8 Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Mon, 28 Dec 2020 13:28:14 +0200 Subject: [PATCH 03/17] fix import and typo --- app/rooms/examples/eg007_create_form_group/controller.py | 6 +++--- app/rooms/examples/eg007_create_form_group/views.py | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/rooms/examples/eg007_create_form_group/controller.py b/app/rooms/examples/eg007_create_form_group/controller.py index 4d420f06..e8711d73 100644 --- a/app/rooms/examples/eg007_create_form_group/controller.py +++ b/app/rooms/examples/eg007_create_form_group/controller.py @@ -31,8 +31,8 @@ def worker(args): form = FormGroupForCreate(name=args['form_group_name']) # Step 3. Post the form object using SDK - form_group_api = FormGroupsApi(api_client) - response = form_group_api.create_form_group(body=form, - account_id=args['account_id']) + form_groups_api = FormGroupsApi(api_client) + response = form_groups_api.create_form_group(body=form, + account_id=args['account_id']) return response diff --git a/app/rooms/examples/eg007_create_form_group/views.py b/app/rooms/examples/eg007_create_form_group/views.py index cc1dc10e..746e5ad8 100644 --- a/app/rooms/examples/eg007_create_form_group/views.py +++ b/app/rooms/examples/eg007_create_form_group/views.py @@ -6,9 +6,7 @@ from app.docusign import authenticate from app.error_handlers import process_error -from app.rooms.examples.eg007_create_form_group.controller import ( - Eg007Controller, -) +from .controller import Eg007Controller eg = "eg007" # reference (and URL) for this example eg007 = Blueprint(eg, __name__) From 73d4002e5ea44a5ce62b3bfe88bd4706f94c34cb Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Mon, 28 Dec 2020 18:12:06 +0200 Subject: [PATCH 04/17] change quotes --- app/rooms/examples/eg007_create_form_group/controller.py | 6 +++--- app/rooms/examples/eg007_create_form_group/views.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/rooms/examples/eg007_create_form_group/controller.py b/app/rooms/examples/eg007_create_form_group/controller.py index e8711d73..0b359de0 100644 --- a/app/rooms/examples/eg007_create_form_group/controller.py +++ b/app/rooms/examples/eg007_create_form_group/controller.py @@ -25,14 +25,14 @@ def worker(args): """ # Step 1. Create an API with headers - api_client = create_rooms_api_client(access_token=args['access_token']) + api_client = create_rooms_api_client(access_token=args["access_token"]) # Step 2. Create FormGroupForCreate object - form = FormGroupForCreate(name=args['form_group_name']) + form = FormGroupForCreate(name=args["form_group_name"]) # Step 3. Post the form object using SDK form_groups_api = FormGroupsApi(api_client) response = form_groups_api.create_form_group(body=form, - account_id=args['account_id']) + account_id=args["account_id"]) return response diff --git a/app/rooms/examples/eg007_create_form_group/views.py b/app/rooms/examples/eg007_create_form_group/views.py index 746e5ad8..78193c77 100644 --- a/app/rooms/examples/eg007_create_form_group/views.py +++ b/app/rooms/examples/eg007_create_form_group/views.py @@ -52,6 +52,6 @@ def get_view(): """responds with the form for the example""" return render_template( "eg007_create_form_group.html", - title='Creating a form group', + title="Creating a form group", source_file=path.basename(path.dirname(__file__)) + "/controller.py" ) From 5785c0219b6e6c74df3abaa6ac3c55cc410fe083 Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Mon, 28 Dec 2020 13:26:06 +0200 Subject: [PATCH 05/17] added eg008 (grant access office to a form group) --- app/__init__.py | 1 + app/rooms/examples/__init__.py | 1 + .../__init__.py | 1 + .../controller.py | 79 +++++++++++++++++++ .../views.py | 64 +++++++++++++++ ...008_grant_office_access_to_form_group.html | 40 ++++++++++ app/rooms/templates/home_rooms.html | 7 ++ 7 files changed, 193 insertions(+) create mode 100644 app/rooms/examples/eg008_grant_office_access_to_form_group/__init__.py create mode 100644 app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py create mode 100644 app/rooms/examples/eg008_grant_office_access_to_form_group/views.py create mode 100644 app/rooms/templates/eg008_grant_office_access_to_form_group.html diff --git a/app/__init__.py b/app/__init__.py index 786d6353..8152b681 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -41,6 +41,7 @@ app.register_blueprint(rooms_examples.eg005) app.register_blueprint(rooms_examples.eg006) app.register_blueprint(rooms_examples.eg007) + app.register_blueprint(rooms_examples.eg008) else: app.register_blueprint(examples.eg001) app.register_blueprint(examples.eg002) diff --git a/app/rooms/examples/__init__.py b/app/rooms/examples/__init__.py index 65871b06..5101a48d 100644 --- a/app/rooms/examples/__init__.py +++ b/app/rooms/examples/__init__.py @@ -5,3 +5,4 @@ from .eg005_get_rooms_with_filters import eg005 from .eg006_create_external_form_fill_session import eg006 from .eg007_create_form_group import eg007 +from .eg008_grant_office_access_to_form_group import eg008 diff --git a/app/rooms/examples/eg008_grant_office_access_to_form_group/__init__.py b/app/rooms/examples/eg008_grant_office_access_to_form_group/__init__.py new file mode 100644 index 00000000..2111ed18 --- /dev/null +++ b/app/rooms/examples/eg008_grant_office_access_to_form_group/__init__.py @@ -0,0 +1 @@ +from .views import eg008 diff --git a/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py b/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py new file mode 100644 index 00000000..f73466e5 --- /dev/null +++ b/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py @@ -0,0 +1,79 @@ +from typing import List + +from docusign_rooms import ( + FormGroupsApi, + FormGroupSummary, + FormGroupSummaryList, + OfficeSummary, + OfficesApi, + OfficeSummaryList, +) +from flask import session, request + +from app.rooms import create_rooms_api_client + + +class Eg008Controller: + @staticmethod + def get_args() -> dict: + """Get required session and request arguments""" + return { + "account_id": session["ds_account_id"], + # Represents your {ACCOUNT_ID} + "access_token": session["ds_access_token"], + # Represents your {ACCESS_TOKEN} + "form_group_id": request.form.get("form_group_id"), + 'office_id': request.form.get('office_id') + } + + @staticmethod + def get_form_groups(args) -> List[FormGroupSummary]: + """ + 1. Create an API Client with headers + 2. GET Form Groups via FormGroupsAPI + """ + + # Step 1. Create an API with headers with headers + api_client = create_rooms_api_client(access_token=args['access_token']) + + # Step 2. GET Form Groups via FormGroupsAPI + form_groups_api = FormGroupsApi(api_client) + responses = form_groups_api.get_form_groups( + account_id=args['account_id']) # type: FormGroupSummaryList + + return responses.form_groups + + @staticmethod + def get_offices(args) -> List[OfficeSummary]: + """ + 1. Create an API Client with headers + 2. Get Offices via OfficesAPI + """ + + # Step 1. Create an API with headers with headers + api_client = create_rooms_api_client(args['access_token']) + + # Step 2. GET offices via OfficesAPI + offices_api = OfficesApi(api_client=api_client) + responses = offices_api.get_offices( + account_id=args['account_id']) # type: OfficeSummaryList + + return responses.office_summaries + + @staticmethod + def worker(args): + """ + + 1. Create an API client with headers + 2. Grant office access tp a form group via FormGroups API + """ + + # Step 1. Create an API client with headers + api_client = create_rooms_api_client(access_token=args['access_token']) + + # Step 2. Grant office access tp a form group via FormGroups API + form_groups_api = FormGroupsApi(api_client) + + form_groups_api.grant_office_access_to_form_group( + form_group_id=args['form_group_id'], office_id=args['office_id'], + account_id=args['account_id']) diff --git a/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py b/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py new file mode 100644 index 00000000..f9ce7bd4 --- /dev/null +++ b/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py @@ -0,0 +1,64 @@ +from docusign_rooms.client.api_exception import ApiException +from flask import Blueprint, render_template + +from app.docusign import authenticate +from app.error_handlers import process_error +from .controller import Eg008Controller + +eg = "eg008" # reference (and URL) for this example +eg008 = Blueprint(eg, __name__) + + +@eg008.route('/eg008', methods=['POST']) +@authenticate(eg=eg) +def assign_office_to_form_group(): + """ + 1. Get required arguments + 2. Call the worker method + 3. Render the response + """ + + args = Eg008Controller.get_args() + + try: + # 2. Call the worker method to assign office to form group + Eg008Controller.worker(args) + except ApiException as err: + return process_error(err) + + # 3. Render the response + + return render_template( + "example_done.html", + title="Assign office to a form group", + h1="Assign office to a form group", + message=f"""Office "{args['office_id']}" has been assigned to + Form Group "{args['form_group_id']}" """, + ) + + +@eg008.route('/eg008', methods=['GET']) +@authenticate(eg=eg) +def get_view(): + """ + 1. Get required arguments + 2. Get Form Groups + 3. Get Offices + 4. Render the response + """ + + # 1. Get required arguments + args = Eg008Controller.get_args() + + # 2. Get Form Groups + form_groups = Eg008Controller.get_form_groups(args) + + # 3. Get offices + offices = Eg008Controller.get_offices(args) + + # 4. Render the response + return render_template( + "eg008_grant_office_access_to_form_group.html", + offices=offices, + form_groups=form_groups + ) diff --git a/app/rooms/templates/eg008_grant_office_access_to_form_group.html b/app/rooms/templates/eg008_grant_office_access_to_form_group.html new file mode 100644 index 00000000..3c56eb9a --- /dev/null +++ b/app/rooms/templates/eg008_grant_office_access_to_form_group.html @@ -0,0 +1,40 @@ + {% extends "base.html" %} +{% block content %} + +

8. Grant office access to a form group

+

This example demonstrates how to grant Office access to a Form Group.

+ +{% if show_doc %} +

Documentation about this example.

+{% endif %} + +

API methods used: + Rooms::AccessFormGroup, + FormGroups::GetFormGroups and + Offices::GetOffices +

+ +
+ {% if form_groups %} +
+ + + + +
+ + + {% else %} +

Problem: please first create a form_group using example 7 +
Thank you.

+ {% endif %} +
+{% endblock %} diff --git a/app/rooms/templates/home_rooms.html b/app/rooms/templates/home_rooms.html index 494b8eb7..8c5cf219 100644 --- a/app/rooms/templates/home_rooms.html +++ b/app/rooms/templates/home_rooms.html @@ -73,6 +73,13 @@

7. Creating a form group

API methods used: Rooms::CreateFormGroup

+

8. Grant office access to a form group

+

This example demonstrates how to grant office access to a form group.

+

API methods used: + Rooms::AccessFormGroup, + FormGroups::GetFormGroups and + Offices::GetOffices +

From b7c5fd0d002c5875b2921b7469143cbb0b1d3f7e Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Mon, 28 Dec 2020 18:10:49 +0200 Subject: [PATCH 06/17] fix typo and change quotes --- .../controller.py | 18 +++++++++--------- .../views.py | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py b/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py index f73466e5..e30ea2f7 100644 --- a/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py +++ b/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py @@ -23,7 +23,7 @@ def get_args() -> dict: "access_token": session["ds_access_token"], # Represents your {ACCESS_TOKEN} "form_group_id": request.form.get("form_group_id"), - 'office_id': request.form.get('office_id') + "office_id": request.form.get("office_id") } @staticmethod @@ -34,12 +34,12 @@ def get_form_groups(args) -> List[FormGroupSummary]: """ # Step 1. Create an API with headers with headers - api_client = create_rooms_api_client(access_token=args['access_token']) + api_client = create_rooms_api_client(access_token=args["access_token"]) # Step 2. GET Form Groups via FormGroupsAPI form_groups_api = FormGroupsApi(api_client) responses = form_groups_api.get_form_groups( - account_id=args['account_id']) # type: FormGroupSummaryList + account_id=args["account_id"]) # type: FormGroupSummaryList return responses.form_groups @@ -51,12 +51,12 @@ def get_offices(args) -> List[OfficeSummary]: """ # Step 1. Create an API with headers with headers - api_client = create_rooms_api_client(args['access_token']) + api_client = create_rooms_api_client(args["access_token"]) # Step 2. GET offices via OfficesAPI offices_api = OfficesApi(api_client=api_client) responses = offices_api.get_offices( - account_id=args['account_id']) # type: OfficeSummaryList + account_id=args["account_id"]) # type: OfficeSummaryList return responses.office_summaries @@ -69,11 +69,11 @@ def worker(args): """ # Step 1. Create an API client with headers - api_client = create_rooms_api_client(access_token=args['access_token']) + api_client = create_rooms_api_client(access_token=args["access_token"]) - # Step 2. Grant office access tp a form group via FormGroups API + # Step 2. Grant office access to a form group via FormGroups API form_groups_api = FormGroupsApi(api_client) form_groups_api.grant_office_access_to_form_group( - form_group_id=args['form_group_id'], office_id=args['office_id'], - account_id=args['account_id']) + form_group_id=args["form_group_id"], office_id=args["office_id"], + account_id=args["account_id"]) diff --git a/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py b/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py index f9ce7bd4..06e2cdf3 100644 --- a/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py +++ b/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py @@ -9,7 +9,7 @@ eg008 = Blueprint(eg, __name__) -@eg008.route('/eg008', methods=['POST']) +@eg008.route("/eg008", methods=["POST"]) @authenticate(eg=eg) def assign_office_to_form_group(): """ @@ -37,7 +37,7 @@ def assign_office_to_form_group(): ) -@eg008.route('/eg008', methods=['GET']) +@eg008.route("/eg008", methods=["GET"]) @authenticate(eg=eg) def get_view(): """ From dbf77c802a9c323e5d352a253c0f578de4358cb2 Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Mon, 28 Dec 2020 18:06:56 +0200 Subject: [PATCH 07/17] added eg009 assign a form to a form group --- app/__init__.py | 1 + app/rooms/examples/__init__.py | 1 + .../__init__.py | 1 + .../controller.py | 94 +++++++++++++++++++ .../eg009_assign_form_to_form_group/views.py | 71 ++++++++++++++ .../eg009_assign_form_to_form_group.html | 40 ++++++++ app/rooms/templates/home_rooms.html | 9 ++ 7 files changed, 217 insertions(+) create mode 100644 app/rooms/examples/eg009_assign_form_to_form_group/__init__.py create mode 100644 app/rooms/examples/eg009_assign_form_to_form_group/controller.py create mode 100644 app/rooms/examples/eg009_assign_form_to_form_group/views.py create mode 100644 app/rooms/templates/eg009_assign_form_to_form_group.html diff --git a/app/__init__.py b/app/__init__.py index 8152b681..39006ee7 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -42,6 +42,7 @@ app.register_blueprint(rooms_examples.eg006) app.register_blueprint(rooms_examples.eg007) app.register_blueprint(rooms_examples.eg008) + app.register_blueprint(rooms_examples.eg009) else: app.register_blueprint(examples.eg001) app.register_blueprint(examples.eg002) diff --git a/app/rooms/examples/__init__.py b/app/rooms/examples/__init__.py index 5101a48d..c9ebaf61 100644 --- a/app/rooms/examples/__init__.py +++ b/app/rooms/examples/__init__.py @@ -6,3 +6,4 @@ from .eg006_create_external_form_fill_session import eg006 from .eg007_create_form_group import eg007 from .eg008_grant_office_access_to_form_group import eg008 +from .eg009_assign_form_to_form_group import eg009 diff --git a/app/rooms/examples/eg009_assign_form_to_form_group/__init__.py b/app/rooms/examples/eg009_assign_form_to_form_group/__init__.py new file mode 100644 index 00000000..4467780d --- /dev/null +++ b/app/rooms/examples/eg009_assign_form_to_form_group/__init__.py @@ -0,0 +1 @@ +from .views import eg009 diff --git a/app/rooms/examples/eg009_assign_form_to_form_group/controller.py b/app/rooms/examples/eg009_assign_form_to_form_group/controller.py new file mode 100644 index 00000000..829f7117 --- /dev/null +++ b/app/rooms/examples/eg009_assign_form_to_form_group/controller.py @@ -0,0 +1,94 @@ +from typing import List + +from docusign_rooms import ( + FormGroupSummary, + FormGroupsApi, + FormGroupSummaryList, + FormLibrariesApi, + FormGroupFormToAssign, + FormSummary, +) +from docusign_rooms import FormSummaryList +from flask import session, request + +from app.rooms import create_rooms_api_client + + +class Eg009Controller: + @staticmethod + def get_args() -> dict: + """Get required session and request arguments""" + return { + "account_id": session["ds_account_id"], + # Represents your {ACCOUNT_ID} + "access_token": session["ds_access_token"], + # Represents your {ACCESS_TOKEN} + "form_group_id": request.form.get("form_group_id"), + 'form_id': request.form.get('form_id') + } + + @staticmethod + def get_form_groups(args) -> List[FormGroupSummary]: + """ + 1. Create an API Client with headers + 2. GET Form Groups via FormGroupsAPI + """ + + # Step 1. Create an API with headers with headers + api_client = create_rooms_api_client(access_token=args['access_token']) + + # Step 2. GET Form Groups via FormGroupsAPI + form_groups_api = FormGroupsApi(api_client) + responses = form_groups_api.get_form_groups( + account_id=args['account_id']) # type: FormGroupSummaryList + + return responses.form_groups + + @staticmethod + def get_forms(args) -> List[FormSummary]: + """ + 1. Create an API client with headers + 2. Get first form library id + 3. Get forms + """ + + # Step 1. Create an API client with headers + api_client = create_rooms_api_client(access_token=args["access_token"]) + + # Step 2. Get first form library id + form_libraries_api = FormLibrariesApi(api_client) + form_libraries = form_libraries_api.get_form_libraries( + account_id=args["account_id"]) + + first_form_library_id = form_libraries.forms_library_summaries[0].forms_library_id + + # Step 3. Get forms + form_library_forms = form_libraries_api.get_form_library_forms( + form_library_id=first_form_library_id, + account_id=args["account_id"] + ) # type: FormSummaryList + + return form_library_forms.forms + + @staticmethod + def worker(args) -> FormGroupFormToAssign: + """ + 1. Create an API Client with headers + 2. Create FormGroupFormToAssign Object + 3. Assign form to a form group via FormGroups API + """ + + # Step 1. Create an API client with headers + api_client = create_rooms_api_client(access_token=args['access_token']) + form_groups_api = FormGroupsApi(api_client) + + # Step 2. Create FormGroupFormToAssign Object + form_group_to_assign = FormGroupFormToAssign(form_id=args["form_id"]) + + # Step 3. Grant office access tp a form group via FormGroups API + response = form_groups_api.assign_form_group_form( + form_group_id=args['form_group_id'], account_id=args['account_id'], + body=form_group_to_assign + ) # type: FormGroupFormToAssign + + return response diff --git a/app/rooms/examples/eg009_assign_form_to_form_group/views.py b/app/rooms/examples/eg009_assign_form_to_form_group/views.py new file mode 100644 index 00000000..19b2d494 --- /dev/null +++ b/app/rooms/examples/eg009_assign_form_to_form_group/views.py @@ -0,0 +1,71 @@ +import json + +from docusign_rooms.client.api_exception import ApiException +from flask import Blueprint, render_template, current_app + +from app.docusign import authenticate +from app.error_handlers import process_error +from .controller import Eg009Controller + +eg = "eg009" # reference (and URL) for this example +eg009 = Blueprint(eg, __name__) + + +@eg009.route("/eg009", methods=['POST']) +@authenticate(eg=eg) +def assign_form_to_form_group(): + """ + 1. Get required arguments + 2. Call the worker method + 3. Render the response + """ + + # 1. Get required arguments + args = Eg009Controller.get_args() + + try: + # 2. Call the worker method to create a new form group + results = Eg009Controller.worker(args) + current_app.logger.info( + f"""Form "{args['form_id']}" has been assigned to + Form Group "{args['form_group_id']}"!""" + ) + except ApiException as err: + return process_error(err) + + # 3. Render the response + return render_template( + "example_done.html", + title="Assigning form a form group", + h1="Creating a form group", + message=f"""Form "{args['form_id']}" has been assigned to + Form Group "{args['form_group_id']}"!""", + json=json.dumps(json.dumps(results.to_dict(), default=str)) + ) + + +@eg009.route("/eg009", methods=['GET']) +@authenticate(eg=eg) +def get_view(): + """ + 1. Get required arguments + 2. Get form groups + 3. Get forms + 4. Render the response + """ + + # 1. Get required arguments + args = Eg009Controller.get_args() + + # 2. get form groups + form_groups = Eg009Controller.get_form_groups(args) + + # 3. get forms + forms = Eg009Controller.get_forms(args) + + # 4. Render the response + return render_template( + "eg009_assign_form_to_form_group.html", + forms=forms, + form_groups=form_groups + ) diff --git a/app/rooms/templates/eg009_assign_form_to_form_group.html b/app/rooms/templates/eg009_assign_form_to_form_group.html new file mode 100644 index 00000000..058cfd76 --- /dev/null +++ b/app/rooms/templates/eg009_assign_form_to_form_group.html @@ -0,0 +1,40 @@ + {% extends "base.html" %} +{% block content %} + +

9. Assign a form to a form group

+

This example demonstrates how to assign form to a form group.

+ +{% if show_doc %} +

Documentation about this example.

+{% endif %} + +

API methods used: + Rooms::AssignFormGroup, + FormGroups::GetFormGroups and + FormLibraries:GetFormLibraries +

+ +
+ {% if form_groups %} +
+ + + + +
+ + + {% else %} +

Problem: please first create a form_group using example 7 +
Thank you.

+ {% endif %} +
+{% endblock %} diff --git a/app/rooms/templates/home_rooms.html b/app/rooms/templates/home_rooms.html index 8c5cf219..1c617a47 100644 --- a/app/rooms/templates/home_rooms.html +++ b/app/rooms/templates/home_rooms.html @@ -80,7 +80,16 @@

8. Grant office access to a form groupFormGroups::GetFormGroups and Offices::GetOffices

+

9. Assign form to a form group

+

This example demonstrates how to assign form to a from group.

+

API methods used: + Rooms::AssignFormGroup, + FormGroups::GetFormGroups and + FormLibraries:GetFormLibraries +

+ + From 3cfd8e0922e1836c3a7a076142959bd70d4c5385 Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Tue, 29 Dec 2020 10:26:41 +0200 Subject: [PATCH 08/17] added mandaroty param --- .../examples/eg009_assign_form_to_form_group/controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/rooms/examples/eg009_assign_form_to_form_group/controller.py b/app/rooms/examples/eg009_assign_form_to_form_group/controller.py index 829f7117..cdb7dc19 100644 --- a/app/rooms/examples/eg009_assign_form_to_form_group/controller.py +++ b/app/rooms/examples/eg009_assign_form_to_form_group/controller.py @@ -83,7 +83,8 @@ def worker(args) -> FormGroupFormToAssign: form_groups_api = FormGroupsApi(api_client) # Step 2. Create FormGroupFormToAssign Object - form_group_to_assign = FormGroupFormToAssign(form_id=args["form_id"]) + form_group_to_assign = FormGroupFormToAssign(form_id=args["form_id"], + is_required=True) # Step 3. Grant office access tp a form group via FormGroups API response = form_groups_api.assign_form_group_form( From fef8ffb55c540e73058769a5bc9312c91898886d Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Mon, 4 Jan 2021 11:30:07 +0200 Subject: [PATCH 09/17] review fixes --- README.md | 17 +++++++++- .../eg007_create_form_group/controller.py | 8 ++--- .../controller.py | 27 ++++++--------- .../views.py | 1 - .../controller.py | 34 ++++++++----------- .../eg009_assign_form_to_form_group/views.py | 4 +-- requirements.txt | 1 - 7 files changed, 45 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 17e55eee..e9e062c7 100644 --- a/README.md +++ b/README.md @@ -148,9 +148,24 @@ This example exports all the available data from a specific room in your DocuSig This example adds a standard real estate related form to a specific room in your DocuSign Rooms account. 1. **How to search for rooms with filters.** [Source.](./app/rooms/examples/eg005_get_rooms_with_filters/controller.py) +This example demonstrates how to return rooms that have had their field data, +updated within the time period between Start date and End date. 1. **Create an external form fillable session.** [Source.](./app/rooms/examples/eg006_create_external_form_fill_session/controller.py) - +This example demonstrates how to create an +external form fill session +using the Rooms API:
+the result of this code example is the URL for the form fill session, which you can embed +in your integration or send to the user. +1. **Create a form group** +[Source.](./app/rooms/examples/eg007_create_form_group/controller.py) +This example demonstrates creating a DocuSign Form Group. +1. **Grant office access to a form group** +[Source.](./app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py) +This example demonstrates how to grant Office access to a Form Group. +1. **Assign a form to a form group** +[Source.](./app/rooms/examples/eg009_assign_form_to_form_group/controller.py) +This example demonstrates how to assign form to a form group. ## Included OAuth grant types: diff --git a/app/rooms/examples/eg007_create_form_group/controller.py b/app/rooms/examples/eg007_create_form_group/controller.py index 0b359de0..f2548da8 100644 --- a/app/rooms/examples/eg007_create_form_group/controller.py +++ b/app/rooms/examples/eg007_create_form_group/controller.py @@ -1,7 +1,7 @@ +from docusign_rooms import FormGroupForCreate, FormGroupsApi from flask import session, request from app.rooms import create_rooms_api_client -from docusign_rooms import FormGroupForCreate, FormGroupsApi class Eg007Controller: @@ -9,10 +9,8 @@ class Eg007Controller: def get_args(): """Get required session and request arguments""" return { - "account_id": session["ds_account_id"], - # Represents your {ACCOUNT_ID} - "access_token": session["ds_access_token"], - # Represents your {ACCESS_TOKEN} + "account_id": session["ds_account_id"], # Represents your {ACCOUNT_ID} + "access_token": session["ds_access_token"], # Represents your {ACCESS_TOKEN} "form_group_name": request.form.get("form_group_name"), } diff --git a/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py b/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py index e30ea2f7..3e62111d 100644 --- a/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py +++ b/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py @@ -1,10 +1,6 @@ -from typing import List - from docusign_rooms import ( FormGroupsApi, - FormGroupSummary, FormGroupSummaryList, - OfficeSummary, OfficesApi, OfficeSummaryList, ) @@ -15,19 +11,17 @@ class Eg008Controller: @staticmethod - def get_args() -> dict: + def get_args(): """Get required session and request arguments""" return { - "account_id": session["ds_account_id"], - # Represents your {ACCOUNT_ID} - "access_token": session["ds_access_token"], - # Represents your {ACCESS_TOKEN} + "account_id": session["ds_account_id"], # Represents your {ACCOUNT_ID} + "access_token": session["ds_access_token"], # Represents your {ACCESS_TOKEN} "form_group_id": request.form.get("form_group_id"), "office_id": request.form.get("office_id") } @staticmethod - def get_form_groups(args) -> List[FormGroupSummary]: + def get_form_groups(args): """ 1. Create an API Client with headers 2. GET Form Groups via FormGroupsAPI @@ -38,13 +32,13 @@ def get_form_groups(args) -> List[FormGroupSummary]: # Step 2. GET Form Groups via FormGroupsAPI form_groups_api = FormGroupsApi(api_client) - responses = form_groups_api.get_form_groups( + response = form_groups_api.get_form_groups( account_id=args["account_id"]) # type: FormGroupSummaryList - return responses.form_groups + return response.form_groups @staticmethod - def get_offices(args) -> List[OfficeSummary]: + def get_offices(args): """ 1. Create an API Client with headers 2. Get Offices via OfficesAPI @@ -55,17 +49,16 @@ def get_offices(args) -> List[OfficeSummary]: # Step 2. GET offices via OfficesAPI offices_api = OfficesApi(api_client=api_client) - responses = offices_api.get_offices( + response = offices_api.get_offices( account_id=args["account_id"]) # type: OfficeSummaryList - return responses.office_summaries + return response.office_summaries @staticmethod def worker(args): """ - 1. Create an API client with headers - 2. Grant office access tp a form group via FormGroups API + 2. Grant office access to a form group via FormGroups API """ # Step 1. Create an API client with headers diff --git a/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py b/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py index 06e2cdf3..6a8043af 100644 --- a/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py +++ b/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py @@ -27,7 +27,6 @@ def assign_office_to_form_group(): return process_error(err) # 3. Render the response - return render_template( "example_done.html", title="Assign office to a form group", diff --git a/app/rooms/examples/eg009_assign_form_to_form_group/controller.py b/app/rooms/examples/eg009_assign_form_to_form_group/controller.py index cdb7dc19..ca55ed68 100644 --- a/app/rooms/examples/eg009_assign_form_to_form_group/controller.py +++ b/app/rooms/examples/eg009_assign_form_to_form_group/controller.py @@ -1,12 +1,8 @@ -from typing import List - from docusign_rooms import ( - FormGroupSummary, FormGroupsApi, FormGroupSummaryList, FormLibrariesApi, FormGroupFormToAssign, - FormSummary, ) from docusign_rooms import FormSummaryList from flask import session, request @@ -16,36 +12,34 @@ class Eg009Controller: @staticmethod - def get_args() -> dict: + def get_args(): """Get required session and request arguments""" return { - "account_id": session["ds_account_id"], - # Represents your {ACCOUNT_ID} - "access_token": session["ds_access_token"], - # Represents your {ACCESS_TOKEN} + "account_id": session["ds_account_id"], # Represents your {ACCOUNT_ID} + "access_token": session["ds_access_token"], # Represents your {ACCESS_TOKEN} "form_group_id": request.form.get("form_group_id"), - 'form_id': request.form.get('form_id') + "form_id": request.form.get("form_id") } @staticmethod - def get_form_groups(args) -> List[FormGroupSummary]: + def get_form_groups(args): """ 1. Create an API Client with headers 2. GET Form Groups via FormGroupsAPI """ # Step 1. Create an API with headers with headers - api_client = create_rooms_api_client(access_token=args['access_token']) + api_client = create_rooms_api_client(access_token=args["access_token"]) # Step 2. GET Form Groups via FormGroupsAPI form_groups_api = FormGroupsApi(api_client) - responses = form_groups_api.get_form_groups( - account_id=args['account_id']) # type: FormGroupSummaryList + response = form_groups_api.get_form_groups( + account_id=args["account_id"]) # type: FormGroupSummaryList - return responses.form_groups + return response.form_groups @staticmethod - def get_forms(args) -> List[FormSummary]: + def get_forms(args): """ 1. Create an API client with headers 2. Get first form library id @@ -71,7 +65,7 @@ def get_forms(args) -> List[FormSummary]: return form_library_forms.forms @staticmethod - def worker(args) -> FormGroupFormToAssign: + def worker(args): """ 1. Create an API Client with headers 2. Create FormGroupFormToAssign Object @@ -79,16 +73,16 @@ def worker(args) -> FormGroupFormToAssign: """ # Step 1. Create an API client with headers - api_client = create_rooms_api_client(access_token=args['access_token']) + api_client = create_rooms_api_client(access_token=args["access_token"]) form_groups_api = FormGroupsApi(api_client) # Step 2. Create FormGroupFormToAssign Object form_group_to_assign = FormGroupFormToAssign(form_id=args["form_id"], is_required=True) - # Step 3. Grant office access tp a form group via FormGroups API + # Step 3. Assign form to a form group via FormGroups API response = form_groups_api.assign_form_group_form( - form_group_id=args['form_group_id'], account_id=args['account_id'], + form_group_id=args["form_group_id"], account_id=args["account_id"], body=form_group_to_assign ) # type: FormGroupFormToAssign diff --git a/app/rooms/examples/eg009_assign_form_to_form_group/views.py b/app/rooms/examples/eg009_assign_form_to_form_group/views.py index 19b2d494..8ccede66 100644 --- a/app/rooms/examples/eg009_assign_form_to_form_group/views.py +++ b/app/rooms/examples/eg009_assign_form_to_form_group/views.py @@ -11,7 +11,7 @@ eg009 = Blueprint(eg, __name__) -@eg009.route("/eg009", methods=['POST']) +@eg009.route("/eg009", methods=["POST"]) @authenticate(eg=eg) def assign_form_to_form_group(): """ @@ -44,7 +44,7 @@ def assign_form_to_form_group(): ) -@eg009.route("/eg009", methods=['GET']) +@eg009.route("/eg009", methods=["GET"]) @authenticate(eg=eg) def get_view(): """ diff --git a/requirements.txt b/requirements.txt index e3629f6a..f07381a5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,5 +30,4 @@ virtualenv==16.7.5 virtualenv-clone==0.5.3 Werkzeug==0.16.0 wrapt==1.11.2 -pyjwt==1.7.1 From 2af909cf5cfc994acb838147f9bafaf7eaac8cec Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Mon, 4 Jan 2021 11:48:00 +0200 Subject: [PATCH 10/17] fix readme.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 2c6eb115..12787d8e 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,6 @@ This example demonstrates how to return rooms that have had their field data, updated within the time period between Start date and End date. 1. **Create an external form fillable session.** [Source.](./app/rooms/examples/eg006_create_external_form_fill_session/controller.py) -<<<<<<< HEAD This example demonstrates how to create an external form fill session using the Rooms API:
From e9de45dce739eb99df6d845a07001545e2cc0320 Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Mon, 4 Jan 2021 11:51:32 +0200 Subject: [PATCH 11/17] fix typo --- app/rooms/templates/home_rooms.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/rooms/templates/home_rooms.html b/app/rooms/templates/home_rooms.html index 1c617a47..333cb1f1 100644 --- a/app/rooms/templates/home_rooms.html +++ b/app/rooms/templates/home_rooms.html @@ -81,7 +81,7 @@

8. Grant office access to a form groupOffices::GetOffices

9. Assign form to a form group

-

This example demonstrates how to assign form to a from group.

+

This example demonstrates how to assign form to a form group.

API methods used: Rooms::AssignFormGroup, FormGroups::GetFormGroups and From 87e258bb94de8504dfa41d92e404c8770c018428 Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Mon, 4 Jan 2021 12:26:38 +0200 Subject: [PATCH 12/17] review fixes --- README.md | 2 +- app/rooms/examples/eg007_create_form_group/controller.py | 5 +++-- .../controller.py | 9 ++++----- .../eg009_assign_form_to_form_group/controller.py | 5 +++-- app/rooms/templates/eg009_assign_form_to_form_group.html | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 12787d8e..93f6efa0 100644 --- a/README.md +++ b/README.md @@ -165,7 +165,7 @@ This example demonstrates creating a DocuSign Form Group. This example demonstrates how to grant Office access to a Form Group. 1. **Assign a form to a form group** [Source.](./app/rooms/examples/eg009_assign_form_to_form_group/controller.py) -This example demonstrates how to assign form to a form group. +This example demonstrates how to assign a form to a form group. ## Click API 1. **Create a clickwrap.** diff --git a/app/rooms/examples/eg007_create_form_group/controller.py b/app/rooms/examples/eg007_create_form_group/controller.py index f2548da8..e07755fc 100644 --- a/app/rooms/examples/eg007_create_form_group/controller.py +++ b/app/rooms/examples/eg007_create_form_group/controller.py @@ -30,7 +30,8 @@ def worker(args): # Step 3. Post the form object using SDK form_groups_api = FormGroupsApi(api_client) - response = form_groups_api.create_form_group(body=form, - account_id=args["account_id"]) + response = form_groups_api.create_form_group( + body=form, account_id=args["account_id"] + ) return response diff --git a/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py b/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py index 3e62111d..d8b097c0 100644 --- a/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py +++ b/app/rooms/examples/eg008_grant_office_access_to_form_group/controller.py @@ -32,8 +32,7 @@ def get_form_groups(args): # Step 2. GET Form Groups via FormGroupsAPI form_groups_api = FormGroupsApi(api_client) - response = form_groups_api.get_form_groups( - account_id=args["account_id"]) # type: FormGroupSummaryList + response = form_groups_api.get_form_groups(account_id=args["account_id"]) # type: FormGroupSummaryList return response.form_groups @@ -49,8 +48,7 @@ def get_offices(args): # Step 2. GET offices via OfficesAPI offices_api = OfficesApi(api_client=api_client) - response = offices_api.get_offices( - account_id=args["account_id"]) # type: OfficeSummaryList + response = offices_api.get_offices(account_id=args["account_id"]) # type: OfficeSummaryList return response.office_summaries @@ -69,4 +67,5 @@ def worker(args): form_groups_api.grant_office_access_to_form_group( form_group_id=args["form_group_id"], office_id=args["office_id"], - account_id=args["account_id"]) + account_id=args["account_id"] + ) diff --git a/app/rooms/examples/eg009_assign_form_to_form_group/controller.py b/app/rooms/examples/eg009_assign_form_to_form_group/controller.py index ca55ed68..a5ea9c9d 100644 --- a/app/rooms/examples/eg009_assign_form_to_form_group/controller.py +++ b/app/rooms/examples/eg009_assign_form_to_form_group/controller.py @@ -77,8 +77,9 @@ def worker(args): form_groups_api = FormGroupsApi(api_client) # Step 2. Create FormGroupFormToAssign Object - form_group_to_assign = FormGroupFormToAssign(form_id=args["form_id"], - is_required=True) + form_group_to_assign = FormGroupFormToAssign( + form_id=args["form_id"], is_required=True + ) # Step 3. Assign form to a form group via FormGroups API response = form_groups_api.assign_form_group_form( diff --git a/app/rooms/templates/eg009_assign_form_to_form_group.html b/app/rooms/templates/eg009_assign_form_to_form_group.html index 058cfd76..d36a80e6 100644 --- a/app/rooms/templates/eg009_assign_form_to_form_group.html +++ b/app/rooms/templates/eg009_assign_form_to_form_group.html @@ -2,7 +2,7 @@ {% block content %}

9. Assign a form to a form group

-

This example demonstrates how to assign form to a form group.

+

This example demonstrates how to assign a form to a form group.

{% if show_doc %}

Documentation about this example.

From 48c0b44751bb480a1b04ca2ec944890f105ad753 Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Mon, 4 Jan 2021 12:31:33 +0200 Subject: [PATCH 13/17] additional permutations --- .../examples/eg009_assign_form_to_form_group/controller.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/rooms/examples/eg009_assign_form_to_form_group/controller.py b/app/rooms/examples/eg009_assign_form_to_form_group/controller.py index a5ea9c9d..603e3537 100644 --- a/app/rooms/examples/eg009_assign_form_to_form_group/controller.py +++ b/app/rooms/examples/eg009_assign_form_to_form_group/controller.py @@ -52,14 +52,14 @@ def get_forms(args): # Step 2. Get first form library id form_libraries_api = FormLibrariesApi(api_client) form_libraries = form_libraries_api.get_form_libraries( - account_id=args["account_id"]) + account_id=args["account_id"] + ) first_form_library_id = form_libraries.forms_library_summaries[0].forms_library_id # Step 3. Get forms form_library_forms = form_libraries_api.get_form_library_forms( - form_library_id=first_form_library_id, - account_id=args["account_id"] + form_library_id=first_form_library_id, account_id=args["account_id"] ) # type: FormSummaryList return form_library_forms.forms From 1a524b6f2d90fb85da5e755b13edfc9feb70c020 Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Mon, 11 Jan 2021 11:01:48 +0200 Subject: [PATCH 14/17] add logger and end line --- .../eg008_grant_office_access_to_form_group/views.py | 6 +++++- .../examples/eg009_assign_form_to_form_group/controller.py | 3 ++- app/rooms/templates/eg007_create_form_group.html | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py b/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py index 6a8043af..ed3f496d 100644 --- a/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py +++ b/app/rooms/examples/eg008_grant_office_access_to_form_group/views.py @@ -1,5 +1,5 @@ from docusign_rooms.client.api_exception import ApiException -from flask import Blueprint, render_template +from flask import Blueprint, render_template, current_app from app.docusign import authenticate from app.error_handlers import process_error @@ -23,6 +23,10 @@ def assign_office_to_form_group(): try: # 2. Call the worker method to assign office to form group Eg008Controller.worker(args) + current_app.logger.info( + f"""Office {args['office_id']} has been assigned to Form Group + {args['form_group_id']}!""" + ) except ApiException as err: return process_error(err) diff --git a/app/rooms/examples/eg009_assign_form_to_form_group/controller.py b/app/rooms/examples/eg009_assign_form_to_form_group/controller.py index 603e3537..d7ebd85f 100644 --- a/app/rooms/examples/eg009_assign_form_to_form_group/controller.py +++ b/app/rooms/examples/eg009_assign_form_to_form_group/controller.py @@ -34,7 +34,8 @@ def get_form_groups(args): # Step 2. GET Form Groups via FormGroupsAPI form_groups_api = FormGroupsApi(api_client) response = form_groups_api.get_form_groups( - account_id=args["account_id"]) # type: FormGroupSummaryList + account_id=args["account_id"] + ) # type: FormGroupSummaryList return response.form_groups diff --git a/app/rooms/templates/eg007_create_form_group.html b/app/rooms/templates/eg007_create_form_group.html index 617732f3..bf717000 100644 --- a/app/rooms/templates/eg007_create_form_group.html +++ b/app/rooms/templates/eg007_create_form_group.html @@ -20,4 +20,4 @@

1. Creating a form group

-{% endblock %} \ No newline at end of file +{% endblock %} From 4f1fcd354a67f01707c7198e05fab4849ecb07a2 Mon Sep 17 00:00:00 2001 From: Vladyslav Turchynevych Date: Mon, 11 Jan 2021 11:11:00 +0200 Subject: [PATCH 15/17] added removed comment --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 93f6efa0..14494f7e 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,7 @@ This example demonstrates how to grant Office access to a Form Group. This example demonstrates how to assign a form to a form group. ## Click API +