Last active
August 29, 2015 14:26
-
-
Save Ergin008/347617404e0a1988a37e to your computer and use it in GitHub Desktop.
Full code sample for DocuSign Embedded Signing Quickstart - uses open source NuGet Client: https://www.nuget.org/packages/DocuSign.Integration.Client.dll/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DocuSign API Quickstart - Embedded Signing | |
// | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Diagnostics; | |
// install DocuSign NuGet package or download source from GitHub: | |
// https://www.nuget.org/packages/DocuSign.Integration.Client.dll/ | |
using DocuSign.Integrations.Client; | |
namespace Quickstart_2 | |
{ | |
class EmbeddedSigning | |
{ | |
static void Main(string[] args) | |
{ | |
//======================================================================================================================= | |
// STEP 1: Login API | |
//======================================================================================================================= | |
RestSettings.Instance.DocuSignAddress = "https://demo.docusign.net"; | |
RestSettings.Instance.WebServiceUrl = RestSettings.Instance.DocuSignAddress + "/restapi/v2"; | |
RestSettings.Instance.IntegratorKey = "INTEGRATOR_KEY"; | |
Account account = new Account(); | |
account.Email = "EMAIL"; | |
account.Password = "PASSWORD"; | |
// Login API call (retrieves your baseUrl and accountId) | |
bool result = account.Login(); | |
if (!result) | |
{ | |
Console.WriteLine("Login API call failed for user {0}.\nError Code: {1}\nMessage: {2}", account.Email, account.RestError.errorCode, account.RestError.message); | |
Console.Read(); | |
return; | |
} | |
//======================================================================================================================= | |
// STEP 2: Create and Send Envelope API (with embedded recipient) | |
//======================================================================================================================= | |
// create envelope object and assign login info | |
Envelope envelope = new Envelope(); | |
envelope.Login = account; | |
envelope.EmailSubject = "Please sign my document"; | |
envelope.Recipients = new Recipients() | |
{ | |
signers = new Signer[] | |
{ | |
new Signer() | |
{ | |
email = "RECIPIENT_EMAIL", | |
name = "RECIPIENT NAME", | |
routingOrder = "1", | |
recipientId = "1", | |
clientUserId = "101" // setting |clientUserId| designates recipient as embedded | |
} | |
} | |
}; | |
Tabs tabList = new Tabs() | |
{ | |
signHereTabs = new Tab[] | |
{ | |
new Tab() | |
{ | |
documentId = 1, | |
pageNumber = 1, | |
xPosition = 100, | |
yPosition = 150 | |
} | |
} | |
}; | |
// assign our one signHere tab to the recipient | |
envelope.Recipients.signers[0].tabs = tabList; | |
// "sent" to send immediately, "created" to save as draft | |
envelope.Status = "sent"; | |
//*** Specify document and send signature request | |
result = envelope.Create("PATH/TO/DOCUMENT/TEST.PDF"); | |
//======================================================================================================================= | |
// STEP 3: Request Recipient View API (aka Signing URL) | |
//======================================================================================================================= | |
string returnUrl = "http://www.docusign.com/devcenter"; | |
string authMethod = "email"; | |
// generate the signing URL for the recipient | |
string signingUrl = envelope.GetEmbeddedSignerView(returnUrl, envelope.Recipients.signers[0]); | |
// open the recipient view URL | |
Process.Start(signingUrl); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment