Last active
July 9, 2016 02:17
-
-
Save Ergin008/6062abbcc9f1a1110d97 to your computer and use it in GitHub Desktop.
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
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 DocuSignQuickstart | |
{ | |
class EmbeddedSigningSample | |
{ | |
static void Main(string[] args) | |
{ | |
// Instantiate the client | |
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; | |
} | |
// create envelope object and assign login info | |
Envelope envelope = new Envelope(); | |
envelope.Login = account; | |
envelope.EmailSubject = "EMAIL_SUBJECT"; | |
envelope.Recipients = new Recipients() | |
{ | |
signers = new Signer[] | |
{ | |
new Signer() | |
{ | |
email = "RECIPIENT_EMAIL", | |
name = "RECIPIENT NAME", | |
routingOrder = "1", | |
recipientId = "1", | |
clientUserId = "101" // must set |clientUserId| for Embedded Signing! | |
} | |
} | |
}; | |
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"); | |
// set the redirect URL for post signing and also the main auth method | |
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