Esempio n. 1
0
        public async void GetEnvelopeRecipientInformation()
        {
            var auth = new AuthenticationClient(_username, _password, _integratorKey);
            await auth.LoginInformationAsync();

            var client = new DocuSignClient(auth);

            var envelope = await client.SendSignatureRequestAsync(_templateId, _recipientName, _recipientEmail, _templateRole);

            var recipient = await client.GetEnvelopeRecipientInformationAsync(envelope.envelopeId);

            Assert.IsNotNull(recipient);
            Assert.IsNotNull(recipient.signers);
            Assert.IsNotNull(recipient.recipientCount);
            Assert.IsNotNull(recipient.currentRoutingOrder);
            Assert.IsNotNull(recipient.signers[0].name);
            Assert.IsNotNull(recipient.signers[0].email);
            Assert.IsNotNull(recipient.signers[0].recipientId);
            Assert.IsNotNull(recipient.signers[0].recipientIdGuid);
            Assert.IsNotNull(recipient.signers[0].requireIdLookup);
            Assert.IsNotNull(recipient.signers[0].userId);
            Assert.IsNotNull(recipient.signers[0].clientUserId);
            Assert.IsNotNull(recipient.signers[0].routingOrder);
            Assert.IsNotNull(recipient.signers[0].note);
            Assert.IsNotNull(recipient.signers[0].status);
            Assert.IsNotNull(recipient.signers[0].templateLocked);
            Assert.IsNotNull(recipient.signers[0].templateRequired);
        }
Esempio n. 2
0
        public Envelope FinalizeMonthSignature(int caseID, DateTime firstDayOfMonth, string returnURL)
        {
            var startDate = firstDayOfMonth;
            var endDate   = startDate.AddMonths(1).AddSeconds(-1);
            var provider  = _context.Providers.Find(Global.Default.User().ProviderID.Value);
            var report    = ReportService.GetPatientHoursReport(caseID, startDate, endDate, provider.ID);

            using (var memstream = new MemoryStream())
            {
                report.ExportToPdf(memstream);
                var dsClient   = new DocuSignClient();
                var dsSettings = AppService.Current.Settings.DocuSignProviderFinalize;
                var config     = new ClientConfig()
                {
                    AuthConfig = new Dymeng.DocuSign.AuthConfig()
                    {
                        Host           = dsSettings.AuthHost,
                        IntegratorKey  = dsSettings.AuthIntegratorKey,
                        OAuthBasePath  = dsSettings.AuthOAuthBasePath,
                        PrivateKeyPath = dsSettings.AuthPrivateKeyPath,
                        UserID         = dsSettings.AuthUserID
                    },
                    DocumentFilename = dsSettings.DocumentFilename,
                    EmailSubject     = dsSettings.EmailSubject,
                    ReturnURL        = returnURL,
                    SignerEmail      = provider.Email ?? dsSettings.DefaultSignerEmail,
                    SignerID         = provider.ID.ToString(),
                    SignerName       = provider.FirstName + " " + provider.LastName,
                    DocumentBytes    = memstream.ToArray()
                };
                return(dsClient.GetSignatureRedirect(config));
            }
        }
Esempio n. 3
0
        public async void GetEnvelopeInformation()
        {
            var auth = new AuthenticationClient(_username, _password, _integratorKey);
            await auth.LoginInformationAsync();

            var client   = new DocuSignClient(auth);
            var envelope = await client.SendSignatureRequestAsync(_templateId, _recipientName, _recipientEmail, _templateRole);

            var envelopeDetails = await client.GetEnvelopeInformationAsync(envelope.envelopeId);

            Assert.IsNotNull(envelopeDetails);
            Assert.IsNotNull(envelopeDetails.envelopeId);
            Assert.IsNotNull(envelopeDetails.status);
            Assert.IsNotNull(envelopeDetails.documentsUri);
            Assert.IsNotNull(envelopeDetails.recipientsUri);
            Assert.IsNotNull(envelopeDetails.envelopeUri);
            Assert.IsNotNull(envelopeDetails.emailSubject);
            Assert.IsNotNull(envelopeDetails.customFieldsUri);
            Assert.IsNotNull(envelopeDetails.notificationUri);
            Assert.IsNotNull(envelopeDetails.enableWetSign);
            Assert.IsNotNull(envelopeDetails.allowReassign);
            Assert.IsNotNull(envelopeDetails.createdDateTime);
            Assert.IsNotNull(envelopeDetails.lastModifiedDateTime);
            Assert.IsNotNull(envelopeDetails.sentDateTime);
            Assert.IsNotNull(envelopeDetails.statusChangedDateTime);
            Assert.IsNotNull(envelopeDetails.documentsCombinedUri);
            Assert.IsNotNull(envelopeDetails.certificateUri);
            Assert.IsNotNull(envelopeDetails.templatesUri);
            Assert.IsNotNull(envelopeDetails.purgeState);
        }
        // GET api/envelope/<id>
        public async Task <Envelope> Get([FromUri] string id)
        {
            await CheckAuthInfo();

            var client = new DocuSignClient(BaseUrl, DocuSignCredentials);

            var envelopeDetails = await client.GetEnvelopeInformationAsync(id);

            return(envelopeDetails);
        }
        // GET api/envelope/<id>
        public async Task <Envelopes> Get([FromUri] DateTime fromDate)
        {
            await CheckAuthInfo();

            var client = new DocuSignClient(BaseUrl, DocuSignCredentials);

            var envelopes = await client.GetEnvelopesAsync(fromDate);

            return(envelopes);
        }
