From 8fa98b58efbe420ade68f651eb4f608baaae453b Mon Sep 17 00:00:00 2001 From: inbargazit Date: Wed, 7 Feb 2024 12:26:27 -0800 Subject: [PATCH] Adding Web Forms API code example --- .gitignore | 3 +- ExamplesAPIType.cs | 6 + ExamplesApiTypeExtensions.cs | 6 + JWTAuth.cs | 7 + .../JwtLoginMethodUnitTest.cs | 3 + .../Common/IRequestItemsService.cs | 2 + launcher-csharp/Common/LocalsFilter.cs | 2 + launcher-csharp/Common/RequestItemsService.cs | 11 + launcher-csharp/Startup.cs | 41 ++-- launcher-csharp/Views/Home/Index.cshtml | 1 + .../Controllers/CreateAndEmbedForm.cs | 127 +++++++++++ .../Examples/CreateAndEmbedFormService.cs | 215 ++++++++++++++++++ .../Views/CreateAndEmbedForm/Embed.cshtml | 72 ++++++ .../Views/CreateAndEmbedForm/embedForm.cshtml | 10 + .../Views/CreateAndEmbedForm/web001.cshtml | 37 +++ launcher-csharp/appsettings.example.json | 1 + .../Controllers/AccountController.cs | 4 + .../eSignature/Models/DSConfiguration.cs | 2 + launcher-csharp/eSignature/Models/Session.cs | 2 + launcher-csharp/launcher-csharp.csproj | 1 + launcher-csharp/wwwroot/js/search.js | 5 +- 21 files changed, 533 insertions(+), 25 deletions(-) create mode 100644 launcher-csharp/WebForms/Controllers/CreateAndEmbedForm.cs create mode 100644 launcher-csharp/WebForms/Examples/CreateAndEmbedFormService.cs create mode 100644 launcher-csharp/WebForms/Views/CreateAndEmbedForm/Embed.cshtml create mode 100644 launcher-csharp/WebForms/Views/CreateAndEmbedForm/embedForm.cshtml create mode 100644 launcher-csharp/WebForms/Views/CreateAndEmbedForm/web001.cshtml diff --git a/.gitignore b/.gitignore index ad8aa6e3..ce67317f 100644 --- a/.gitignore +++ b/.gitignore @@ -263,4 +263,5 @@ __pycache__/ #configuration files (secrets), should not be checked in to source control appsettings.json private.key -app.config \ No newline at end of file +app.config +web-form-config.json \ No newline at end of file diff --git a/ExamplesAPIType.cs b/ExamplesAPIType.cs index c8ac93ff..f08a9595 100644 --- a/ExamplesAPIType.cs +++ b/ExamplesAPIType.cs @@ -43,6 +43,12 @@ public enum ExamplesApiType /// [Description("con")] Connect = 5, + + /// + /// Web Forms API + /// + [Description("web")] + WebForms = 6, } public static class ExamplesApiTypeExtensions diff --git a/ExamplesApiTypeExtensions.cs b/ExamplesApiTypeExtensions.cs index 211ee38b..dc0105ff 100644 --- a/ExamplesApiTypeExtensions.cs +++ b/ExamplesApiTypeExtensions.cs @@ -43,6 +43,12 @@ public enum ExamplesApiType /// [Description("con")] Connect = 5, + + /// + /// Web Forms API + /// + [Description("web")] + WebForms = 6, } public static class ExamplesApiTypeExtensions diff --git a/JWTAuth.cs b/JWTAuth.cs index 3ae21b7d..935125a7 100644 --- a/JWTAuth.cs +++ b/JWTAuth.cs @@ -78,6 +78,13 @@ public static OAuthToken AuthenticateWithJwt(string api, string clientId, string }); } + if (apiType == ExamplesApiType.WebForms) + { + scopes.Add("webforms_read"); + scopes.Add("webforms_instance_write"); + scopes.Add("webforms_instance_read"); + } + return docuSignClient.RequestJWTUserToken( clientId, impersonatedUserId, diff --git a/launcher-csharp.Tests/JwtLoginMethodUnitTest.cs b/launcher-csharp.Tests/JwtLoginMethodUnitTest.cs index 44994bf7..36f497e8 100644 --- a/launcher-csharp.Tests/JwtLoginMethodUnitTest.cs +++ b/launcher-csharp.Tests/JwtLoginMethodUnitTest.cs @@ -92,6 +92,9 @@ private string BuildConsentUrl(ExamplesApiType apiType, TestConfig testConfig) scopes += "%20user_read%20user_write%20organization_read%20account_read%20group_read%20" + "permission_read%20identity_provider_read%20domain_read%20user_data_redact%20" + "asset_group_account_read%20asset_group_account_clone_write%20asset_group_account_clone_read"; + } else if (apiType == ExamplesApiType.WebForms) + { + scopes += "%20webforms_manage"; } string caret = ""; diff --git a/launcher-csharp/Common/IRequestItemsService.cs b/launcher-csharp/Common/IRequestItemsService.cs index 3262643c..ea254750 100644 --- a/launcher-csharp/Common/IRequestItemsService.cs +++ b/launcher-csharp/Common/IRequestItemsService.cs @@ -34,6 +34,8 @@ public interface IRequestItemsService public string TemplateId { get; set; } + public string WebFormsTemplateId { get; set; } + public string PausedEnvelopeId { get; set; } public string Status { get; set; } diff --git a/launcher-csharp/Common/LocalsFilter.cs b/launcher-csharp/Common/LocalsFilter.cs index 7a66e728..c92f5ddb 100644 --- a/launcher-csharp/Common/LocalsFilter.cs +++ b/launcher-csharp/Common/LocalsFilter.cs @@ -97,6 +97,7 @@ public void OnActionExecuting(ActionExecutingContext context) BasePath = identity.FindFirst(x => x.Type.Equals("base_uri")).Value, RoomsApiBasePath = this.configuration["DocuSign:RoomsApiEndpoint"], AdminApiBasePath = this.configuration["DocuSign:AdminApiEndpoint"], + WebFormsBasePath = this.configuration["DocuSign:WebFormsBasePath"], } : new Session @@ -106,6 +107,7 @@ public void OnActionExecuting(ActionExecutingContext context) BasePath = this.requestItemsService.Session.BasePath, RoomsApiBasePath = this.configuration["DocuSign:RoomsApiEndpoint"], AdminApiBasePath = this.configuration["DocuSign:AdminApiEndpoint"], + WebFormsBasePath = this.configuration["DocuSign:WebFormsBasePath"], }; this.requestItemsService.Session = locals.Session; diff --git a/launcher-csharp/Common/RequestItemsService.cs b/launcher-csharp/Common/RequestItemsService.cs index 93c4ddf8..e0a18747 100644 --- a/launcher-csharp/Common/RequestItemsService.cs +++ b/launcher-csharp/Common/RequestItemsService.cs @@ -148,6 +148,12 @@ public string TemplateId set => this.cache.Set(this.GetKey("TemplateId"), value); } + public string WebFormsTemplateId + { + get => this.cache.Get(this.GetKey("WebFormsTemplateId")); + set => this.cache.Set(this.GetKey("WebFormsTemplateId"), value); + } + public string ClickwrapId { get => this.cache.Get(this.GetKey("ClickwrapId")); @@ -206,6 +212,7 @@ public void UpdateUserFromJwt() BasePath = account.BaseUri, RoomsApiBasePath = this.Configuration["DocuSign:RoomsApiEndpoint"], AdminApiBasePath = this.Configuration["DocuSign:AdminApiEndpoint"], + WebFormsBasePath = this.Configuration["DocuSign:WebFormsBasePath"], }; } @@ -255,6 +262,10 @@ public string IdentifyApiOfCodeExample(string eg) { currentApiType = ExamplesApiType.Connect.ToString(); } + else if (eg.Contains(ExamplesApiType.WebForms.ToKeywordString())) + { + currentApiType = ExamplesApiType.WebForms.ToString(); + } else { currentApiType = ExamplesApiType.ESignature.ToString(); diff --git a/launcher-csharp/Startup.cs b/launcher-csharp/Startup.cs index 36238fa4..6520295e 100644 --- a/launcher-csharp/Startup.cs +++ b/launcher-csharp/Startup.cs @@ -7,11 +7,14 @@ namespace DocuSign.CodeExamples { using System; using System.Collections.Generic; + using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; using System.Text.Json; + using System.Text.RegularExpressions; using System.Threading.Tasks; + using System.Web; using DocuSign.CodeExamples.Common; using DocuSign.CodeExamples.Models; using DocuSign.Rooms.Api; @@ -35,7 +38,7 @@ public Startup(IConfiguration configuration) { this.Configuration = configuration; - this.apiTypes.Add(ExamplesApiType.ESignature, new List { "signature" }); + this.apiTypes.Add(ExamplesApiType.ESignature, new List { "signature", }); this.apiTypes.Add(ExamplesApiType.Rooms, new List { @@ -77,6 +80,11 @@ public Startup(IConfiguration configuration) "asset_group_account_clone_write", "asset_group_account_clone_read", }); + + this.apiTypes.Add(ExamplesApiType.WebForms, new List + { + "signature", "webforms_read", "webforms_instance_write", "webforms_instance_read", + }); } public IConfiguration Configuration { get; } @@ -175,28 +183,7 @@ public void ConfigureServices(IServiceCollection services) { List scopesForCurrentApi = this.apiTypes.GetValueOrDefault(Enum.Parse(this.Configuration["API"])); - foreach (var api in this.apiTypes) - { - if (this.Configuration["API"] != api.Key.ToString()) - { - foreach (var scope in api.Value) - { - if (scopesForCurrentApi != null && !scopesForCurrentApi.Contains(scope)) - { - var scopeWithSeperator = scope + "%20"; - - if (redirectContext.RedirectUri.Contains(scopeWithSeperator)) - { - redirectContext.RedirectUri = redirectContext.RedirectUri.Replace(scopeWithSeperator, string.Empty); - } - else - { - redirectContext.RedirectUri = redirectContext.RedirectUri.Replace(scope, string.Empty); - } - } - } - } - } + redirectContext.RedirectUri = this.UpdateRedirectUriScopes(redirectContext.RedirectUri, scopesForCurrentApi); redirectContext.HttpContext.Response.Redirect(redirectContext.RedirectUri); return Task.FromResult(0); @@ -327,5 +314,13 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) return keyValue; } + + private string UpdateRedirectUriScopes(string uri, List wantedScopes) + { + const string pattern = @"(?:&|\?)scope=([^&]+)"; + + var encodedScopes = string.Join(" ", wantedScopes); + return Regex.Replace(uri, pattern, $"&scope={HttpUtility.UrlPathEncode(encodedScopes)}"); + } } } diff --git a/launcher-csharp/Views/Home/Index.cshtml b/launcher-csharp/Views/Home/Index.cshtml index 27774867..37fea8a3 100644 --- a/launcher-csharp/Views/Home/Index.cshtml +++ b/launcher-csharp/Views/Home/Index.cshtml @@ -43,6 +43,7 @@ : ((ApIs) api).Name.ToLower() == ExamplesApiType.Monitor.ToString().ToLower() ? ExamplesApiType.Monitor.ToKeywordString() : ((ApIs) api).Name.ToLower() == ExamplesApiType.Rooms.ToString().ToLower() ? ExamplesApiType.Rooms.ToKeywordString() : ((ApIs) api).Name.ToLower() == ExamplesApiType.Connect.ToString().ToLower() ? ExamplesApiType.Connect.ToKeywordString() + : ((ApIs) api).Name.ToLower() == ExamplesApiType.WebForms.ToString().ToLower() ? ExamplesApiType.WebForms.ToKeywordString() : ExamplesApiType.Admin.ToKeywordString(); @foreach(var exampleGroup in api.Groups) diff --git a/launcher-csharp/WebForms/Controllers/CreateAndEmbedForm.cs b/launcher-csharp/WebForms/Controllers/CreateAndEmbedForm.cs new file mode 100644 index 00000000..daa99b49 --- /dev/null +++ b/launcher-csharp/WebForms/Controllers/CreateAndEmbedForm.cs @@ -0,0 +1,127 @@ +// +// Copyright (c) DocuSign. All rights reserved. +// + +namespace DocuSign.CodeExamples.WebForms.Controllers +{ + using System; + using System.Collections.Generic; + using System.Linq; + using DocuSign.CodeExamples.Common; + using DocuSign.CodeExamples.Controllers; + using DocuSign.CodeExamples.Models; + using DocuSign.eSign.Client; + using DocuSign.eSign.Model; + using DocuSign.WebForms.Examples; + using DocuSign.WebForms.Model; + using Microsoft.AspNetCore.Mvc; + using Microsoft.Extensions.Configuration; + + [Area("WebForms")] + [Route("web001")] + public class CreateAndEmbedForm : EgController + { + public const string TemplateName = "Web Form Example Template"; + + private IConfiguration configuration; + + public CreateAndEmbedForm( + DsConfiguration config, + IConfiguration configuration, + LauncherTexts launcherTexts, + IRequestItemsService requestItemsService) + : base(config, launcherTexts, requestItemsService) + { + this.configuration = configuration; + this.CodeExampleText = this.GetExampleText(this.EgName, ExamplesApiType.WebForms); + this.ViewBag.title = this.CodeExampleText.ExampleName; + } + + public override string EgName => "web001"; + + [SetViewBag] + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult CheckTemplates() + { + string basePath = this.RequestItemsService.Session.BasePath + "/restapi"; + string accessToken = this.RequestItemsService.User.AccessToken; + string accountId = this.RequestItemsService.Session.AccountId; + + //ds-snippet-start:WebForms1Step2 + var docuSignClient = new DocuSignClient(basePath); + docuSignClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken); + //ds-snippet-end:WebForms1Step2 + + List templates = CreateAndEmbedFormService.GetTemplatesByName( + docuSignClient, + accountId, + TemplateName); + + if (templates == null || templates.Count == 0) + { + TemplateSummary template = CreateAndEmbedFormService.CreateTemplate( + docuSignClient, + accountId, + this.Config.DocumentTemplatePdf, + TemplateName); + + this.RequestItemsService.WebFormsTemplateId = template.TemplateId; + } + else + { + this.RequestItemsService.WebFormsTemplateId = templates.First().TemplateId; + } + + CreateAndEmbedFormService.AddTemplateIdToForm( + this.Config.WebFormConfig, + this.RequestItemsService.WebFormsTemplateId); + + this.ViewBag.CodeExampleText = this.CodeExampleText; + this.ViewBag.Description = this.CodeExampleText.AdditionalPages + .First(x => x.Name == "create_web_form").ResultsPageText; + + return this.View("embedForm"); + } + + [MustAuthenticate] + [SetViewBag] + [Route("EmbedForm")] + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult EmbedForm() + { + string basePath = this.RequestItemsService.Session.WebFormsBasePath; + string accessToken = this.RequestItemsService.User.AccessToken; + string accountId = this.RequestItemsService.Session.AccountId; + + var docuSignClient = new DocuSign.WebForms.Client.DocuSignClient(basePath); + docuSignClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken); + + WebFormSummaryList forms = CreateAndEmbedFormService.GetForms( + docuSignClient, + accountId); + + if (forms.Items == null || forms.Items.Count == 0) + { + this.ViewBag.CodeExampleText = this.CodeExampleText; + this.ViewBag.Description = this.CodeExampleText.AdditionalPages + .First(x => x.Name == "create_web_form").ResultsPageText; + + return this.View("embedForm"); + } + + string formId = forms.Items.First(x => x.FormProperties.Name == TemplateName).Id; + WebFormInstance form = CreateAndEmbedFormService.CreateInstance( + docuSignClient, + accountId, + formId); + + this.ViewBag.InstanceToken = form.InstanceToken; + this.ViewBag.Url = form.FormUrl; + this.ViewBag.IntegrationKey = this.configuration["DocuSign:ClientId"]; + + return this.View("Embed"); + } + } +} diff --git a/launcher-csharp/WebForms/Examples/CreateAndEmbedFormService.cs b/launcher-csharp/WebForms/Examples/CreateAndEmbedFormService.cs new file mode 100644 index 00000000..0e11f433 --- /dev/null +++ b/launcher-csharp/WebForms/Examples/CreateAndEmbedFormService.cs @@ -0,0 +1,215 @@ +// +// Copyright (c) DocuSign. All rights reserved. +// + +namespace DocuSign.WebForms.Examples +{ + using System; + using System.Collections.Generic; + using System.IO; + using DocuSign.eSign.Api; + using DocuSign.eSign.Client; + using DocuSign.eSign.Model; + using DocuSign.WebForms.Api; + using DocuSign.WebForms.Model; + + public static class CreateAndEmbedFormService + { + public static WebFormSummaryList GetForms(Client.DocuSignClient docuSignClient, string accountId) + { + FormManagementApi formManagementApi = new FormManagementApi(docuSignClient); + FormManagementApi.ListFormsOptions listFormsOptions = new FormManagementApi.ListFormsOptions(); + listFormsOptions.search = "Web Form Example Template"; + return formManagementApi.ListForms(accountId, listFormsOptions); + } + + public static void AddTemplateIdToForm(string fileLocation, string templateId) + { + string targetString = "template-id"; + + try + { + string fileContent = File.ReadAllText(fileLocation); + string modifiedContent = fileContent.Replace(targetString, templateId); + + File.WriteAllText(fileLocation, modifiedContent); + } + catch (Exception ex) + { + Console.WriteLine($"An error occurred: {ex.Message}"); + } + } + + public static WebFormInstance CreateInstance( + Client.DocuSignClient docuSignClient, + string accountId, + string formId) + { + //ds-snippet-start:WebForms1Step4 + var formValues = new WebFormValues + { + { "PhoneNumber", "555-555-5555" }, + { "Yes", new[] { "Yes" } }, + { "Company", "Tally" }, + { "JobTitle", "Programmer Writer" }, + }; + + var options = new CreateInstanceRequestBody() + { + ClientUserId = "1234-5678-abcd-ijkl", + FormValues = formValues, + ExpirationOffset = 3600, + }; + //ds-snippet-end:WebForms1Step4 + + //ds-snippet-start:WebForms1Step5 + FormInstanceManagementApi formManagementApi = new FormInstanceManagementApi(docuSignClient); + return formManagementApi.CreateInstance(accountId, formId, options); + //ds-snippet-end:WebForms1Step5 + } + + public static List GetTemplatesByName( + DocuSignClient docuSignClient, + string accountId, + string templateName) + { + //ds-snippet-start:WebForms1Step3 + var templatesApi = new TemplatesApi(docuSignClient); + var listTemplateOptions = new TemplatesApi.ListTemplatesOptions(); + listTemplateOptions.searchText = templateName; + + EnvelopeTemplateResults templates = templatesApi.ListTemplates(accountId, listTemplateOptions); + //ds-snippet-end:WebForms1Step3 + + return templates.EnvelopeTemplates; + } + + public static TemplateSummary CreateTemplate( + DocuSignClient docuSignClient, + string accountId, + string documentPdf, + string templateName) + { + TemplatesApi templatesApi = new TemplatesApi(docuSignClient); + + EnvelopeTemplate templateReqObject = PrepareEnvelopeTemplate(templateName, documentPdf); + + TemplateSummary template = templatesApi.CreateTemplate(accountId, templateReqObject); + + return template; + } + + public static EnvelopeTemplate PrepareEnvelopeTemplate(string resultsTemplateName, string documentPdf) + { + Document document = new Document() + { + DocumentBase64 = Convert.ToBase64String(File.ReadAllBytes(documentPdf)), + Name = "World_Wide_Web_Form", + FileExtension = "pdf", + DocumentId = "1", + }; + + Signer signer = new Signer() + { + RoleName = "signer", + RecipientId = "1", + RoutingOrder = "1", + }; + + Tabs signerTabs = new Tabs() + { + CheckboxTabs = new List + { + new Checkbox() + { + DocumentId = "1", + TabLabel = "Yes", + AnchorString = "/SMS/", + AnchorUnits = "pixels", + AnchorXOffset = "20", + AnchorYOffset = "10", + }, + }, + SignHereTabs = new List + { + new SignHere() + { + DocumentId = "1", + TabLabel = "Signature", + AnchorString = "/SignHere/", + AnchorUnits = "pixels", + AnchorXOffset = "20", + AnchorYOffset = "10", + }, + }, + TextTabs = new List + { + new Text() + { + DocumentId = "1", + TabLabel = "FullName", + AnchorString = "/FullName/", + AnchorUnits = "pixels", + AnchorXOffset = "20", + AnchorYOffset = "10", + }, + new Text() + { + DocumentId = "1", + TabLabel = "PhoneNumber", + AnchorString = "/PhoneNumber/", + AnchorUnits = "pixels", + AnchorXOffset = "20", + AnchorYOffset = "10", + }, + new Text() + { + DocumentId = "1", + TabLabel = "Company", + AnchorString = "/Company/", + AnchorUnits = "pixels", + AnchorXOffset = "20", + AnchorYOffset = "10", + }, + new Text() + { + DocumentId = "1", + TabLabel = "JobTitle", + AnchorString = "/Title/", + AnchorUnits = "pixels", + AnchorXOffset = "20", + AnchorYOffset = "10", + }, + }, + DateSignedTabs = new List + { + new DateSigned() + { + DocumentId = "1", + TabLabel = "DateSigned", + AnchorString = "/Date/", + AnchorUnits = "pixels", + AnchorXOffset = "20", + AnchorYOffset = "10", + }, + }, + }; + + signer.Tabs = signerTabs; + + Recipients recipients = new Recipients(); + recipients.Signers = new List { signer }; + + return new EnvelopeTemplate() + { + Description = "Example template created via the API", + Name = resultsTemplateName, + Shared = "false", + Documents = new List { document }, + EmailSubject = "Please sign this document", + Recipients = recipients, + Status = "created", + }; + } + } +} diff --git a/launcher-csharp/WebForms/Views/CreateAndEmbedForm/Embed.cshtml b/launcher-csharp/WebForms/Views/CreateAndEmbedForm/Embed.cshtml new file mode 100644 index 00000000..f74fbdbd --- /dev/null +++ b/launcher-csharp/WebForms/Views/CreateAndEmbedForm/Embed.cshtml @@ -0,0 +1,72 @@ +@{ + //ds-snippet-start:WebForms1Step6 +} + + + + + @Html.Raw("") + + + +
+
+
The web form has been embedded below using the DocuSign.js library.
+
+

