diff --git a/DocuSign.Integrations.Client/Envelope.cs b/DocuSign.Integrations.Client/Envelope.cs index 52dfa5fb2..259c1ea13 100755 --- a/DocuSign.Integrations.Client/Envelope.cs +++ b/DocuSign.Integrations.Client/Envelope.cs @@ -610,204 +610,204 @@ public bool GetCustomFields() throw; } } - - /// - /// Creates an envelope for the user without a document. - /// - /// true if successful, false otherwise - private bool CreateWithoutDocument() + + /// + /// Creates an envelope for the user without a document. + /// + /// true if successful, false otherwise + private bool CreateWithoutDocument() { CheckAPIPreRequisites(); - try - { - RequestInfo req = new RequestInfo(); - req.RequestContentType = "application/json"; - req.AcceptContentType = "application/json"; - req.BaseUrl = this.Login.BaseUrl; - req.LoginEmail = this.Login.Email; - req.ApiPassword = this.Login.ApiPassword; - req.Uri = "/envelopes?api_password=true"; - req.HttpMethod = "POST"; - req.IntegratorKey = RestSettings.Instance.IntegratorKey; - - RequestBuilder builder = new RequestBuilder(); - builder.Proxy = this.Proxy; - builder.Request = req; - - List requestBodies = new List(); - RequestBody rb = new RequestBody(); - - rb.Text = this.CreateJson(new List()); - - if (string.IsNullOrEmpty(rb.Text) == true) - { - return false; - } - - requestBodies.Add(rb); - - req.RequestBody = requestBodies.ToArray(); - builder.Request = req; - ResponseInfo response = builder.MakeRESTRequest(); - this.Trace(builder, response); - - if (response.StatusCode == HttpStatusCode.Created) - { - this.ParseCreateResponse(response); - if (Status == "sent") - { - GetRecipientView(); - } - else - { - GetSenderView(string.Empty); - } - } - else - { - this.ParseErrorResponse(response); - } - return response.StatusCode == HttpStatusCode.Created; - } - catch (Exception ex) - { - if (ex is WebException || ex is NotSupportedException || ex is InvalidOperationException || ex is ProtocolViolationException) - { - // Once we get the debugging logger integrated into this project, we should write a log entry here - return false; - } - - throw; - } - } - - /// - /// Adds tabs to the envelope for the first/default recipient - /// - /// List of tabs to add - /// true if successful, false otherwise - public bool AddTabs(TabCollection tabs) + try + { + RequestInfo req = new RequestInfo(); + req.RequestContentType = "application/json"; + req.AcceptContentType = "application/json"; + req.BaseUrl = this.Login.BaseUrl; + req.LoginEmail = this.Login.Email; + req.ApiPassword = this.Login.ApiPassword; + req.Uri = "/envelopes?api_password=true"; + req.HttpMethod = "POST"; + req.IntegratorKey = RestSettings.Instance.IntegratorKey; + + RequestBuilder builder = new RequestBuilder(); + builder.Proxy = this.Proxy; + builder.Request = req; + + List requestBodies = new List(); + RequestBody rb = new RequestBody(); + + rb.Text = this.CreateJson(new List()); + + if (string.IsNullOrEmpty(rb.Text) == true) + { + return false; + } + + requestBodies.Add(rb); + + req.RequestBody = requestBodies.ToArray(); + builder.Request = req; + ResponseInfo response = builder.MakeRESTRequest(); + this.Trace(builder, response); + + if (response.StatusCode == HttpStatusCode.Created) + { + this.ParseCreateResponse(response); + if (Status == "sent") + { + GetRecipientView(); + } + else + { + GetSenderView(string.Empty); + } + } + else + { + this.ParseErrorResponse(response); + } + return response.StatusCode == HttpStatusCode.Created; + } + catch (Exception ex) + { + if (ex is WebException || ex is NotSupportedException || ex is InvalidOperationException || ex is ProtocolViolationException) + { + // Once we get the debugging logger integrated into this project, we should write a log entry here + return false; + } + + throw; + } + } + + /// + /// Adds tabs to the envelope for the first/default recipient + /// + /// List of tabs to add + /// true if successful, false otherwise + public bool AddTabs(TabCollection tabs) { CheckAPIPreRequisites(); - try - { - RequestInfo req = new RequestInfo(); - req.RequestContentType = "application/json"; - req.AcceptContentType = "application/json"; - req.BaseUrl = this.Login.BaseUrl; - req.LoginEmail = this.Login.Email; + try + { + RequestInfo req = new RequestInfo(); + req.RequestContentType = "application/json"; + req.AcceptContentType = "application/json"; + req.BaseUrl = this.Login.BaseUrl; + req.LoginEmail = this.Login.Email; req.ApiPassword = this.Login.ApiPassword; - req.Uri = string.Format("/envelopes/{0}/recipients/{1}/tabs", this.EnvelopeId, (string)(GetFirstRecipients().First())["recipientIdGuid"]); - req.HttpMethod = "POST"; - req.IntegratorKey = RestSettings.Instance.IntegratorKey; - - RequestBuilder builder = new RequestBuilder(); - builder.Proxy = this.Proxy; - builder.Request = req; - - List requestBodies = new List(); - RequestBody rb = new RequestBody(); - - foreach (var tab in tabs.textTabs) - tab.tabLabel = Guid.NewGuid().ToString(); - JsonSerializerSettings settings = new JsonSerializerSettings(); - settings.NullValueHandling = NullValueHandling.Ignore; - rb.Text = JsonConvert.SerializeObject(tabs, settings); - - if (string.IsNullOrEmpty(rb.Text) == true) - { - return false; - } - - requestBodies.Add(rb); - - req.RequestBody = requestBodies.ToArray(); - builder.Request = req; - ResponseInfo response = builder.MakeRESTRequest(); - this.Trace(builder, response); - - if (response.StatusCode != HttpStatusCode.Created) - { - this.ParseErrorResponse(response); - } - - return response.StatusCode == HttpStatusCode.Created; - } - catch (Exception ex) - { - if (ex is WebException || ex is NotSupportedException || ex is InvalidOperationException || ex is ProtocolViolationException) - { - // Once we get the debugging logger integrated into this project, we should write a log entry here - return false; - } - - throw; - } - } - - /// - /// Add subject and blurb information for an envelope one is sending - /// - /// Email subject - /// Email body - /// true if successful, false otherwise - public bool AddEmailInformation(string subject, string blurb) + req.Uri = string.Format("/envelopes/{0}/recipients/{1}/tabs", this.EnvelopeId, (string)(GetFirstRecipients().First())["recipientIdGuid"]); + req.HttpMethod = "POST"; + req.IntegratorKey = RestSettings.Instance.IntegratorKey; + + RequestBuilder builder = new RequestBuilder(); + builder.Proxy = this.Proxy; + builder.Request = req; + + List requestBodies = new List(); + RequestBody rb = new RequestBody(); + + foreach (var tab in tabs.textTabs) + tab.tabLabel = Guid.NewGuid().ToString(); + JsonSerializerSettings settings = new JsonSerializerSettings(); + settings.NullValueHandling = NullValueHandling.Ignore; + rb.Text = JsonConvert.SerializeObject(tabs, settings); + + if (string.IsNullOrEmpty(rb.Text) == true) + { + return false; + } + + requestBodies.Add(rb); + + req.RequestBody = requestBodies.ToArray(); + builder.Request = req; + ResponseInfo response = builder.MakeRESTRequest(); + this.Trace(builder, response); + + if (response.StatusCode != HttpStatusCode.Created) + { + this.ParseErrorResponse(response); + } + + return response.StatusCode == HttpStatusCode.Created; + } + catch (Exception ex) + { + if (ex is WebException || ex is NotSupportedException || ex is InvalidOperationException || ex is ProtocolViolationException) + { + // Once we get the debugging logger integrated into this project, we should write a log entry here + return false; + } + + throw; + } + } + + /// + /// Add subject and blurb information for an envelope one is sending + /// + /// Email subject + /// Email body + /// true if successful, false otherwise + public bool AddEmailInformation(string subject, string blurb) { CheckAPIPreRequisites(); - // for now just support adding all email details. We can expand if needed. - if (String.IsNullOrEmpty(subject) || String.IsNullOrEmpty(blurb)) - { - return false; - } - - try - { - RequestInfo req = new RequestInfo(); - req.RequestContentType = "application/json"; - req.AcceptContentType = "application/json"; - req.BaseUrl = this.Login.BaseUrl; - req.LoginEmail = this.Login.Email; + // for now just support adding all email details. We can expand if needed. + if (String.IsNullOrEmpty(subject) || String.IsNullOrEmpty(blurb)) + { + return false; + } + + try + { + RequestInfo req = new RequestInfo(); + req.RequestContentType = "application/json"; + req.AcceptContentType = "application/json"; + req.BaseUrl = this.Login.BaseUrl; + req.LoginEmail = this.Login.Email; req.ApiPassword = this.Login.ApiPassword; - req.Uri = String.Format("/envelopes/{0}", this.EnvelopeId); - req.HttpMethod = "PUT"; - req.IntegratorKey = RestSettings.Instance.IntegratorKey; - - RequestBuilder builder = new RequestBuilder(); - builder.Proxy = Proxy; - builder.Request = req; - - List requestBodies = new List(); - RequestBody rb = new RequestBody(); - - var emailDetails = new Dictionary(){ - {"emailBlurb", blurb}, - {"emailSubject", subject} - }; - - rb.Text = JsonConvert.SerializeObject(emailDetails); - requestBodies.Add(rb); - req.RequestBody = requestBodies.ToArray(); - builder.Request = req; - ResponseInfo response = builder.MakeRESTRequest(); - this.Trace(builder, response); - - if (response.StatusCode != HttpStatusCode.OK) - { - this.ParseErrorResponse(response); - } - - return response.StatusCode == HttpStatusCode.OK; - } - catch (Exception ex) - { - if (ex is WebException || ex is NotSupportedException || ex is InvalidOperationException || ex is ProtocolViolationException) - { - // Once we get the debugging logger integrated into this project, we should write a log entry here - return false; - } - - throw; - } + req.Uri = String.Format("/envelopes/{0}", this.EnvelopeId); + req.HttpMethod = "PUT"; + req.IntegratorKey = RestSettings.Instance.IntegratorKey; + + RequestBuilder builder = new RequestBuilder(); + builder.Proxy = Proxy; + builder.Request = req; + + List requestBodies = new List(); + RequestBody rb = new RequestBody(); + + var emailDetails = new Dictionary(){ + {"emailBlurb", blurb}, + {"emailSubject", subject} + }; + + rb.Text = JsonConvert.SerializeObject(emailDetails); + requestBodies.Add(rb); + req.RequestBody = requestBodies.ToArray(); + builder.Request = req; + ResponseInfo response = builder.MakeRESTRequest(); + this.Trace(builder, response); + + if (response.StatusCode != HttpStatusCode.OK) + { + this.ParseErrorResponse(response); + } + + return response.StatusCode == HttpStatusCode.OK; + } + catch (Exception ex) + { + if (ex is WebException || ex is NotSupportedException || ex is InvalidOperationException || ex is ProtocolViolationException) + { + // Once we get the debugging logger integrated into this project, we should write a log entry here + return false; + } + + throw; + } } /// @@ -860,60 +860,60 @@ public bool SendReminder() throw; } - } - - - /// - /// Add recipients to the envelope - /// - /// - /// true if successful, false otherwise - public bool AddRecipients(Recipients recipients) + } + + + /// + /// Add recipients to the envelope + /// + /// + /// true if successful, false otherwise + public bool AddRecipients(Recipients recipients) { CheckAPIPreRequisites(); - try - { - RequestInfo req = new RequestInfo(); - req.RequestContentType = "application/json"; - req.AcceptContentType = "application/json"; - req.BaseUrl = this.Login.BaseUrl; - req.LoginEmail = this.Login.Email; + try + { + RequestInfo req = new RequestInfo(); + req.RequestContentType = "application/json"; + req.AcceptContentType = "application/json"; + req.BaseUrl = this.Login.BaseUrl; + req.LoginEmail = this.Login.Email; req.ApiPassword = this.Login.ApiPassword; - req.Uri = String.Format("/envelopes/{0}/recipients", this.EnvelopeId); - req.HttpMethod = "POST"; - req.IntegratorKey = RestSettings.Instance.IntegratorKey; - - RequestBuilder builder = new RequestBuilder(); - builder.Proxy = Proxy; - builder.Request = req; - - List requestBodies = new List(); - RequestBody rb = new RequestBody(); - - rb.Text = JsonConvert.SerializeObject(recipients); - requestBodies.Add(rb); - req.RequestBody = requestBodies.ToArray(); - builder.Request = req; - ResponseInfo response = builder.MakeRESTRequest(); - this.Trace(builder, response); - - if (response.StatusCode != HttpStatusCode.Created) - { - this.ParseErrorResponse(response); - } - - return response.StatusCode == HttpStatusCode.Created; - } - catch (Exception ex) - { - if (ex is WebException || ex is NotSupportedException || ex is InvalidOperationException || ex is ProtocolViolationException) - { - // Once we get the debugging logger integrated into this project, we should write a log entry here - return false; - } - - throw; - } + req.Uri = String.Format("/envelopes/{0}/recipients", this.EnvelopeId); + req.HttpMethod = "POST"; + req.IntegratorKey = RestSettings.Instance.IntegratorKey; + + RequestBuilder builder = new RequestBuilder(); + builder.Proxy = Proxy; + builder.Request = req; + + List requestBodies = new List(); + RequestBody rb = new RequestBody(); + + rb.Text = JsonConvert.SerializeObject(recipients); + requestBodies.Add(rb); + req.RequestBody = requestBodies.ToArray(); + builder.Request = req; + ResponseInfo response = builder.MakeRESTRequest(); + this.Trace(builder, response); + + if (response.StatusCode != HttpStatusCode.Created) + { + this.ParseErrorResponse(response); + } + + return response.StatusCode == HttpStatusCode.Created; + } + catch (Exception ex) + { + if (ex is WebException || ex is NotSupportedException || ex is InvalidOperationException || ex is ProtocolViolationException) + { + // Once we get the debugging logger integrated into this project, we should write a log entry here + return false; + } + + throw; + } } /// @@ -1073,68 +1073,68 @@ public bool GetRecipients(bool includeTabs, bool includeExtended) throw; } - } - - - /// - /// Serializes the Json objects - /// - /// String value of the full path to a document. Not required. May be null or empty. - /// serialized Json text - protected string CreateJson(List docPaths, int startIndex = 1) - { - try - { - EnvelopeCreate env = new EnvelopeCreate(); - env.emailBlurb = RestSettings.Instance.EmailBlurb; - env.emailSubject = string.IsNullOrEmpty(this.EmailSubject) ? RestSettings.Instance.EmailSubject : this.EmailSubject; - if (this.CustomFields != null) - { - env.customFields = this.CustomFields; - } + } + + + /// + /// Serializes the Json objects + /// + /// String value of the full path to a document. Not required. May be null or empty. + /// serialized Json text + protected string CreateJson(List docPaths, int startIndex = 1) + { + try + { + EnvelopeCreate env = new EnvelopeCreate(); + env.emailBlurb = RestSettings.Instance.EmailBlurb; + env.emailSubject = string.IsNullOrEmpty(this.EmailSubject) ? RestSettings.Instance.EmailSubject : this.EmailSubject; + if (this.CustomFields != null) + { + env.customFields = this.CustomFields; + } if (!String.IsNullOrEmpty(EmailBlurb)) { env.emailBlurb = EmailBlurb.Length > MaxBlurbSize ? EmailBlurb.Substring(0, MaxBlurbSize) - : EmailBlurb; - } - - env.recipients = this.Recipients; - env.templateRoles = this.TemplateRoles; - env.carbonCopies = this.CarbonCopies; - env.status = this.Status; + : EmailBlurb; + } + + env.recipients = this.Recipients; + env.templateRoles = this.TemplateRoles; + env.carbonCopies = this.CarbonCopies; + env.status = this.Status; env.templateId = this.TemplateId; env.compositeTemplates = this.CompositeTemplates; - env.notification = this.Notification; - - // documents information... - var docs = new List(); - int i = startIndex; - foreach (var docPath in docPaths) - { - var doc = new Document(); - - doc.documentId = i.ToString(); - doc.name = docPath; - docs.Add(doc); - i++; - } - env.documents = docs.ToArray(); - - env.eventNotification = this.Events; - string output = JsonConvert.SerializeObject(env, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); - return output; - } - catch (Exception ex) - { - if (ex is WebException || ex is NotSupportedException || ex is InvalidOperationException || ex is ProtocolViolationException) - { - // Once we get the debugging logger integrated into this project, we should write a log entry here - return string.Empty; - } - - throw; - } + env.notification = this.Notification; + + // documents information... + var docs = new List(); + int i = startIndex; + foreach (var docPath in docPaths) + { + var doc = new Document(); + + doc.documentId = i.ToString(); + doc.name = docPath; + docs.Add(doc); + i++; + } + env.documents = docs.ToArray(); + + env.eventNotification = this.Events; + string output = JsonConvert.SerializeObject(env, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); + return output; + } + catch (Exception ex) + { + if (ex is WebException || ex is NotSupportedException || ex is InvalidOperationException || ex is ProtocolViolationException) + { + // Once we get the debugging logger integrated into this project, we should write a log entry here + return string.Empty; + } + + throw; + } } /// @@ -1186,7 +1186,7 @@ private string CreateJson(List documents) throw; } } - + /// /// Updates an envelope status /// diff --git a/DocuSign.Integrations.Client/Envelope.json.cs b/DocuSign.Integrations.Client/Envelope.json.cs index 3d0981953..bd9915f8d 100755 --- a/DocuSign.Integrations.Client/Envelope.json.cs +++ b/DocuSign.Integrations.Client/Envelope.json.cs @@ -256,6 +256,10 @@ public class Signer /// Each customField string can be a maximum of 100 characters. /// public string[] customFields { get; set; } + /// + /// Sets the access code that the recipient must enter before opening the document. + /// + public string accessCode { get; set; } } ///