Esempio n. 6
0
        // GET api/envelope/<id>
        public async Task <Recipient> Get([FromUri] string id)
        {
            await CheckAuthInfo();

            var client = new DocuSignClient(BaseUrl, DocuSignCredentials);

            var recipient = await client.GetEnvelopeRecipientInformationAsync(id);

            return(recipient);
        }
        // GET api/templates
        public async Task <Templates> Get()
        {
            await CheckAuthInfo();

            var client = new DocuSignClient(BaseUrl, DocuSignCredentials);

            var templates = await client.GetTemplatesAsync();

            return(templates);
        }
Esempio n. 8
0
        public async void GetEnvelopes()
        {
            var auth = new AuthenticationClient(_username, _password, _integratorKey);
            await auth.LoginInformationAsync();

            var client    = new DocuSignClient(auth);
            var envelopes = await client.GetEnvelopesAsync(DateTime.Now.AddDays(-100));

            Assert.IsNotNull(envelopes);
        }
Esempio n. 9
0
        public async void GetTemplates()
        {
            var auth = new AuthenticationClient(_username, _password, _integratorKey);
            await auth.LoginInformationAsync();

            var client    = new DocuSignClient(auth);
            var templates = await client.GetTemplatesAsync();

            Assert.IsNotNull(templates);
        }
        // POST api/signature
        public async Task <Envelope> Post([FromBody] SignatureRequestTemplate signatureRequestTemplate)
        {
            await CheckAuthInfo();

            var client = new DocuSignClient(BaseUrl, DocuSignCredentials);

            var envelope = await client.SendSignatureRequestAsync(
                signatureRequestTemplate.TemplateId,
                signatureRequestTemplate.RecipientName,
                signatureRequestTemplate.RecipientEmail,
                signatureRequestTemplate.TemplateRole);

            return(envelope);
        }
Esempio n. 11
0
        public async void SendSignatureRequestFromTemplate()
        {
            var auth = new AuthenticationClient(_username, _password, _integratorKey);
            await auth.LoginInformationAsync();

            var client   = new DocuSignClient(auth);
            var envelope = await client.SendSignatureRequestAsync(_templateId, _recipientName, _recipientEmail, _templateRole);

            Assert.IsNotNull(envelope);
            Assert.IsNotNull(envelope.envelopeId);
            Assert.IsNotNull(envelope.status);
            Assert.IsNotNull(envelope.statusDateTime);
            Assert.IsNotNull(envelope.uri);
        }
Esempio n. 12
0
        public async void SendSignatureRequestFromDocument()
        {
            var auth = new AuthenticationClient(_username, _password, _integratorKey);
            await auth.LoginInformationAsync();

            var client = new DocuSignClient(auth);

            var documentName = "test.pdf";
            var fileStream   = File.OpenRead(documentName);
            var envelope     = await client.SendDocumentSignatureRequestAsync(documentName, _recipientName, _recipientEmail, "application/pdf", fileStream);

            Assert.IsNotNull(envelope);
            Assert.IsNotNull(envelope.envelopeId);
            Assert.IsNotNull(envelope.status);
            Assert.IsNotNull(envelope.statusDateTime);
            Assert.IsNotNull(envelope.uri);
        }
