Skip to content

Commit 7cf9fa6

Browse files
committed
Merge branch 'master' into feature/maintenance-november-2022
2 parents dc43c90 + edbf17f commit 7cf9fa6

File tree

17 files changed

+115
-95
lines changed

17 files changed

+115
-95
lines changed

README.MD

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ MySuresample application written in Python 3.7 (server) and React (client). You
77

88
MySure demonstrates the following:
99

10-
1. Authentication with DocuSign via [JSON Web Token (JWT) Grant](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-jsonwebtoken)
10+
1. Authentication with DocuSign via [JSON Web Token (JWT) Grant](https://developers.docusign.com/platform/auth/jwt/)
1111
2. **Submit a claim:** [Source](./app/api/requests.py)
1212
This example demonstrates an integration for submitting a claim. It allows you to pass data received from the user to fill in a document. It also adds the ability to attach additional information to the document.
1313
* The document, based on an HTML template, is combined with Docusign AutoPlace and attachment features.
1414
* The signing ceremony is implemented with embedded signing for a single signer.
1515
* The DocuSign signing ceremony is initiated from your website.
16-
* Anchor text ([AutoPlace](https://support.docusign.com/en/guides/AutoPlace-New-DocuSign-Experience)) is used to position the signing fields in the document.
17-
* [Adding attachments](https://support.docusign.com/en/guides/signer-guide-signing-adding-attachments-new) enables users to add additional information to the document.
16+
* Anchor text ([AutoPlace](https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/tabs/auto-place/)) is used to position the signing fields in the document.
17+
* [Adding attachments](https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/documents/attachments/) enables users to add additional information to the document.
1818
3. **Renew an insurance policy.** [Source](./app/api/clickwrap.py)
1919
This example shows how to use the Click API to create a clickwrap programmatically, render it in your UI, and and then submit it. It also tracks the submission event and, just after submission, redirects the user to the final page.
20-
* [More information about Click API](https://developers.docusign.com/click-api)
20+
* [More information about Click API](https://developers.docusign.com/docs/click-api)
2121
4. **Purchase a new insurance policy.** [Source](./app/api/requests.py)
22-
The example shows how to [request payment using Docusign](https://www.docusign.com/products/payments). It's implemented using an HTML-based template with [payment tabs](https://developers.docusign.com/esign-rest-api/guides/concepts/tabs/payment). The document also includes different tab types, such as [Formula](https://developers.docusign.com/esign-rest-api/guides/concepts/tabs) and
23-
[Checkbox](https://developers.docusign.com/esign-rest-api/reference/Envelopes/EnvelopeRecipientTabs/).
22+
The example shows how to [request payment using DocuSign](https://developers.docusign.com/docs/esign-rest-api/how-to/request-a-payment/). It's implemented using an HTML-based template with [payment tabs](https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/tabs/payment/). The document also includes different tab types, such as [Formula](https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/tabs/calculated-fields/) and
23+
[Checkbox](https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/enveloperecipienttabs/).
2424

2525
The document contains additional logic to calculate the total amount. At completion, the user is able to pay the calculated amount and get back to the original website.
2626

@@ -65,7 +65,7 @@ MySure demonstrates the following:
6565
> **Note:** Protect your integration key and client secret. You should make sure that the **.env** file will not be stored in your source code repository.
6666
6. Navigate to [the admin demo Apps and Keys page](https://admindemo.docusign.com/authenticate?goTo=appsAndKeys), add the Redirect URI http://localhost:3000/callback and then hit save
6767

68-
> **Note:** You should add a dynamic content properties to your clickwrap by following this [instruction](https://developers.docusign.com/docs/click-api/click101/customize-clickwrap-fields/) before using it in the sample app.
68+
> **Note:** You should add a dynamic content properties to your clickwrap by following this [instruction](https://developers.docusign.com/docs/click-api/click101/customize-elastic-template-fields/) before using it in the sample app.
6969
7070
**Using installation scripts**
7171

app/api/clickwrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def insurance_renewal():
2424
}
2525

2626
try:
27-
clickwrap_ = Clickwrap.get(clickwrap_args, session)
27+
clickwrap_ = Clickwrap.create(clickwrap_args, session)
2828
except ApiException as exc:
2929
return process_error(exc)
3030
return jsonify(clickwrap=clickwrap_)

app/clickwrap.py

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,73 @@
1-
from app.ds_config import CLICKWRAP_ID
1+
import base64
2+
from os import path
3+
4+
from app.ds_config import (
5+
TPL_PATH,
6+
CLICKWRAP_BASE_HOST,
7+
CLICKWRAP_BASE_URI
8+
)
9+
from app.ds_client import DsClient
10+
211

312
class Clickwrap: # pylint: disable=too-few-public-methods
413
@staticmethod
5-
def get(args, session):
6-
"""Gets a clickwrap and account data
14+
def create(args, session):
15+
"""Creates a clickwrap for an account
16+
Parameters:
17+
args (dict): Parameters for the clickwrap.
718
Returns:
8-
JSON structure of the clickwrap.
19+
JSON structure of the created clickwrap.
920
"""
21+
terms_name = args.get('terms_name')
22+
file_name = 'terms-renewal.docx'
1023
account_id = session.get('account_id')
1124

12-
clickwrap = {
13-
'accountId': account_id,
14-
'clickwrapId': CLICKWRAP_ID
25+
with open(path.join(TPL_PATH, file_name), 'rb') as binary_file:
26+
binary_file_data = binary_file.read()
27+
base64_encoded_data = base64.b64encode(binary_file_data)
28+
base64_terms = base64_encoded_data.decode('utf-8')
29+
30+
# Construct clickwrap JSON body
31+
body = {
32+
'displaySettings': {
33+
'consentButtonText': 'I Agree',
34+
'displayName': args.get('display_name'),
35+
'downloadable': True,
36+
'format': 'modal',
37+
'hasAccept': True,
38+
'mustRead': True,
39+
'requireAccept': True,
40+
'size': 'medium',
41+
'documentDisplay': 'document',
42+
},
43+
'documents': [
44+
{
45+
'documentBase64': base64_terms,
46+
'documentName': terms_name,
47+
'fileExtension': file_name[file_name.rfind('.')+1:],
48+
'order': 0
49+
}
50+
],
51+
'name': terms_name,
52+
'requireReacceptance': True
1553
}
1654

17-
return clickwrap
55+
# Make a POST call to the clickwraps endpoint to create a clickwrap for an account
56+
ds_client = DsClient.get_configured_instance(
57+
session.get('access_token'),
58+
CLICKWRAP_BASE_HOST
59+
)
60+
61+
uri = f"{CLICKWRAP_BASE_URI}/{account_id}/clickwraps"
62+
response = ds_client.call_api(
63+
uri, 'POST', body=body, response_type='object'
64+
)
65+
66+
clickwrap_id = response[0].get('clickwrapId')
67+
68+
# Make a PUT call to the clickwraps endpoint to activate created clickwrap
69+
uri = f"{CLICKWRAP_BASE_URI}/{account_id}/clickwraps/{clickwrap_id}/versions/1"
70+
response_active = ds_client.call_api(
71+
uri, 'PUT', body={'status': 'active'}, response_type='object'
72+
)
73+
return response_active[0]

app/ds_config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,3 @@
2020
DS_RETURN_URL = os.environ.get('REACT_APP_DS_RETURN_URL')
2121
DS_AUTH_SERVER = os.environ.get('DS_AUTH_SERVER')
2222
DS_DEMO_SERVER = os.environ.get('REACT_APP_DS_DEMO_SERVER')
23-
24-
CLICKWRAP_ID = os.environ.get('CLICKWRAP_ID')

package-lock.json

Lines changed: 18 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4+
<!-- Google Tag Manager -->
5+
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
6+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
7+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
8+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
9+
})(window,document,'script','dataLayer','GTM-WPK6FN5');</script>
10+
<!-- End Google Tag Manager -->
411
<meta charset="utf-8" />
512
<link rel="icon" href="favicon.ico" />
613
<meta name="viewport" content="width=device-width, initial-scale=1" />

public/locales/en/About.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
"DeveloperCenter": "Developer Center",
1212
"DeveloperCenterLink": "https://developers.docusign.com",
1313
"APICodeExamples": "DocuSign eSignature API Code Examples",
14-
"APICodeExamplesLink": "https://developers.docusign.com/esign-rest-api/code-examples",
14+
"APICodeExamplesLink": "https://developers.docusign.com/docs/esign-rest-api/how-to/",
1515
"ESignatureDocumentation": "DocuSign eSignature API Documentation",
16-
"ESignatureDocumentationLink": " https://developers.docusign.com/esign-rest-api/reference",
16+
"ESignatureDocumentationLink": " https://developers.docusign.com/docs/esign-rest-api/reference/",
1717
"DeveloperCommunity": "Developer Community",
1818
"DeveloperCommunityLink": "http://stackoverflow.com/questions/tagged/docusignapi",
1919
"AboutDocuSign": "<h3>About DocuSign</h3><ul><li>More than <strong>400 million users</strong> in <strong>188 countries</strong></li><li>More than 300,000 companies</li><li>More than 300,000 new unique users join The DocuSign Global Trust Network every day</li><li>More than 64% of documents are completed within one hour</li> <li>DocuSign is available in <strong>43 languages</strong></li></ul>",

0 commit comments

Comments
 (0)