Skip to content

Add new code examples to the python launcher #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 60 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,81 +8,116 @@ This repo is a Python 3 application that demonstrates:
[Authorization Code Grant flow](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-code-grant).
When the token expires, the user is asked to re-authenticate.
The **refresh token** is not used in this example.
* Authentication with DocuSign via the [JSON Web Token (JWT) Grant](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-jsonwebtoken).
When the token expires, it updates automatically.
1. **Embedded Signing Ceremony.**
[Source.](./app/eg001_embedded_signing.py)
[Source.](./app/examples/eg001_embedded_signing/controller.py)
This example sends an envelope, and then uses an embedded signing ceremony for the first signer.
With embedded signing, the DocuSign signing ceremony is initiated from your website.
1. **Send an envelope with a remote (email) signer and cc recipient.**
[Source.](./app/eg002_signing_via_email.py)
[Source.](./app/examples/eg002_signing_via_email/controller.py)
The envelope includes a pdf, Word, and HTML document.
Anchor text ([AutoPlace](https://support.docusign.com/en/guides/AutoPlace-New-DocuSign-Experience)) is used to position the signing fields in the documents.
1. **List envelopes in the user's account.**
[Source.](./app/eg003_list_envelopes.py)
[Source.](./app/examples/eg003_list_envelopes/controller.py)
The envelopes' current status is included.
1. **Get an envelope's basic information.**
[Source.](./app/eg004_envelope_info.py)
[Source.](./app/examples/eg004_envelope_info/controller.py)
The example lists the basic information about an envelope, including its overall status.
1. **List an envelope's recipients**
[Source.](./app/eg005_envelope_recipients.py)
[Source.](./app/examples/eg005_envelope_recipients/controller.py)
Includes current recipient status.
1. **List an envelope's documents.**
[Source.](./app/eg006_envelope_docs.py)
[Source.](./app/examples/eg006_envelope_docs/controller.py)
1. **Download an envelope's documents.**
[Source.](./app/eg007_envelope_get_doc.py)
[Source.](./app/examples/eg007_envelope_get_doc/controller.py)
The example can download individual
documents, the documents concatenated together, or a zip file of the documents.
1. **Programmatically create a template.**
[Source.](./app/eg008_create_template.py)
[Source.](./app/examples/eg008_create_template/controller.py)
1. **Send an envelope using a template.**
[Source.](./app/eg009_use_template.py)
1. **Send an envelope and upload its documents with multpart binary transfer.**
[Source.](./app/eg010_send_binary_docs.py)
[Source.](./app/examples/eg009_use_template/controller.py)
1. **Send an envelope and upload its documents with multipart binary transfer.**
[Source.](./app/examples/eg010_send_binary_docs/controller.py)
Binary transfer is 33% more efficient than using Base64 encoding.
1. **Embedded sending.**
[Source.](./app/eg011_embedded_sending.py)
[Source.](./app/examples/eg011_embedded_sending/controller.py)
Embeds the DocuSign web tool (NDSE) in your web app to finalize or update
the envelope and documents before they are sent.
1. **Embedded DocuSign web tool (NDSE).**
[Source.](./app/eg012_embedded_console.py)
[Source.](./app/examples/eg012_embedded_console/controller.py)
1. **Embedded Signing Ceremony from a template with an added document.**
[Source.](./app/eg013_add_doc_to_template.py)
[Source.](./app/examples/eg013_add_doc_to_template/controller.py)
This example sends an envelope based on a template.
In addition to the template's document(s), the example adds an
additional document to the envelope by using the
[Composite Templates](https://developers.docusign.com/esign-rest-api/guides/features/templates#composite-templates)
feature.
1. **Payments example: an order form, with online payment by credit card.**
[Source.](./app/eg014_collect_payment.py)
[Source.](./app/examples/eg014_collect_payment/controller.py)
1. **Get the envelope tab data.**
Retrieve the tab (field) values for all of the envelope's recipients.
[Source.](./app/eg015_envelope_tab_data.py)
[Source.](./app/examples/eg015_envelope_tab_data/controller.py)
1. **Set envelope tab values.**
The example creates an envelope and sets the initial values for its tabs (fields). Some of the tabs
are set to be read-only, others can be updated by the recipient. The example also stores
metadata with the envelope.
[Source.](./app/eg016_set_tab_values.py)
[Source.](./app/examples/eg016_set_tab_values/controller.py)
1. **Set template tab values.**
The example creates an envelope using a template and sets the initial values for its tabs (fields).
The example also stores metadata with the envelope.
[Source.](./app/eg017_set_template_tab_values.py)
[Source.](./app/examples/eg017_set_template_tab_values/controller.py)
1. **Get the envelope custom field data (metadata).**
The example retrieves the custom metadata (custom data fields) stored with the envelope.
[Source.](./app/eg018_envelope_custom_field_data.py)
[Source.](./app/examples/eg018_envelope_custom_field_data/controller.py)
1. **Requiring an Access Code for a Recipient**
[Source.](./app/eg019_access_code_authentication.py)
[Source.](./app/examples/eg019_access_code_authentication/controller.py)
This example sends an envelope that requires an access-code for the purpose of multi-factor authentication.
1. **Requiring SMS authentication for a recipient**
[Source.](./app/eg020_sms_authentication.py)
[Source.](./app/examples/eg020_sms_authentication/controller.py)
This example sends an envelope that requires entering in a six digit code from an text message for the purpose of multi-factor authentication.
1. **Requiring Phone authentication for a recipient**
[Source.](./app/eg021_phone_authentication.py)
[Source.](./app/examples/eg021_phone_authentication/controller.py)
This example sends an envelope that requires entering in a voice-based response code for the purpose of multi-factor authentication.
1. **Requiring Knowledge-Based Authentication (KBA) for a Recipient**
[Source.](./app/eg022_kba_authentication.py)
[Source.](./app/examples/eg022_kba_authentication/controller.py)
This example sends an envelope that requires passing a Public records check to validate identity for the purpose of multi-factor authentication.
1. **Requiring ID Verification (IDV) for a recipient**
[Source.](./app/eg023_idv_authentication.py)
This example sends an envelope that requires submitting a photo of a government issued id for the purpose of multi-factor authentication.
[Source.](./app/examples/eg023_idv_authentication/controller.py)
This example sends an envelope that requires submitting a photo of a government issued id for the purpose of multi-factor authentication.
1. **Creating a permission profile**
[Source.](./app/examples/eg024_permissions_creating/controller.py)
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.
1. **Setting a permission profile**
[Source.](./app/examples/eg025_permissions_set_user_group/controller.py)
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.
You must have already created the permissions profile and the group of users.
1. **Updating individual permission settings**
[Source.](./app/examples/eg026_permissions_change_single_setting/controller.py)
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.
1. **Deleting a permission profile**
[Source.](./app/examples/eg027_permissions_delete/controller.py)
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.
1. **Creating a brand**
[Source.](./app/examples/eg028_brand_creating/controller.py)
This example creates brand profile for an account using the [Create Brand](https://developers.docusign.com/esign-rest-api/reference/Accounts/AccountBrands/create) method.
1. **Applying a brand to an envelope**
[Source.](./app/examples/eg029_brands_apply_to_envelope/controller.py)
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.
First, creates the envelope and then applies the brand to it.
Anchor text ([AutoPlace](https://support.docusign.com/en/guides/AutoPlace-New-DocuSign-Experience)) is used to position the signing fields in the documents.
1. **Applying a brand to a template**
[Source.](./app/examples/eg030_brands_apply_to_template/controller.py)
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.
You must have already created the template and the brand.
Anchor text ([AutoPlace](https://support.docusign.com/en/guides/AutoPlace-New-DocuSign-Experience)) is used to position the signing fields in the documents.
1. **Bulk sending envelopes to multiple recipients**
[Source.](./app/examples/eg031_bulk_send/controller.py)
This code example demonstrates how to send envelopes in bulk to multiple recipients using these methods:
[Create Bulk Send List](https://developers.docusign.com/esign-rest-api/reference/BulkEnvelopes/BulkSend/createBulkSendList),
[Create Bulk Send Request](https://developers.docusign.com/esign-rest-api/reference/BulkEnvelopes/BulkSend/createBulkSendRequest).
Firstly, creates a bulk send recipients list, and then creates an envelope.
After that, initiates bulk envelope sending.

## Installation

Expand Down Expand Up @@ -147,9 +182,3 @@ This repository uses the MIT License. See the LICENSE file for more information.
### Pull Requests
Pull requests are welcomed. Pull requests will only be considered if their content
uses the MIT License.

### Additional Resources
* [DocuSign Developer Center](https://developers.docusign.com)
* [DocuSign API on Twitter](https://twitter.com/docusignapi)
* [DocuSign For Developers on LinkedIn](https://www.linkedin.com/showcase/docusign-for-developers/)
* [DocuSign For Developers on YouTube](https://www.youtube.com/channel/UCJSJ2kMs_qeQotmw4-lX2NQ)
51 changes: 45 additions & 6 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,61 @@
import os
from app import ds_config

from flask import Flask
from flask_wtf.csrf import CSRFProtect

from . import examples
from .docusign.views import ds
from .views import core

session_path = "/tmp/python_recipe_sessions"

app = Flask(__name__)
app.config.from_pyfile("config.py")
app.secret_key = ds_config.DS_CONFIG["session_secret"]
csrf = CSRFProtect(app) # See https://flask-wtf.readthedocs.io/en/stable/csrf.html
# See https://flask-wtf.readthedocs.io/en/stable/csrf.html
csrf = CSRFProtect(app)

# Register home page
app.register_blueprint(core)
# Register OAuth
app.register_blueprint(ds)
# Register examples
app.register_blueprint(examples.eg001)
app.register_blueprint(examples.eg002)
app.register_blueprint(examples.eg003)
app.register_blueprint(examples.eg004)
app.register_blueprint(examples.eg005)
app.register_blueprint(examples.eg006)
app.register_blueprint(examples.eg007)
app.register_blueprint(examples.eg008)
app.register_blueprint(examples.eg009)
app.register_blueprint(examples.eg010)
app.register_blueprint(examples.eg011)
app.register_blueprint(examples.eg012)
app.register_blueprint(examples.eg013)
app.register_blueprint(examples.eg014)
app.register_blueprint(examples.eg015)
app.register_blueprint(examples.eg016)
app.register_blueprint(examples.eg017)
app.register_blueprint(examples.eg018)
app.register_blueprint(examples.eg019)
app.register_blueprint(examples.eg020)
app.register_blueprint(examples.eg021)
app.register_blueprint(examples.eg022)
app.register_blueprint(examples.eg023)
app.register_blueprint(examples.eg024)
app.register_blueprint(examples.eg025)
app.register_blueprint(examples.eg026)
app.register_blueprint(examples.eg027)
app.register_blueprint(examples.eg028)
app.register_blueprint(examples.eg029)
app.register_blueprint(examples.eg030)
app.register_blueprint(examples.eg031)

if "DYNO" in os.environ: # On Heroku?
import logging

stream_handler = logging.StreamHandler()
app.logger.addHandler(stream_handler)
app.logger.setLevel(logging.INFO)
app.logger.info("Recipe example startup")
app.config.update(dict(PREFERRED_URL_SCHEME = "https"))

from app import views
app.config.update(dict(PREFERRED_URL_SCHEME="https"))
4 changes: 4 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
# For interactive debugging of Flask apps on Heroku see
# http://stackoverflow.com/a/13946679/64904
DEBUG = True

# Secret for encrypting session cookie content
# Use any random string of characters
SECRET_KEY = "{SESSION_SECRET}"
105 changes: 105 additions & 0 deletions app/consts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
from os import path
import re

demo_docs_path = path.abspath(path.join(path.dirname(path.realpath(__file__)), "static/demo_documents"))

# Pattern for validating signer name and email
pattern = re.compile("([^\w \-\@\.\,])+")

signer_client_id = 1000 # Used to indicate that the signer will use an embedded
# Signing Ceremony. Represents the signer"s userId within
# your application.

authentication_method = "None" # How is this application authenticating

minimum_buffer_min = 3

# Template name for create template example
template_name = "Example Signer and CC template"

# Name of static doc file
doc_file = "World_Wide_Corp_fields.pdf"
# Name of static pdf file
pdf_file = "World_Wide_Corp_lorem.pdf"

# Base uri for callback function
base_uri_suffix = "/restapi"


# Default languages for brand
languages = {
"Arabic": "ar",
"Armenian": "hy",
"Bahasa Indonesia": "id",
"Bahasa Malay": "ms",
"Bulgarian": "bg",
"Chinese Simplified": "zh_CN",
"Chinese Traditional": "zh_TW",
"Croatian": "hr",
"Czech": "cs",
"Danish": "da",
"Dutch": "nl",
"English UK": "en_GB",
"English US": "en",
"Estonian": "et",
"Farsi": "fa",
"Finnish": "fi",
"French": "fr",
"French Canada": "fr_CA",
"German": "de",
"Greek": "el",
"Hebrew": "he",
"Hindi": "hi",
"Hungarian": "hu",
"Italian": "it",
"Japanese": "ja",
"Korean": "ko",
"Latvian": "lv",
"Lithuanian": "lt",
"Norwegian": "no",
"Polish": "pl",
"Portuguese": "pt",
"Portuguese Brasil": "pt_BR",
"Romanian": "ro",
"Russian": "ru",
"Serbian": "sr",
"Slovak": "sk",
"Slovenian": "sl",
"Spanish": "es",
"Spanish Latin America": "es_MX",
"Swedish": "sv",
"Thai": "th",
"Turkish": "tr",
"Ukrainian": "uk",
"Vietnamese": "vi"
}

# Default settings for updating and creating permissions
settings = {
"useNewDocuSignExperienceInterface": "optional",
"allowBulkSending": "true",
"allowEnvelopeSending": "true",
"allowSignerAttachments": "true",
"allowTaggingInSendAndCorrect": "true",
"allowWetSigningOverride": "true",
"allowedAddressBookAccess": "personalAndShared",
"allowedTemplateAccess": "share",
"enableRecipientViewingNotifications": "true",
"enableSequentialSigningInterface": "true",
"receiveCompletedSelfSignedDocumentsAsEmailLinks": "false",
"signingUiVersion": "v2",
"useNewSendingInterface": "true",
"allowApiAccess": "true",
"allowApiAccessToAccount": "true",
"allowApiSendingOnBehalfOfOthers": "true",
"allowApiSequentialSigning": "true",
"enableApiRequestLogging": "true",
"allowDocuSignDesktopClient": "false",
"allowSendersToSetRecipientEmailLanguage": "true",
"allowVaulting": "false",
"allowedToBeEnvelopeTransferRecipient": "true",
"enableTransactionPointIntegration": "false",
"powerFormRole": "admin",
"vaultingMode": "none"
}

2 changes: 2 additions & 0 deletions app/docusign/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .ds_client import DSClient
from .utils import ds_token_ok, create_api_client, authenticate
Loading