Esempio n. 13
0
        public async void GetRecipientViewUrl()
        {
            var auth = new AuthenticationClient(_username, _password, _integratorKey);
            await auth.LoginInformationAsync();

            var client   = new DocuSignClient(auth);
            var envelope = await client.SendSignatureRequestAsync(_templateId, _recipientName, _recipientEmail, _templateRole);

            var uri           = envelope.uri;
            var recipientView = await client.RecipientViewAsync(_recipientName, _recipientEmail, uri);

            Assert.IsNotNull(recipientView);
            Assert.IsNotNull(recipientView.url);

            Uri  uriResult;
            bool isUri = Uri.TryCreate(recipientView.url, UriKind.Absolute, out uriResult);

            Assert.IsTrue(isUri);
        }
        public ViewUrl GenerateDocument(GBME9Request getData)
        {
            string clientUserId   = "1234";
            var    docuSignClient = new DocuSignClient(this.DocuSignCredentials);
            var    accountId      = docuSignClient.AccountId;

            string signerEmail  = getData.RecipientEmail;
            string signerName   = "";
            string RecipientId  = "1";
            string RoutingOrder = "1";
            // Create the signer recipient object
            Signer signer = new Signer
            {
                Email        = signerEmail,
                Name         = signerName,
                ClientUserId = clientUserId,
                RecipientId  = RecipientId,
                RoutingOrder = RoutingOrder,
                RoleName     = DocuSignTemplate.TemplateRoleNames.FirstOrDefault()
            };

            // Create the sign here tab (signing field on the document)
            var tabs = new List <Text> {
                new Text {
                    TabLabel = "LastName", Value = getData.LastName
                },
                new Text {
                    TabLabel = "FirstName", Value = getData.FirstName
                },
                new Text {
                    TabLabel = "MiddleName", Value = getData.MiddleName
                },
                new Text {
                    TabLabel = "PrvsLastName", Value = getData.PreviousLastName
                },
                new Text {
                    TabLabel = "PrvsFirstName", Value = getData.PreviousFirstName
                },
                new Text {
                    TabLabel = "SSN", Value = "xxxxxxxxx"
                },
                new Text {
                    TabLabel = "DateOfBirth", Value = getData.DateOfBirth
                },
                new Text {
                    TabLabel = "GuamLicense", Value = getData.GuamLicenseNo
                },
                new Text {
                    TabLabel = "ExpirationDate", Value = getData.ExpirationDate
                },
                new Text {
                    TabLabel = "Course1", Value = getData.Course1
                },
                new Text {
                    TabLabel = "Sponsored1", Value = getData.Sponsored1
                },
                new Text {
                    TabLabel = "Attended1", Value = getData.Attended1
                },
                new Text {
                    TabLabel = "Approved1", Value = getData.Approved1
                },
                new Text {
                    TabLabel = "Category1", Value = getData.Category1
                },
                new Text {
                    TabLabel = "CreditHour1", Value = getData.CreditHour1
                },
                new Text {
                    TabLabel = "Course2", Value = getData.Course2
                },
                new Text {
                    TabLabel = "Sponsored2", Value = getData.Sponsored2
                },
                new Text {
                    TabLabel = "Attended2", Value = getData.Attended2
                },
                new Text {
                    TabLabel = "Approved2", Value = getData.Approved2
                },
                new Text {
                    TabLabel = "Category2", Value = getData.Category2
                },
                new Text {
                    TabLabel = "CreditHour2", Value = getData.CreditHour2
                },
                new Text {
                    TabLabel = "Course3", Value = getData.Course3
                },
                new Text {
                    TabLabel = "Sponsored3", Value = getData.Sponsored3
                },
                new Text {
                    TabLabel = "Attended3", Value = getData.Attended3
                },
                new Text {
                    TabLabel = "Approved3", Value = getData.Approved3
                },
                new Text {
                    TabLabel = "Category3", Value = getData.Category3
                },
                new Text {
                    TabLabel = "CreditHour3", Value = getData.CreditHour3
                },
                new Text {
                    TabLabel = "Course4", Value = getData.Course4
                },
                new Text {
                    TabLabel = "Sponsored4", Value = getData.Sponsored4
                },
                new Text {
                    TabLabel = "Attended4", Value = getData.Attended4
                },
                new Text {
                    TabLabel = "Approved4", Value = getData.Approved4
                },
                new Text {
                    TabLabel = "Category4", Value = getData.Category4
                },
                new Text {
                    TabLabel = "CreditHour4", Value = getData.CreditHour4
                },
                new Text {
                    TabLabel = "Course5", Value = getData.Course5
                },
                new Text {
                    TabLabel = "Sponsored5", Value = getData.Sponsored5
                },
                new Text {
                    TabLabel = "Attended5", Value = getData.Attended5
                },
                new Text {
                    TabLabel = "Approved5", Value = getData.Approved5
                },
                new Text {
                    TabLabel = "Category5", Value = getData.Category5
                },
                new Text {
                    TabLabel = "CreditHour5", Value = getData.CreditHour5
                },
                new Text {
                    TabLabel = "Course6", Value = getData.Course6
                },
                new Text {
                    TabLabel = "Sponsored6", Value = getData.Sponsored6
                },
                new Text {
                    TabLabel = "Attended6", Value = getData.Attended6
                },
                new Text {
                    TabLabel = "Approved6", Value = getData.Approved6
                },
                new Text {
                    TabLabel = "Category6", Value = getData.Category6
                },
                new Text {
                    TabLabel = "CreditHour6", Value = getData.CreditHour6
                },
                new Text {
                    TabLabel = "Course7", Value = getData.Course7
                },
                new Text {
                    TabLabel = "Sponsored7", Value = getData.Sponsored7
                },
                new Text {
                    TabLabel = "Attended7", Value = getData.Attended7
                },
                new Text {
                    TabLabel = "Approved7", Value = getData.Approved7
                },
                new Text {
                    TabLabel = "Category7", Value = getData.Category7
                },
                new Text {
                    TabLabel = "CreditHour7", Value = getData.CreditHour7
                },
                new Text {
                    TabLabel = "Course8", Value = getData.Course8
                },
                new Text {
                    TabLabel = "Sponsored8", Value = getData.Sponsored8
                },
                new Text {
                    TabLabel = "Attended8", Value = getData.Attended8
                },
                new Text {
                    TabLabel = "Approved8", Value = getData.Approved8
                },
                new Text {
                    TabLabel = "Category8", Value = getData.Category8
                },
                new Text {
                    TabLabel = "CreditHour8", Value = getData.CreditHour8
                },
                new Text {
                    TabLabel = "Course9", Value = getData.Course9
                },
                new Text {
                    TabLabel = "Sponsored9", Value = getData.Sponsored9
                },
                new Text {
                    TabLabel = "Attended9", Value = getData.Attended9
                },
                new Text {
                    TabLabel = "Approved9", Value = getData.Approved9
                },
                new Text {
                    TabLabel = "Category9", Value = getData.Category9
                },
                new Text {
                    TabLabel = "CreditHour9", Value = getData.CreditHour9
                },
                new Text {
                    TabLabel = "Course10", Value = getData.Course10
                },
                new Text {
                    TabLabel = "Sponsored10", Value = getData.Sponsored10
                },
                new Text {
                    TabLabel = "Attended10", Value = getData.Attended10
                },
                new Text {
                    TabLabel = "Approved10", Value = getData.Approved10
                },
                new Text {
                    TabLabel = "Category10", Value = getData.Category10
                },
                new Text {
                    TabLabel = "CreditHour10", Value = getData.CreditHour10
                },
                new Text {
                    TabLabel = "Course11", Value = getData.Course11
                },
                new Text {
                    TabLabel = "Sponsored11", Value = getData.Sponsored11
                },
                new Text {
                    TabLabel = "Attended11", Value = getData.Attended11
                },
                new Text {
                    TabLabel = "Approved11", Value = getData.Approved11
                },
                new Text {
                    TabLabel = "Category11", Value = getData.Category11
                },
                new Text {
                    TabLabel = "CreditHour11", Value = getData.CreditHour11
                }
            };

            // Add the sign here tab array to the signer object.
            signer.Tabs = new Tabs {
                TextTabs = tabs
            };

            // Create array of signer objects
            Signer[] signers = new Signer[] { signer };
            // Create recipients object
            Recipients recipient = new Recipients {
                Signers = new List <Signer>(signers)
            };

            var serverTemplates = new List <ServerTemplate> {
                new ServerTemplate {
                    TemplateId = DocuSignTemplate.TemplateId, Sequence = "1"
                }
            };
            var inlineTemplates = new List <InlineTemplate> {
                new InlineTemplate {
                    Recipients = recipient, Sequence = "2"
                }
            };
            var compositeTemplates = new List <CompositeTemplate> {
                new CompositeTemplate {
                    InlineTemplates = inlineTemplates, ServerTemplates = serverTemplates
                }
            };

            // Bring the objects together in the EnvelopeDefinition
            EnvelopeDefinition envelope = new EnvelopeDefinition
            {
                EmailSubject       = this.EmailTemplate.Subject,
                EmailBlurb         = this.EmailTemplate.MessageBody,
                CompositeTemplates = compositeTemplates,
                Status             = "sent"
            };

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            var envelopesApi    = new EnvelopesApi();
            var envelopeSummary = envelopesApi.CreateEnvelope(accountId, envelope);

            // 3. Create Envelope Recipient View request obj
            string envelopeId = envelopeSummary.EnvelopeId;
            RecipientViewRequest viewOptions = new RecipientViewRequest
            {
                ReturnUrl            = "http://www.docusign.com/devcenter",
                ClientUserId         = clientUserId,
                UserName             = signerName,
                AuthenticationMethod = "Email",
                Email = signerEmail
            };

            // 4. Use the SDK to obtain a Recipient View URL
            ViewUrl viewUrl = envelopesApi.CreateRecipientView(accountId, envelopeId, viewOptions);

            return(viewUrl);
        }
