Esempio n. 1
0
        void _AddBulkRecipientAction()
        {
            DocusignResponse response = new DocusignResponse();

            SendRestRequest(response, HttpMethod.Put, "envelopes/" + templateId + "/recipients/" + recipientId + "/bulk_recipients", filePath).Wait();
            if (response.IsError)
            {
                // more compex error handling is needed
                string messageError = "Error trying to Add bulk recipient: ";
                try
                {
                    resObj = response.GetData <BulkRecipientsSummaryResponse>();
                    foreach (var bulkRecipient in resObj.bulkRecipients)
                    {
                        messageError += "\nEmail: " + bulkRecipient.email + "\n Name: " + bulkRecipient.name
                                        + "Errors: ";
                        foreach (var error in bulkRecipient.errorDetails)
                        {
                            messageError += "\n " + error.message;
                        }
                    }
                    foreach (var errorDetail in resObj.errorDetails)
                    {
                        messageError += "Error code: " + errorDetail.errorCode + " - " + errorDetail.message + "\n";
                    }
                }
                catch (System.Exception)
                {
                    response.Throw();
                }
                throw new System.Exception(messageError);
            }
            resObj = response.GetData <BulkRecipientsSummaryResponse>();
        }
Esempio n. 2
0
        void _SendTemplate()
        {
            DocusignResponse response = new DocusignResponse();

            SendRestRequest(response, HttpMethod.Post, "envelopes", template).Wait();
            if (response.IsError)
            {
                response.Throw();
            }
        }
Esempio n. 3
0
        void _ListEnvelopes()
        {
            DocusignResponse response = new DocusignResponse();

            SendRestRequest(response, HttpMethod.Get, "envelopes", null, Query).Wait();
            if (response.IsError)
            {
                response.Throw();
            }
            resObj = response.GetData <EnvelopeResponse>();
        }
Esempio n. 4
0
        void _GetRecipients()
        {
            DocusignResponse response = new DocusignResponse();

            SendRestRequest(response, HttpMethod.Get, "envelopes/" + envelopeID + "/recipients", null, Query).Wait();
            if (response.IsError)
            {
                response.Throw();
            }
            resObj = response.GetData <RecipientsResponse>();
        }
Esempio n. 5
0
        void _ListDocuments()
        {
            DocusignResponse response = new DocusignResponse();

            SendRestRequest(response, HttpMethod.Get, "templates/" + mEnvelopeId + "/recipients", null).Wait();
            if (response.IsError)
            {
                response.Throw();
            }
            resObj = response.GetData <RecipientsListResponse>();
        }
        void _SendEnvelope()
        {
            DocusignResponse response = new DocusignResponse();

            SendRestRequest(response, HttpMethod.Post, "envelopes", env).Wait();
            if (response.IsError)
            {
                response.Throw();
            }
            resObj = response.GetData <EnvelopeSentResponse>();
        }
        void _DownloadDocument()
        {
            DocusignResponse response = new DocusignResponse();

            SendRestRequest(response, HttpMethod.Get, "envelopes/" + mEnvelopeID + "/documents/" + mDocumentID, null, Query).Wait();
            if (response.IsError)
            {
                response.Throw();
            }
            resObj = response.getStreamContent();
        }
Esempio n. 8
0
        void _GetTabs()
        {
            DocusignResponse response = new DocusignResponse();

            SendRestRequest(response, HttpMethod.Get, "envelopes/" + mEnvelopeId + "/documents/" + mDocumentId + "/tabs", null).Wait();
            if (response.IsError)
            {
                response.Throw();
            }
            resObj = response.GetData <TabsResponse>();
        }
Esempio n. 9
0
        void _SendEnvelope()
        {
            TemplateInfo send = new TemplateInfo();

            send.notification.expirations.expireAfter   = "40";
            send.notification.expirations.expireEnabled = true;
            send.notification.expirations.expireWarn    = "5";
            DocusignResponse response = new DocusignResponse();

            SendRestRequest(response, HttpMethod.Put, "templates/" + templateID, send).Wait();
            if (response.IsError)
            {
                response.Throw();
            }
            resObj = response.GetData <TemplateSummaryResponse>();
        }
        protected async Task SendRestRequest(DocusignResponse restResponse, HttpMethod method, string path, object body, Dictionary <string, string> query = null)
        {
            HttpResponseMessage response = await HttpAgent.SendRestRequest(authAgent, method, path, body, query, true);

            string responseContent = await response.Content.ReadAsStringAsync();

            restResponse.Initialize(response, responseContent);
            if (restResponse.NeedsRefresh)
            {
                authAgent.RefreshAuthToken().Wait();
                response = await HttpAgent.SendRestRequest(authAgent, method, path, body);

                responseContent = await response.Content.ReadAsStringAsync();

                restResponse.Initialize(response, responseContent);
            }
        }
        void SendEnvelope()
        {
            int docId        = 1;
            int recptId      = 1;
            int routingOrder = 1;

            Document        document  = new Document(Path.GetFileName(documentFilePath), documentFilePath, docId);
            List <Document> documents = new List <Document>()
            {
                document
            };

            SignHereTab signHereTab;

            if (anchorText != null)
            {
                signHereTab = new SignHereTab(anchorText, offsetX, offsetY, docId, 1, null, null, 1, false);
            }
            else
            {
                signHereTab = new SignHereTab(sigX, sigY, docId, 1, null, null, 1, false);
            }

            List <Tab> tabs = new List <Tab>()
            {
                signHereTab
            };
            Signer r1signer = new Signer(recipientName, recipientEmail, routingOrder, tabs, recptId);

            List <Recipient> recipients = new List <Recipient>()
            {
                r1signer
            };

            Envelope env = new Envelope(subject, documents, recipients);

            DocusignResponse response = new DocusignResponse();

            SendRestRequest(response, HttpMethod.Post, "envelopes", env).Wait();
            if (response.IsError)
            {
                response.Throw();
            }
        }
Esempio n. 12
0
        void _GetTemplateInfo()
        {
            //Get Template ID
            DocusignResponse response = new DocusignResponse();

            SendRestRequest(response, HttpMethod.Get, "templates", null).Wait();
            if (response.IsError)
            {
                response.Throw();
            }
            TemplateListResponse resObj = response.GetData <TemplateListResponse>();

            foreach (TemplateDetails td in resObj.envelopeTemplates)
            {
                if (td.name.Trim() == templateName.Trim())
                {
                    templateId = td.templateId;
                }
            }
            if (templateId == null)
            {
                throw new ArgumentException("Could not find template with name " + templateName);
            }

            /*Get Template Roles
             * DocusignResponse response2 = new DocusignResponse();
             * var path = string.Format("envelopes/{0}/recipients", templateId);
             * var query = new Dictionary<string, string>()
             * {
             *  { "include_tabs", "false" },
             *  { "include_extended", "true" }
             * };
             * SendRestRequest(response2, HttpMethod.Get, path, null, query).Wait();
             * if (response2.IsError)
             * {
             *  response2.Throw();
             * }*/
        }