Skip to content

Commit bc97953

Browse files
authored
Merge pull request #14 from docusign/April-2020-New-Code-Examples
Add new code examples to the python launcher
2 parents 16a4511 + dc7b189 commit bc97953

File tree

146 files changed

+6468
-4540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+6468
-4540
lines changed

README.md

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,81 +8,116 @@ This repo is a Python 3 application that demonstrates:
88
[Authorization Code Grant flow](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-code-grant).
99
When the token expires, the user is asked to re-authenticate.
1010
The **refresh token** is not used in this example.
11+
* Authentication with DocuSign via the [JSON Web Token (JWT) Grant](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-jsonwebtoken).
12+
When the token expires, it updates automatically.
1113
1. **Embedded Signing Ceremony.**
12-
[Source.](./app/eg001_embedded_signing.py)
14+
[Source.](./app/examples/eg001_embedded_signing/controller.py)
1315
This example sends an envelope, and then uses an embedded signing ceremony for the first signer.
1416
With embedded signing, the DocuSign signing ceremony is initiated from your website.
1517
1. **Send an envelope with a remote (email) signer and cc recipient.**
16-
[Source.](./app/eg002_signing_via_email.py)
18+
[Source.](./app/examples/eg002_signing_via_email/controller.py)
1719
The envelope includes a pdf, Word, and HTML document.
1820
Anchor text ([AutoPlace](https://support.docusign.com/en/guides/AutoPlace-New-DocuSign-Experience)) is used to position the signing fields in the documents.
1921
1. **List envelopes in the user's account.**
20-
[Source.](./app/eg003_list_envelopes.py)
22+
[Source.](./app/examples/eg003_list_envelopes/controller.py)
2123
The envelopes' current status is included.
2224
1. **Get an envelope's basic information.**
23-
[Source.](./app/eg004_envelope_info.py)
25+
[Source.](./app/examples/eg004_envelope_info/controller.py)
2426
The example lists the basic information about an envelope, including its overall status.
2527
1. **List an envelope's recipients**
26-
[Source.](./app/eg005_envelope_recipients.py)
28+
[Source.](./app/examples/eg005_envelope_recipients/controller.py)
2729
Includes current recipient status.
2830
1. **List an envelope's documents.**
29-
[Source.](./app/eg006_envelope_docs.py)
31+
[Source.](./app/examples/eg006_envelope_docs/controller.py)
3032
1. **Download an envelope's documents.**
31-
[Source.](./app/eg007_envelope_get_doc.py)
33+
[Source.](./app/examples/eg007_envelope_get_doc/controller.py)
3234
The example can download individual
3335
documents, the documents concatenated together, or a zip file of the documents.
3436
1. **Programmatically create a template.**
35-
[Source.](./app/eg008_create_template.py)
37+
[Source.](./app/examples/eg008_create_template/controller.py)
3638
1. **Send an envelope using a template.**
37-
[Source.](./app/eg009_use_template.py)
38-
1. **Send an envelope and upload its documents with multpart binary transfer.**
39-
[Source.](./app/eg010_send_binary_docs.py)
39+
[Source.](./app/examples/eg009_use_template/controller.py)
40+
1. **Send an envelope and upload its documents with multipart binary transfer.**
41+
[Source.](./app/examples/eg010_send_binary_docs/controller.py)
4042
Binary transfer is 33% more efficient than using Base64 encoding.
4143
1. **Embedded sending.**
42-
[Source.](./app/eg011_embedded_sending.py)
44+
[Source.](./app/examples/eg011_embedded_sending/controller.py)
4345
Embeds the DocuSign web tool (NDSE) in your web app to finalize or update
4446
the envelope and documents before they are sent.
4547
1. **Embedded DocuSign web tool (NDSE).**
46-
[Source.](./app/eg012_embedded_console.py)
48+
[Source.](./app/examples/eg012_embedded_console/controller.py)
4749
1. **Embedded Signing Ceremony from a template with an added document.**
48-
[Source.](./app/eg013_add_doc_to_template.py)
50+
[Source.](./app/examples/eg013_add_doc_to_template/controller.py)
4951
This example sends an envelope based on a template.
5052
In addition to the template's document(s), the example adds an
5153
additional document to the envelope by using the
5254
[Composite Templates](https://developers.docusign.com/esign-rest-api/guides/features/templates#composite-templates)
5355
feature.
5456
1. **Payments example: an order form, with online payment by credit card.**
55-
[Source.](./app/eg014_collect_payment.py)
57+
[Source.](./app/examples/eg014_collect_payment/controller.py)
5658
1. **Get the envelope tab data.**
5759
Retrieve the tab (field) values for all of the envelope's recipients.
58-
[Source.](./app/eg015_envelope_tab_data.py)
60+
[Source.](./app/examples/eg015_envelope_tab_data/controller.py)
5961
1. **Set envelope tab values.**
6062
The example creates an envelope and sets the initial values for its tabs (fields). Some of the tabs
6163
are set to be read-only, others can be updated by the recipient. The example also stores
6264
metadata with the envelope.
63-
[Source.](./app/eg016_set_tab_values.py)
65+
[Source.](./app/examples/eg016_set_tab_values/controller.py)
6466
1. **Set template tab values.**
6567
The example creates an envelope using a template and sets the initial values for its tabs (fields).
6668
The example also stores metadata with the envelope.
67-
[Source.](./app/eg017_set_template_tab_values.py)
69+
[Source.](./app/examples/eg017_set_template_tab_values/controller.py)
6870
1. **Get the envelope custom field data (metadata).**
6971
The example retrieves the custom metadata (custom data fields) stored with the envelope.
70-
[Source.](./app/eg018_envelope_custom_field_data.py)
72+
[Source.](./app/examples/eg018_envelope_custom_field_data/controller.py)
7173
1. **Requiring an Access Code for a Recipient**
72-
[Source.](./app/eg019_access_code_authentication.py)
74+
[Source.](./app/examples/eg019_access_code_authentication/controller.py)
7375
This example sends an envelope that requires an access-code for the purpose of multi-factor authentication.
7476
1. **Requiring SMS authentication for a recipient**
75-
[Source.](./app/eg020_sms_authentication.py)
77+
[Source.](./app/examples/eg020_sms_authentication/controller.py)
7678
This example sends an envelope that requires entering in a six digit code from an text message for the purpose of multi-factor authentication.
7779
1. **Requiring Phone authentication for a recipient**
78-
[Source.](./app/eg021_phone_authentication.py)
80+
[Source.](./app/examples/eg021_phone_authentication/controller.py)
7981
This example sends an envelope that requires entering in a voice-based response code for the purpose of multi-factor authentication.
8082
1. **Requiring Knowledge-Based Authentication (KBA) for a Recipient**
81-
[Source.](./app/eg022_kba_authentication.py)
83+
[Source.](./app/examples/eg022_kba_authentication/controller.py)
8284
This example sends an envelope that requires passing a Public records check to validate identity for the purpose of multi-factor authentication.
8385
1. **Requiring ID Verification (IDV) for a recipient**
84-
[Source.](./app/eg023_idv_authentication.py)
85-
This example sends an envelope that requires submitting a photo of a government issued id for the purpose of multi-factor authentication.
86+
[Source.](./app/examples/eg023_idv_authentication/controller.py)
87+
This example sends an envelope that requires submitting a photo of a government issued id for the purpose of multi-factor authentication.
88+
1. **Creating a permission profile**
89+
[Source.](./app/examples/eg024_permissions_creating/controller.py)
90+
This code example demonstrates how to create a permission profile using the [Create Permission Profile](https://developers.docusign.com/esign-rest-api/reference/Accounts/AccountPermissionProfiles/create) method.
91+
1. **Setting a permission profile**
92+
[Source.](./app/examples/eg025_permissions_set_user_group/controller.py)
93+
This code example demonstrates how to set a user group’s permission profile using the [Update Group](https://developers.docusign.com/esign-rest-api/reference/UserGroups/Groups/update) method.
94+
You must have already created the permissions profile and the group of users.
95+
1. **Updating individual permission settings**
96+
[Source.](./app/examples/eg026_permissions_change_single_setting/controller.py)
97+
This code example demonstrates how to edit individual permission settings on a permissions profile using the [Update Permission Profile](https://developers.docusign.com/esign-rest-api/reference/Accounts/AccountPermissionProfiles/update) method.
98+
1. **Deleting a permission profile**
99+
[Source.](./app/examples/eg027_permissions_delete/controller.py)
100+
This code example demonstrates how to delete a permission profile using the [Delete Permission Profile](https://developers.docusign.com/esign-rest-api/reference/Accounts/AccountPermissionProfiles/create) method.
101+
1. **Creating a brand**
102+
[Source.](./app/examples/eg028_brand_creating/controller.py)
103+
This example creates brand profile for an account using the [Create Brand](https://developers.docusign.com/esign-rest-api/reference/Accounts/AccountBrands/create) method.
104+
1. **Applying a brand to an envelope**
105+
[Source.](./app/examples/eg029_brands_apply_to_envelope/controller.py)
106+
This code example demonstrates how to apply a brand you've created to an envelope using the [Create Envelope](https://developers.docusign.com/esign-rest-api/reference/Envelopes/Envelopes/create) method.
107+
First, creates the envelope and then applies the brand to it.
108+
Anchor text ([AutoPlace](https://support.docusign.com/en/guides/AutoPlace-New-DocuSign-Experience)) is used to position the signing fields in the documents.
109+
1. **Applying a brand to a template**
110+
[Source.](./app/examples/eg030_brands_apply_to_template/controller.py)
111+
This code example demonstrates how to apply a brand you've created to a template using using the [Create Envelope](https://developers.docusign.com/esign-rest-api/reference/Envelopes/Envelopes/create) method.
112+
You must have already created the template and the brand.
113+
Anchor text ([AutoPlace](https://support.docusign.com/en/guides/AutoPlace-New-DocuSign-Experience)) is used to position the signing fields in the documents.
114+
1. **Bulk sending envelopes to multiple recipients**
115+
[Source.](./app/examples/eg031_bulk_send/controller.py)
116+
This code example demonstrates how to send envelopes in bulk to multiple recipients using these methods:
117+
[Create Bulk Send List](https://developers.docusign.com/esign-rest-api/reference/BulkEnvelopes/BulkSend/createBulkSendList),
118+
[Create Bulk Send Request](https://developers.docusign.com/esign-rest-api/reference/BulkEnvelopes/BulkSend/createBulkSendRequest).
119+
Firstly, creates a bulk send recipients list, and then creates an envelope.
120+
After that, initiates bulk envelope sending.
86121

87122
## Installation
88123

@@ -147,9 +182,3 @@ This repository uses the MIT License. See the LICENSE file for more information.
147182
### Pull Requests
148183
Pull requests are welcomed. Pull requests will only be considered if their content
149184
uses the MIT License.
150-
151-
### Additional Resources
152-
* [DocuSign Developer Center](https://developers.docusign.com)
153-
* [DocuSign API on Twitter](https://twitter.com/docusignapi)
154-
* [DocuSign For Developers on LinkedIn](https://www.linkedin.com/showcase/docusign-for-developers/)
155-
* [DocuSign For Developers on YouTube](https://www.youtube.com/channel/UCJSJ2kMs_qeQotmw4-lX2NQ)

app/__init__.py

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,61 @@
11
import os
2-
from app import ds_config
2+
33
from flask import Flask
44
from flask_wtf.csrf import CSRFProtect
55

6+
from . import examples
7+
from .docusign.views import ds
8+
from .views import core
69

710
session_path = "/tmp/python_recipe_sessions"
811

912
app = Flask(__name__)
1013
app.config.from_pyfile("config.py")
11-
app.secret_key = ds_config.DS_CONFIG["session_secret"]
12-
csrf = CSRFProtect(app) # See https://flask-wtf.readthedocs.io/en/stable/csrf.html
14+
# See https://flask-wtf.readthedocs.io/en/stable/csrf.html
15+
csrf = CSRFProtect(app)
16+
17+
# Register home page
18+
app.register_blueprint(core)
19+
# Register OAuth
20+
app.register_blueprint(ds)
21+
# Register examples
22+
app.register_blueprint(examples.eg001)
23+
app.register_blueprint(examples.eg002)
24+
app.register_blueprint(examples.eg003)
25+
app.register_blueprint(examples.eg004)
26+
app.register_blueprint(examples.eg005)
27+
app.register_blueprint(examples.eg006)
28+
app.register_blueprint(examples.eg007)
29+
app.register_blueprint(examples.eg008)
30+
app.register_blueprint(examples.eg009)
31+
app.register_blueprint(examples.eg010)
32+
app.register_blueprint(examples.eg011)
33+
app.register_blueprint(examples.eg012)
34+
app.register_blueprint(examples.eg013)
35+
app.register_blueprint(examples.eg014)
36+
app.register_blueprint(examples.eg015)
37+
app.register_blueprint(examples.eg016)
38+
app.register_blueprint(examples.eg017)
39+
app.register_blueprint(examples.eg018)
40+
app.register_blueprint(examples.eg019)
41+
app.register_blueprint(examples.eg020)
42+
app.register_blueprint(examples.eg021)
43+
app.register_blueprint(examples.eg022)
44+
app.register_blueprint(examples.eg023)
45+
app.register_blueprint(examples.eg024)
46+
app.register_blueprint(examples.eg025)
47+
app.register_blueprint(examples.eg026)
48+
app.register_blueprint(examples.eg027)
49+
app.register_blueprint(examples.eg028)
50+
app.register_blueprint(examples.eg029)
51+
app.register_blueprint(examples.eg030)
52+
app.register_blueprint(examples.eg031)
1353

1454
if "DYNO" in os.environ: # On Heroku?
1555
import logging
56+
1657
stream_handler = logging.StreamHandler()
1758
app.logger.addHandler(stream_handler)
1859
app.logger.setLevel(logging.INFO)
1960
app.logger.info("Recipe example startup")
20-
app.config.update(dict(PREFERRED_URL_SCHEME = "https"))
21-
22-
from app import views
61+
app.config.update(dict(PREFERRED_URL_SCHEME="https"))

app/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
# For interactive debugging of Flask apps on Heroku see
33
# http://stackoverflow.com/a/13946679/64904
44
DEBUG = True
5+
6+
# Secret for encrypting session cookie content
7+
# Use any random string of characters
8+
SECRET_KEY = "{SESSION_SECRET}"

app/consts.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
from os import path
2+
import re
3+
4+
demo_docs_path = path.abspath(path.join(path.dirname(path.realpath(__file__)), "static/demo_documents"))
5+
6+
# Pattern for validating signer name and email
7+
pattern = re.compile("([^\w \-\@\.\,])+")
8+
9+
signer_client_id = 1000 # Used to indicate that the signer will use an embedded
10+
# Signing Ceremony. Represents the signer"s userId within
11+
# your application.
12+
13+
authentication_method = "None" # How is this application authenticating
14+
15+
minimum_buffer_min = 3
16+
17+
# Template name for create template example
18+
template_name = "Example Signer and CC template"
19+
20+
# Name of static doc file
21+
doc_file = "World_Wide_Corp_fields.pdf"
22+
# Name of static pdf file
23+
pdf_file = "World_Wide_Corp_lorem.pdf"
24+
25+
# Base uri for callback function
26+
base_uri_suffix = "/restapi"
27+
28+
29+
# Default languages for brand
30+
languages = {
31+
"Arabic": "ar",
32+
"Armenian": "hy",
33+
"Bahasa Indonesia": "id",
34+
"Bahasa Malay": "ms",
35+
"Bulgarian": "bg",
36+
"Chinese Simplified": "zh_CN",
37+
"Chinese Traditional": "zh_TW",
38+
"Croatian": "hr",
39+
"Czech": "cs",
40+
"Danish": "da",
41+
"Dutch": "nl",
42+
"English UK": "en_GB",
43+
"English US": "en",
44+
"Estonian": "et",
45+
"Farsi": "fa",
46+
"Finnish": "fi",
47+
"French": "fr",
48+
"French Canada": "fr_CA",
49+
"German": "de",
50+
"Greek": "el",
51+
"Hebrew": "he",
52+
"Hindi": "hi",
53+
"Hungarian": "hu",
54+
"Italian": "it",
55+
"Japanese": "ja",
56+
"Korean": "ko",
57+
"Latvian": "lv",
58+
"Lithuanian": "lt",
59+
"Norwegian": "no",
60+
"Polish": "pl",
61+
"Portuguese": "pt",
62+
"Portuguese Brasil": "pt_BR",
63+
"Romanian": "ro",
64+
"Russian": "ru",
65+
"Serbian": "sr",
66+
"Slovak": "sk",
67+
"Slovenian": "sl",
68+
"Spanish": "es",
69+
"Spanish Latin America": "es_MX",
70+
"Swedish": "sv",
71+
"Thai": "th",
72+
"Turkish": "tr",
73+
"Ukrainian": "uk",
74+
"Vietnamese": "vi"
75+
}
76+
77+
# Default settings for updating and creating permissions
78+
settings = {
79+
"useNewDocuSignExperienceInterface": "optional",
80+
"allowBulkSending": "true",
81+
"allowEnvelopeSending": "true",
82+
"allowSignerAttachments": "true",
83+
"allowTaggingInSendAndCorrect": "true",
84+
"allowWetSigningOverride": "true",
85+
"allowedAddressBookAccess": "personalAndShared",
86+
"allowedTemplateAccess": "share",
87+
"enableRecipientViewingNotifications": "true",
88+
"enableSequentialSigningInterface": "true",
89+
"receiveCompletedSelfSignedDocumentsAsEmailLinks": "false",
90+
"signingUiVersion": "v2",
91+
"useNewSendingInterface": "true",
92+
"allowApiAccess": "true",
93+
"allowApiAccessToAccount": "true",
94+
"allowApiSendingOnBehalfOfOthers": "true",
95+
"allowApiSequentialSigning": "true",
96+
"enableApiRequestLogging": "true",
97+
"allowDocuSignDesktopClient": "false",
98+
"allowSendersToSetRecipientEmailLanguage": "true",
99+
"allowVaulting": "false",
100+
"allowedToBeEnvelopeTransferRecipient": "true",
101+
"enableTransactionPointIntegration": "false",
102+
"powerFormRole": "admin",
103+
"vaultingMode": "none"
104+
}
105+

app/docusign/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .ds_client import DSClient
2+
from .utils import ds_token_ok, create_api_client, authenticate

0 commit comments

Comments
 (0)