Esempio n. 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OrganizationsApi"/> class
        /// using AplClient object
        /// </summary>
        /// <param name="aplClient">An instance of AplClient</param>
        /// <returns></returns>
        public OrganizationsApi(DocuSignClient aplClient)
        {
            this.ApiClient = aplClient;

            ExceptionFactory = Configuration.DefaultExceptionFactory;
        }
        public ViewUrl GenerateDocument(GBME21Request getData)
        {
            string clientUserId   = "221";
            var    docuSignClient = new DocuSignClient(this.DocuSignCredentials);
            var    accountId      = docuSignClient.AccountId;

            string RecipientId  = "1";
            string RoutingOrder = "1";
            // Create the signer recipient object
            Signer signer = new Signer
            {
                Email        = getData.RecipientEmail,
                Name         = getData.Name,
                ClientUserId = clientUserId,
                RecipientId  = RecipientId,
                RoutingOrder = RoutingOrder,
                RoleName     = DocuSignTemplate.TemplateRoleNames.FirstOrDefault()
            };

            // Create the sign here tab (signing field on the document)
            var tabs = new List <Text> {
                new Text {
                    TabLabel = "Name", Value = getData.Name
                },
                new Text {
                    TabLabel = "PreviousName", Value = getData.PreviousName
                }
            };

            // Add the sign here tab array to the signer object.
            signer.Tabs = new Tabs {
                TextTabs = tabs
            };

            // Create array of signer objects
            Signer[] signers = new Signer[] { signer };
            // Create recipients object
            Recipients recipient = new Recipients {
                Signers = new List <Signer>(signers)
            };

            var serverTemplates = new List <ServerTemplate> {
                new ServerTemplate {
                    TemplateId = DocuSignTemplate.TemplateId, Sequence = "1"
                }
            };
            var inlineTemplates = new List <InlineTemplate> {
                new InlineTemplate {
                    Recipients = recipient, Sequence = "2"
                }
            };
            var compositeTemplates = new List <CompositeTemplate> {
                new CompositeTemplate {
                    InlineTemplates = inlineTemplates, ServerTemplates = serverTemplates
                }
            };

            // Bring the objects together in the EnvelopeDefinition
            EnvelopeDefinition envelope = new EnvelopeDefinition
            {
                EmailSubject       = this.EmailTemplate.Subject,
                EmailBlurb         = this.EmailTemplate.MessageBody,
                CompositeTemplates = compositeTemplates,
                Status             = "sent"
            };

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            var envelopesApi    = new EnvelopesApi();
            var envelopeSummary = envelopesApi.CreateEnvelope(accountId, envelope);

            // 3. Create Envelope Recipient View request obj
            string envelopeId = envelopeSummary.EnvelopeId;
            RecipientViewRequest viewOptions = new RecipientViewRequest
            {
                ReturnUrl            = "http://www.docusign.com/devcenter",
                ClientUserId         = clientUserId,
                UserName             = getData.Name,
                AuthenticationMethod = "Email",
                Email = getData.RecipientEmail
            };

            // 4. Use the SDK to obtain a Recipient View URL
            ViewUrl viewUrl = envelopesApi.CreateRecipientView(accountId, envelopeId, viewOptions);

            return(viewUrl);
        }
