/// <summary> /// Initializes a new instance of the <see cref="UsersApi"/> class /// using Configuration object /// </summary> /// <param name="configuration">An instance of Configuration</param> /// <returns></returns> public UsersApi(Configuration configuration = null) { if (configuration == null) // use the default one in Configuration this.Configuration = Configuration.Default; else this.Configuration = configuration; }
public string GetAccountID() { #region auth_details string integratorKey = ConfigurationManager.AppSettings["IntegratorKey"]; string email = ConfigurationManager.AppSettings["DocuSignUserEmail"]; string password = ConfigurationManager.AppSettings["DocuSignPassword"]; string authHeader = "{\"Username\":\"" + email + "\", \"Password\":\"" + password + "\", \"IntegratorKey\":\"" + integratorKey + "\"}"; #endregion DocuSign.eSign.Client.Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader); #region attemptlogin ApiClient client = new ApiClient(basePath: "https://demo.docusign.net/restapi"); DocuSign.eSign.Client.Configuration configHeader = new DocuSign.eSign.Client.Configuration(client); configHeader.AddDefaultHeader("X-DocuSign-Authentication", authHeader); AuthenticationApi authApi = new AuthenticationApi(configHeader); LoginInformation loginInfo = authApi.Login(); #endregion return(loginInfo.LoginAccounts[0].AccountId); }
private static DocuSign.eSign.Client.Configuration GetConfiguration(DocuSignAccount account, OAuth20Token token) { if (account == null) { throw new ArgumentNullException("account"); } if (token == null) { throw new ArgumentNullException("token"); } var apiClient = new ApiClient(account.BaseUri + "/restapi"); var configuration = new DocuSign.eSign.Client.Configuration { ApiClient = apiClient }; configuration.AddDefaultHeader("Authorization", "Bearer " + DocuSignToken.GetRefreshedToken(token)); return(configuration); }
private static string CreateEnvelope(string accountId, Document document, DocuSignData docuSignData, DocuSign.eSign.Client.Configuration configuration) { var eventNotification = new EventNotification { EnvelopeEvents = new List <EnvelopeEvent> { //new EnvelopeEvent {EnvelopeEventStatusCode = DocuSignStatus.Sent.ToString()}, //new EnvelopeEvent {EnvelopeEventStatusCode = DocuSignStatus.Delivered.ToString()}, new EnvelopeEvent { EnvelopeEventStatusCode = DocuSignStatus.Completed.ToString() }, new EnvelopeEvent { EnvelopeEventStatusCode = DocuSignStatus.Declined.ToString() }, new EnvelopeEvent { EnvelopeEventStatusCode = DocuSignStatus.Voided.ToString() }, }, IncludeDocumentFields = "true", //RecipientEvents = new List<RecipientEvent> // { // new RecipientEvent {RecipientEventStatusCode = "Sent"}, // new RecipientEvent {RecipientEventStatusCode = "Delivered"}, // new RecipientEvent {RecipientEventStatusCode = "Completed"}, // new RecipientEvent {RecipientEventStatusCode = "Declined"}, // new RecipientEvent {RecipientEventStatusCode = "AuthenticationFailed"}, // new RecipientEvent {RecipientEventStatusCode = "AutoResponded"}, // }, Url = CommonLinkUtility.GetFullAbsolutePath(DocuSignHandler.Path + "?" + FilesLinkUtility.Action + "=webhook"), }; Global.Logger.Debug("DocuSign hook url: " + eventNotification.Url); var signers = new List <Signer>(); docuSignData.Users.ForEach(uid => { try { var user = CoreContext.UserManager.GetUsers(uid); signers.Add(new Signer { Email = user.Email, Name = user.DisplayUserName(false), RecipientId = user.ID.ToString(), }); } catch (Exception ex) { Log.Error("Signer is undefined", ex); } }); var envelopeDefinition = new EnvelopeDefinition { CustomFields = new CustomFields { TextCustomFields = new List <TextCustomField> { new TextCustomField { Name = UserField, Value = SecurityContext.CurrentAccount.ID.ToString() }, } }, Documents = new List <Document> { document }, EmailBlurb = docuSignData.Message, EmailSubject = docuSignData.Name, EventNotification = eventNotification, Recipients = new Recipients { Signers = signers, }, Status = "created", }; var envelopesApi = new EnvelopesApi(configuration); var envelopeSummary = envelopesApi.CreateEnvelope(accountId, envelopeDefinition); Global.Logger.Debug("DocuSign createdEnvelope: " + envelopeSummary.EnvelopeId); var envelopeId = envelopeSummary.EnvelopeId; var url = envelopesApi.CreateSenderView(accountId, envelopeId, new ReturnUrlRequest { ReturnUrl = CommonLinkUtility.GetFullAbsolutePath(DocuSignHandler.Path + "?" + FilesLinkUtility.Action + "=redirect") }); Global.Logger.Debug("DocuSign senderView: " + url.Url); return(url.Url); }