Skip to content

Commit 3b253fd

Browse files
author
Olena Harkusha
committed
Add embed a clickwrap example
1 parent b6b64b9 commit 3b253fd

7 files changed

Lines changed: 105 additions & 1 deletion

File tree

app/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
app.register_blueprint(click_examples.eg001)
4848
app.register_blueprint(click_examples.eg002)
4949
app.register_blueprint(click_examples.eg003)
50+
app.register_blueprint(click_examples.eg004)
5051
app.register_blueprint(click_examples.eg005)
5152
app.register_blueprint(click_examples.eg006)
5253
app.register_blueprint(click_examples.eg007)

app/click/examples/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .eg001_create_clickwrap import eg001
22
from .eg002_activate_clickwrap import eg002
33
from .eg003_test_clickwrap import eg003
4+
from .eg004_embed_clickwrap import eg004
45
from .eg005_create_new_clickwrap_version import eg005
56
from .eg006_list_clickwraps import eg006
67
from .eg007_clickwrap_responses import eg007
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .views import eg004
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from flask import session
2+
3+
4+
class Eg004Controller:
5+
@staticmethod
6+
def get_args():
7+
"""Get required session arguments"""
8+
return {
9+
"account_id": session.get("ds_account_id"), # Represents your {ACCOUNT_ID}
10+
"access_token": session.get("ds_access_token"), # Represents your {ACCESS_TOKEN}
11+
"clickwrap_id": session.get("clickwrap_id"),
12+
"clickwrap_is_active": session.get("clickwrap_is_active")
13+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Example 004: Embeding a clickwrap"""
2+
3+
from os import path
4+
5+
from flask import request, render_template, Blueprint, session
6+
7+
from .controller import Eg004Controller
8+
from app.docusign import authenticate
9+
from app.ds_config import DS_CONFIG
10+
11+
eg = "eg004" # reference (and url) for this example
12+
eg004 = Blueprint("eg004", __name__)
13+
14+
15+
@eg004.route("/eg004", methods=["GET", "POST"])
16+
@authenticate(eg=eg)
17+
def embed_clickwrap():
18+
"""
19+
1. Get required arguments
20+
2. Render the response
21+
"""
22+
# 1. Get required arguments
23+
args = Eg004Controller.get_args()
24+
show_clickwrap = True if request.method == 'POST' else False
25+
26+
# 2. Render template
27+
return render_template(
28+
"eg004_embed_clickwrap.html",
29+
title="Embeding a clickwrap",
30+
account_id=args.get('account_id'),
31+
client_user_id=DS_CONFIG.get('signer_email'),
32+
clickwrap_id=args.get('clickwrap_id'),
33+
clickwrap_ok=session.get("clickwrap_id") and session.get("clickwrap_is_active"),
34+
show_clickwrap=show_clickwrap,
35+
source_file=path.basename(path.dirname(__file__)) + "/controller.py",
36+
source_url=DS_CONFIG["github_example_url"] + path.basename(
37+
path.dirname(__file__)) + "/controller.py",
38+
)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!-- extend base layout --> {% extends "base.html" %} {% block content %}
2+
<h4>4. Enbeding a clickwrap</h4>
3+
<p>This example demonstrates how to use DocuSign Click to embed an
4+
existing clickwrap in your website.
5+
</p>
6+
7+
<p>
8+
View source file <a target="_blank" href="{{ source_url | safe }}">{{
9+
source_file }}</a> on GitHub.
10+
</p>
11+
12+
{% if clickwrap_ok %}
13+
14+
<p>The clickwrap you created and activated via examples 1 and 2 will be queried.</p>
15+
16+
{% if not show_clickwrap %}
17+
<form class="eg" action="" method="post">
18+
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
19+
<button type="submit" class="btn btn-docu">Show Clickwrap</button>
20+
</form>
21+
{% endif %}
22+
23+
{% else %}
24+
<p>Problem: please first create a clickwrap using <a href="eg001">example 1</a>
25+
and activate it using <a href="eg002">example 2.</a><br/>Thank you.</p>
26+
27+
<form class="eg" action="eg001" method="get">
28+
<button type="submit" class="btn btn-docu">Continue</button>
29+
</form>
30+
{% endif %}
31+
32+
{% if show_clickwrap %}
33+
<div id="ds-clickwrap"></div>
34+
<script src="https://demo.docusign.net/clickapi/sdk/latest/docusign-click.js"></script>
35+
<script>docuSignClick.Clickwrap.render({
36+
environment: 'https://demo.docusign.net',
37+
accountId: {{ account_id | tojson }},
38+
clickwrapId: {{ clickwrap_id | tojson }},
39+
clientUserId: {{ client_user_id | tojson }}
40+
}, '#ds-clickwrap');
41+
</script>
42+
43+
<p><a href="/">Continue</a></p>
44+
{% endif %}
45+
46+
{% endblock %}

app/click/templates/home_click.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,17 @@ <h4 id="example003">3. <a href="eg003">Testing a clickwrap</a></h4>
5353
<p>This example demonstrates how to use Clickwrap Tester to preview a
5454
newly created and activated clickwrap.
5555
</p>
56+
<h4 id="example004">4. <a href="eg004">Enbeding a clickwrap</a></h4>
57+
<p>This example demonstrates how to use DocuSign Click to embed an
58+
existing clickwrap in your website.
59+
</p>
5660
<h4 id="example005">5. <a href="eg005">Creating a new clickwrap
5761
version</a></h4>
5862
<p>This example demonstrates how to use the Click API to
5963
create a new version of a clickwrap.</p>
6064
<p>API method used:
6165
<a target='_blank'
62-
href="https://developers.docusign.com/docs/click-api/reference/accounts/clickwraps/updateclickwrapversion">???ClickWraps::updateClickwrapVersion???</a>
66+
href="https://developers.docusign.com/docs/click-api/reference/accounts/clickwraps/updateclickwrapversion">ClickWraps::updateClickwrapVersion</a>
6367
</p>
6468
<h4 id="example006">6. <a href="eg006">Getting a list of clickwraps</a>
6569
</h4>

0 commit comments

Comments
 (0)