Esempio n. 17
0
        public static void Main()
        {
            DocuSignCredentials credentials = new DocuSignCredentials();

            credentials.username      = "";                     // your account email
            credentials.password      = "";                     // your account password
            credentials.integratorKey = "";                     // your account Integrator Key (found on Preferences -> API page)
            credentials.accountId     = "";
            credentials.baseUrl       = "https://demo.docusign.net/";

            DocuSignClient client = new DocuSignClient(credentials);

            Envelope envelope = new Envelope();

            envelope.status       = "sent";
            envelope.emailSubject = "Test API Call Create Envelope";

            Signer signer = new Signer();

            signer.email       = "";
            signer.name        = "";
            signer.recipientId = 1;

            SignHereTab signHereTab = new SignHereTab();

            signHereTab.anchorString  = "/S1Sign/";
            signHereTab.anchorXOffset = "-20";
            signHereTab.anchorYOffset = "120";

            InitialHereTab initialHereTab = new InitialHereTab();

            initialHereTab.anchorString  = "/S1Initial/";
            initialHereTab.anchorXOffset = "10";
            initialHereTab.anchorYOffset = "120";

            FullNameTab fullNameTab = new FullNameTab();

            fullNameTab.anchorString  = "/S1FullName/";
            fullNameTab.anchorXOffset = "-20";
            fullNameTab.anchorYOffset = "120";

            DateSignedTab dateSignedTab = new DateSignedTab();

            dateSignedTab.anchorString  = "/S1Date/";
            dateSignedTab.anchorXOffset = "-20";
            dateSignedTab.anchorYOffset = "120";

            signer.tabs = new Tabs();
            signer.tabs.signHereTabs = new List <SignHereTab>();
            signer.tabs.signHereTabs.Add(signHereTab);

            signer.tabs.initialHereTabs = new List <InitialHereTab>();
            signer.tabs.initialHereTabs.Add(initialHereTab);

            signer.tabs.fullNameTabs = new List <FullNameTab>();
            signer.tabs.fullNameTabs.Add(fullNameTab);

            signer.tabs.dateSignedTabs = new List <DateSignedTab>();
            signer.tabs.dateSignedTabs.Add(dateSignedTab);

            envelope.recipients         = new Recipients();
            envelope.recipients.signers = new List <Signer>();
            envelope.recipients.signers.Add(signer);

            Document document = new Document();

            document.name       = "Try DocuSigning.docx"; // copy document with same name and extension into project directory (i.e. "test.pdf")
            document.documentId = 1;

            envelope.documents = new List <Document>();
            envelope.documents.Add(document);

            CreateEnvelopeResponse response = client.CreateAndSendEnvelope(envelope);

            Trace.WriteLine(response);
        }