Web Form will render here

+
+
+
+ + + +

@Html.Raw(ViewBag.SupportingTexts.ContinueButton)

+ +@Html.Raw("") + + +@{ + //ds-snippet-end:WebForms1Step6 +} \ No newline at end of file diff --git a/launcher-csharp/WebForms/Views/CreateAndEmbedForm/embedForm.cshtml b/launcher-csharp/WebForms/Views/CreateAndEmbedForm/embedForm.cshtml new file mode 100644 index 00000000..387bdb6f --- /dev/null +++ b/launcher-csharp/WebForms/Views/CreateAndEmbedForm/embedForm.cshtml @@ -0,0 +1,10 @@ +

@Html.Raw(ViewBag.CodeExampleText.ExampleName)

+ +

+ @ViewBag.Description +

+ +
+ +
+ diff --git a/launcher-csharp/WebForms/Views/CreateAndEmbedForm/web001.cshtml b/launcher-csharp/WebForms/Views/CreateAndEmbedForm/web001.cshtml new file mode 100644 index 00000000..21b8e5af --- /dev/null +++ b/launcher-csharp/WebForms/Views/CreateAndEmbedForm/web001.cshtml @@ -0,0 +1,37 @@ +@{ + var additionalPages = ViewBag.CodeExampleText.AdditionalPages; + var description = ""; + foreach (var additionalPage in additionalPages) + { + if (additionalPage.Name == "create_web_form_template") + { + description = additionalPage.ResultsPageText; + } + } +} + +

@Html.Raw(ViewBag.CodeExampleText.ExampleName)

+

+ @description +

+ +

+ API methods used: + Templates::list, and + Templates::create. +

+ +

+ @Html.Raw( + @String.Format( + ViewBag.SupportingTexts.ViewSourceFile, + "CreateAndEmbedFormService.cs" + ) + ) +

+ + +
+ +
+ diff --git a/launcher-csharp/appsettings.example.json b/launcher-csharp/appsettings.example.json index 7ab79b9e..879bbfbd 100644 --- a/launcher-csharp/appsettings.example.json +++ b/launcher-csharp/appsettings.example.json @@ -15,6 +15,7 @@ "AppUrl": "https://localhost:44333", "RoomsApiEndpoint": "https://demo.rooms.docusign.com", "AdminApiEndpoint": "https://api-d.docusign.net/management", + "WebFormsBasePath": "https://demo.services.docusign.net/webforms/v1.1", "CodeExamplesManifest": "https://raw.githubusercontent.com/docusign/code-examples-csharp/master/manifest/CodeExamplesManifest.json", "SignerEmail": "{SIGNER_EMAIL}", "SignerName": "{SIGNER_NAME}", diff --git a/launcher-csharp/eSignature/Controllers/AccountController.cs b/launcher-csharp/eSignature/Controllers/AccountController.cs index 022e7598..f740b1f7 100644 --- a/launcher-csharp/eSignature/Controllers/AccountController.cs +++ b/launcher-csharp/eSignature/Controllers/AccountController.cs @@ -118,6 +118,10 @@ private string BuildConsentUrl() { scopes += " user_read user_write organization_read account_read group_read permission_read identity_provider_read domain_read user_data_redact asset_group_account_read asset_group_account_clone_write asset_group_account_clone_read"; } + else if (apiType == ExamplesApiType.WebForms) + { + scopes += " webforms_read webforms_instance_write webforms_instance_read"; + } return this.Configuration["DocuSign:AuthorizationEndpoint"] + "?response_type=code" + "&scope=" + scopes + diff --git a/launcher-csharp/eSignature/Models/DSConfiguration.cs b/launcher-csharp/eSignature/Models/DSConfiguration.cs index 208f075c..ee04288e 100644 --- a/launcher-csharp/eSignature/Models/DSConfiguration.cs +++ b/launcher-csharp/eSignature/Models/DSConfiguration.cs @@ -10,6 +10,8 @@ public class DsConfiguration public string DocDocx = "World_Wide_Corp_Battle_Plan_Trafalgar.docx"; public string TabsDocx = "World_Wide_Corp_salary.docx"; public string DocPdf = "World_Wide_Corp_lorem.pdf"; + public string DocumentTemplatePdf = "World_Wide_Corp_Web_Form.pdf"; + public string WebFormConfig = "web-form-config.json"; public string OfferDocDocx = "Offer_Letter_Demo.docx"; public string DocCsv = "UserData.csv"; public string DocHtml = "doc_1.html"; diff --git a/launcher-csharp/eSignature/Models/Session.cs b/launcher-csharp/eSignature/Models/Session.cs index e5cd8baa..b89f02ea 100644 --- a/launcher-csharp/eSignature/Models/Session.cs +++ b/launcher-csharp/eSignature/Models/Session.cs @@ -12,6 +12,8 @@ public class Session public string BasePath { get; set; } + public string WebFormsBasePath { get; set; } + public string RoomsApiBasePath { get; set; } public string AdminApiBasePath { get; set; } diff --git a/launcher-csharp/launcher-csharp.csproj b/launcher-csharp/launcher-csharp.csproj index fd9271da..2e9b88e0 100644 --- a/launcher-csharp/launcher-csharp.csproj +++ b/launcher-csharp/launcher-csharp.csproj @@ -41,6 +41,7 @@ + diff --git a/launcher-csharp/wwwroot/js/search.js b/launcher-csharp/wwwroot/js/search.js index 38c203b2..eddd1a72 100644 --- a/launcher-csharp/wwwroot/js/search.js +++ b/launcher-csharp/wwwroot/js/search.js @@ -5,7 +5,8 @@ CLICK: 'click', ROOMS: 'rooms', ADMIN: 'admin', - CONNECT: 'connect' + CONNECT: 'connect', + WEBFORMS: 'webforms' }; let processJSONData = function () { @@ -125,6 +126,8 @@ return "eg"; case API_TYPES.CONNECT: return "con"; + case API_TYPES.WEBFORMS: + return "web"; } }