//Docusign API dev guide says this method is subject to call limit and should not be used more than once every 15 min per unique envelope ID
        public static string GetDocumentStatus(string envelopeId, [IgnoreMappingDefault] DocusignCredentials overrideCredentials = null)
        {
            IDocusignCreds creds = overrideCredentials as IDocusignCreds ?? DSServiceClientFactory.DsSettings;

            var dsClient = DSServiceClientFactory.GetDsClient(creds);

            using (var scope = new System.ServiceModel.OperationContextScope(dsClient.InnerChannel))
            {
                OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = DSServiceClientFactory.GetAuthHeaderRequestProperty(creds);

                return(dsClient.RequestStatus(envelopeId).Status.ToString());
            }
        }
        public static FileData GetSignedDocument(string envelopeId, [IgnoreMappingDefault] DocusignCredentials overrideCredentials = null)
        {
            IDocusignCreds creds = overrideCredentials as IDocusignCreds ?? DSServiceClientFactory.DsSettings;

            var dsClient = DSServiceClientFactory.GetDsClient(creds);

            using (var scope = new System.ServiceModel.OperationContextScope(dsClient.InnerChannel))
            {
                OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = DSServiceClientFactory.GetAuthHeaderRequestProperty(creds);

                var documentsPDFs = dsClient.RequestDocumentPDFs(envelopeId);

                if (documentsPDFs == null || documentsPDFs.DocumentPDF == null || documentsPDFs.DocumentPDF.Length == 0)
                {
                    return(null);
                }

                return(new FileData(string.Format("{0}.pdf", documentsPDFs.DocumentPDF[0].Name), documentsPDFs.DocumentPDF[0].PDFBytes));
            }
        }
        public static FileData GetCertificate(string envelopeId, [IgnoreMappingDefault] DocusignCredentials overrideCredentials = null)
        {
            IDocusignCreds creds = overrideCredentials as IDocusignCreds ?? DSServiceClientFactory.DsSettings;

            DSAPIServiceSoapClient dsClient = DSServiceClientFactory.GetDsClient(creds);

            using (OperationContextScope scope = new OperationContextScope(dsClient.InnerChannel))
            {
                OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = DSServiceClientFactory.GetAuthHeaderRequestProperty(creds);

                var documentsPDFs = dsClient.RequestCertificate(envelopeId);

                if (documentsPDFs == null || documentsPDFs.DocumentPDF == null || documentsPDFs.DocumentPDF.Length == 0)
                {
                    return(null);
                }

                return(new FileData($"{documentsPDFs.DocumentPDF[0].Name}.pdf", documentsPDFs.DocumentPDF[0].PDFBytes));
            }
        }