public IActionResult Create() { // Check the token with minimal buffer time. bool tokenOk = CheckToken(3); if (!tokenOk) { // We could store the parameters of the requested operation so it could be // restarted automatically. But since it should be rare to have a token issue // here, we'll make the user re-enter the form data after authentication RequestItemsService.EgName = EgName; return(Redirect("/ds/mustAuthenticate")); } var basePath = RequestItemsService.Session.BasePath + "/restapi"; // Step 1: Obtain your OAuth token var accessToken = RequestItemsService.User.AccessToken; // Represents your {ACCESS_TOKEN} var accountId = RequestItemsService.Session.AccountId; // Rrepresents your {ACCOUNT_ID} var envelopeId = RequestItemsService.EnvelopeId; // Step 2: Construct your API headers var apiClient = new ApiClient(basePath); apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken); // Step 3: Call the eSignature REST API var envelopesApi = new EnvelopesApi(apiClient); CustomFieldsEnvelope results = envelopesApi.ListCustomFields(accountId, envelopeId); ViewBag.h1 = "Envelope custom field data"; ViewBag.message = "Results from the EnvelopeCustomFields::list method:"; ViewBag.Locals.Json = JsonConvert.SerializeObject(results, Formatting.Indented); return(View("example_done")); }
internal static bool EnvelopeCustomFieldsEqual(CustomFieldsEnvelope cfe) { if (cfe == null && EnvelopeCustomFields == null) return true; if (cfe.TextCustomFields != null) { if (EnvelopeCustomFields.TextCustomFields == null) return false; if (cfe.TextCustomFields.Count != EnvelopeCustomFields.TextCustomFields.Count) return false; bool textFieldFound = false; foreach (var cfeItem in cfe.TextCustomFields) { foreach (var ecf in EnvelopeCustomFields.TextCustomFields) { if (cfeItem.Name == ecf.Name && cfeItem.Value == ecf.Value) { textFieldFound = true; break; } } if (!textFieldFound) return false; textFieldFound = false; } } else { if (EnvelopeCustomFields.TextCustomFields != null) return false; } return true; }
public void ListCustomFieldsTest() { CreateCustomFieldsTest(); EnvelopesApi envelopesApi = new EnvelopesApi(); CustomFieldsEnvelope cfe = envelopesApi.ListCustomFields(TestConfig.AccountId, TestConfig.EnvelopeId); Assert.IsNotNull(cfe); Assert.IsTrue(TestConfig.EnvelopeCustomFieldsEqual(cfe)); }
internal static bool EnvelopeCustomFieldsEqual(CustomFieldsEnvelope cfe) { if (cfe == null && EnvelopeCustomFields == null) { return(true); } if (cfe.TextCustomFields != null) { if (EnvelopeCustomFields.TextCustomFields == null) { return(false); } if (cfe.TextCustomFields.Count != EnvelopeCustomFields.TextCustomFields.Count) { return(false); } bool textFieldFound = false; foreach (var cfeItem in cfe.TextCustomFields) { foreach (var ecf in EnvelopeCustomFields.TextCustomFields) { if (cfeItem.Name == ecf.Name && cfeItem.Value == ecf.Value) { textFieldFound = true; break; } } if (!textFieldFound) { return(false); } textFieldFound = false; } } else { if (EnvelopeCustomFields.TextCustomFields != null) { return(false); } } return(true); }