Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //The MIT License
- //Copyright( c) 2016- DocuSign, Inc. (https://www.docusign.com)
- //Permission is hereby granted, free of charge, to any person obtaining a copy
- //of this software and associated documentation files (the "Software"), to deal
- //in the Software without restriction, including without limitation the rights
- //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- //copies of the Software, and to permit persons to whom the Software is
- //furnished to do so, subject to the following conditions:
- //The above copyright notice and this permission notice shall be included in all
- //copies or substantial portions of the Software.
- //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- //SOFTWARE.
- using DocuSign.eSign.Api;
- using DocuSign.eSign.Model;
- using DocuSign.eSign.Client;
- namespace DocuSignSample
- {
- class Program
- {
- static void Main(string[] args)
- {
- string username = "[EMAIL]";
- string password = "[PASSWORD]";
- string integratorKey = "[INTEGRATOR_KEY]";
- // initialize client for desired environment (for production change to www)
- ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");
- Configuration.Default.ApiClient = apiClient;
- // configure 'X-DocuSign-Authentication' header
- string authHeader = "{\"Username\":\"" + username + "\", \"Password\":\"" + password + "\", \"IntegratorKey\":\"" + integratorKey + "\"}";
- Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
- // we will retrieve this from the login API call
- string accountId = null;
- /////////////////////////////////////////////////////////////////
- // STEP 1: LOGIN API
- /////////////////////////////////////////////////////////////////
- // login call is available in the authentication api
- AuthenticationApi authApi = new AuthenticationApi();
- LoginInformation loginInfo = authApi.Login();
- // parse the first account ID that is returned (user might belong to multiple accounts)
- accountId = loginInfo.LoginAccounts[0].AccountId;
- // Update ApiClient with the new base url from login call
- apiClient = new ApiClient(loginInfo.LoginAccounts[0].BaseUrl);
- /////////////////////////////////////////////////////////////////
- // STEP 2: CREATE ENVELOPE API
- /////////////////////////////////////////////////////////////////
- // create a new envelope which we will use to send the signature request
- EnvelopeDefinition envDef = new EnvelopeDefinition();
- envDef.EmailSubject = "[DocuSign C# SDK] - Sample Signature Request";
- // provide a valid template ID from a template in your account
- envDef.TemplateId = "[TEMPLATE_ID]";
- // assign recipient to template role by setting name, email, and role name. Note that the
- // template role name must match the placeholder role name saved in your account template.
- TemplateRole tRole = new TemplateRole();
- tRole.Email = "[SIGNER_EMAIL]";
- tRole.Name = "[SIGNER_NAME]";
- tRole.RoleName = "[ROLE_NAME]";
- // add the roles list with the our single role to the envelope
- List<TemplateRole> rolesList = new List<TemplateRole>() { tRole };
- envDef.TemplateRoles = rolesList;
- // set envelope status to "sent" to immediately send the signature request
- envDef.Status = "sent";
- // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
- EnvelopesApi envelopesApi = new EnvelopesApi();
- EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement