Example #1
0
        public IActionResult Create(string signerEmail, string signerName)
        {
            // Data for this method
            var accessToken = RequestItemsService.User.AccessToken;
            var basePath    = RequestItemsService.Session.BasePath + "/restapi";
            var accountId   = RequestItemsService.Session.AccountId;
            var envelopeId  = RequestItemsService.EnvelopeId;

            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"));
            }

            // Call the Examples API method to get the list of all documents from the specified envelope
            global::eSignature.Examples.ListEnvelopeDocuments.EnvelopeDocuments envelopeDocuments =
                global::eSignature.Examples.ListEnvelopeDocuments.GetDocuments(accessToken, basePath, accountId, envelopeId);

            // Map the envelopeDocuments object to match the RequestItemsService.EnvelopeDocuments type
            var mappedEnvelopeDocuments = new EnvelopeDocuments
            {
                EnvelopeId = envelopeDocuments.EnvelopeId,
                Documents  = envelopeDocuments.Documents.Select(docItem => new EnvelopeDocItem {
                    DocumentId = docItem.DocumentId, Name = docItem.Name, Type = docItem.Type
                })
                             .ToList()
            };

            // Save the envelopeId and its list of documents in the session so
            // they can be used in example 7 (download a document)
            RequestItemsService.EnvelopeDocuments = mappedEnvelopeDocuments;

            // Process results
            ViewBag.envelopeDocuments = mappedEnvelopeDocuments;
            ViewBag.h1          = "List envelope documents result";
            ViewBag.message     = "Results from the EnvelopeDocuments::list method:";
            ViewBag.Locals.Json = JsonConvert.SerializeObject(mappedEnvelopeDocuments, Formatting.Indented);
            return(View("example_done"));
        }
        // ***DS.snippet.0.start
        private (EnvelopeDocumentsResult results, EnvelopeDocuments envelopeDocuments) DoWork(
            string accessToken, string basePath, string accountId, string envelopeId)
        {
            // Data for this method
            // accessToken
            // basePath
            // accountId
            // envelopeId

            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            var envelopesApi = new EnvelopesApi(apiClient);
            EnvelopeDocumentsResult results = envelopesApi.ListDocuments(accountId, envelopeId);

            // Prepare and save the envelopeId and its list of documents in the session so
            // they can be used in example 7 (download a document)
            List <EnvelopeDocItem> envelopeDocItems = new List <EnvelopeDocItem>
            {
                new EnvelopeDocItem {
                    Name = "Combined", Type = "content", DocumentId = "combined"
                },
                new EnvelopeDocItem {
                    Name = "Zip archive", Type = "zip", DocumentId = "archive"
                }
            };

            foreach (EnvelopeDocument doc in results.EnvelopeDocuments)
            {
                envelopeDocItems.Add(new EnvelopeDocItem
                {
                    DocumentId = doc.DocumentId,
                    Name       = doc.DocumentId == "certificate" ? "Certificate of completion" : doc.Name,
                    Type       = doc.Type
                });
            }

            EnvelopeDocuments envelopeDocuments = new EnvelopeDocuments
            {
                EnvelopeId = envelopeId,
                Documents  = envelopeDocItems
            };

            return(results, envelopeDocuments);
        }
Example #3
0
        /// <summary>
        /// Gets a list of all the documents for a specific envelope
        /// </summary>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <param name="envelopeId">The required envelopeId</param>
        /// <returns>An object containing information about all the documents in the envelopes</returns>
        public static EnvelopeDocuments GetDocuments(string accessToken, string basePath, string accountId, string envelopeId)
        {
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            EnvelopesApi            envelopesApi = new EnvelopesApi(apiClient);
            EnvelopeDocumentsResult results      = envelopesApi.ListDocuments(accountId, envelopeId);

            List <EnvelopeDocItem> envelopeDocItems = new List <EnvelopeDocItem>
            {
                new EnvelopeDocItem {
                    Name = "Combined", Type = "content", DocumentId = "combined"
                },
                new EnvelopeDocItem {
                    Name = "Zip archive", Type = "zip", DocumentId = "archive"
                }
            };

            foreach (EnvelopeDocument doc in results.EnvelopeDocuments)
            {
                envelopeDocItems.Add(new EnvelopeDocItem
                {
                    DocumentId = doc.DocumentId,
                    Name       = doc.DocumentId == "certificate" ? "Certificate of completion" : doc.Name,
                    Type       = doc.Type
                });
            }

            EnvelopeDocuments envelopeDocuments = new EnvelopeDocuments
            {
                EnvelopeId = envelopeId,
                Documents  = envelopeDocItems
            };

            return(envelopeDocuments);
        }