Example #1
0
        private Func <VoidEnvelopeRequestModel, UpdateEnvelopeResponseModel> VoidDraftEnvelopeFunc()
        {
            return(request =>
            {
                var account = AuthenticateUser(request.ESignAccount);
                var folderApi = new FoldersApi();
                var folders = folderApi.List(account.AccountId);
                var deletedFolder = folders.Folders.FirstOrDefault(x => x.Type == "recyclebin" && x.OwnerUserId == account.UserId);

                var currentFolder = folders.Folders
                                    .FirstOrDefault(folder => folderApi.ListItems(account.AccountId, folder.FolderId).FolderItems
                                                    .Any(folderItems => folderItems.EnvelopeId == request.EnvelopeId));

                if (deletedFolder != null && currentFolder != null)
                {
                    folderApi.MoveEnvelopes(account.AccountId, deletedFolder.FolderId, new FoldersRequest
                    {
                        EnvelopeIds = new List <string> {
                            request.EnvelopeId
                        },
                        FromFolderId = currentFolder.FolderId
                    });
                }

                return null;
            });
        }
        public static IEnumerable <KeyValueDTO> GetFolders(DocuSignApiConfiguration conf)
        {
            var api     = new FoldersApi(conf.Configuration);
            var folders = api.List(conf.AccountId);

            return(folders.Folders?.Where(a => a.Filter == null).Select(a => new KeyValueDTO(a.Name, a.FolderId)) ?? new List <KeyValueDTO>());
        }
Example #3
0
        private static Func <BaseRequestModel, bool> IsFileExistFunc()
        {
            return(request =>
            {
                var accountId = Authenticate(request.ESignAccount);
                var folderApi = new FoldersApi();
                var folders = folderApi.List(accountId);

                return folders.Folders
                .Select(folder => folderApi.ListItems(accountId, folder.FolderId))
                .Any(listItems => listItems.FolderItems
                     .Any(listItem => listItem.EnvelopeId == request.EnvelopeId));
            });
        }
        public static IEnumerable <FolderItem> GetFolderItems(DocuSignApiConfiguration config, DocuSignQuery docuSignQuery)
        {
            var resultItems = new List <FolderItem>();

            FoldersApi api = new FoldersApi(config.Configuration);

            if (string.IsNullOrEmpty(docuSignQuery.Folder))
            {
                //return all envelopes from all folders
                var folders = api.List(config.AccountId).Folders.Where(a => a.Filter == null);
                if (folders != null)
                {
                    foreach (var item in folders)
                    {
                        var envelopesResponse = api.ListItems(config.AccountId, item.FolderId,
                                                              new FoldersApi.SearchOptions()
                        {
                            status     = docuSignQuery.Status,
                            searchText = docuSignQuery.SearchText
                        });
                        resultItems.AddRange(envelopesResponse.FolderItems);
                    }
                }
            }
            else
            {
                var envelopesResponse = api.ListItems(config.AccountId, docuSignQuery.Folder,
                                                      new FoldersApi.SearchOptions()
                {
                    status     = docuSignQuery.Status,
                    searchText = docuSignQuery.SearchText
                });
                resultItems.AddRange(envelopesResponse.FolderItems);
            }

            return(resultItems);
        }