Esempio n. 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TrustServiceProvidersApi"/> class
        /// using AplClient object
        /// </summary>
        /// <param name="aplClient">An instance of AplClient</param>
        /// <returns></returns>
        public TrustServiceProvidersApi(DocuSignClient aplClient)
        {
            this.ApiClient = aplClient;

            ExceptionFactory = Configuration.DefaultExceptionFactory;
        }
Esempio n. 19
0
        public async Task <Envelope> PostFormData()
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            await CheckAuthInfo();

            var    client = new DocuSignClient(BaseUrl, DocuSignCredentials);
            string root;

            if (IsLocal(Request))
            {
                root = HttpContext.Current.Server.MapPath("~/App_Data");
            }
            {
                root = @"D:\home\site\wwwroot";
            }


            var streamProvider = new MultipartFormDataStreamProvider(root);

            await Request.Content.ReadAsMultipartAsync(streamProvider);

            var documentName   = string.Empty;
            var recipientName  = string.Empty;
            var recipientEmail = string.Empty;
            var contentType    = string.Empty;

            foreach (var key in streamProvider.FormData.AllKeys)
            {
                var strings = streamProvider.FormData.GetValues(key);
                if (strings != null)
                {
                    foreach (var val in strings)
                    {
                        if (key == "DocumentName")
                        {
                            documentName = val;
                        }
                        if (key == "RecipientName")
                        {
                            recipientName = val;
                        }
                        if (key == "RecipientEmail")
                        {
                            recipientEmail = val;
                        }
                        if (key == "ContentType")
                        {
                            contentType = val;
                        }
                    }
                }
            }

            var fileData   = streamProvider.FileData[0];
            var fileInfo   = new FileInfo(fileData.LocalFileName);
            var fileStream = fileInfo.OpenRead();

            var envelope = await client.SendDocumentSignatureRequestAsync(documentName, recipientName, recipientEmail, contentType, fileStream);

            return(envelope);
        }