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 void JwtMoveEnvelopesTest()
        {
            JwtRequestSignatureOnDocumentTest("sent");

            FoldersApi foldersApi = new FoldersApi(testConfig.ApiClient.Configuration);

            FoldersRequest foldersRequest = new FoldersRequest(EnvelopeIds: new List <string> {
                testConfig.EnvelopeId
            }, FromFolderId: "sentitems");

            string          ToFolderId = "draft";
            FoldersResponse foldersResponse;

            try
            {
                foldersResponse = foldersApi.MoveEnvelopes(testConfig.AccountId, ToFolderId, foldersRequest);
            }
            catch (Exception ex)
            {
                Assert.Fail("Expected no exception, Actual error message: " + ex.Message);
            }

            // Test if we moved the envelope to the correct folder
            FoldersApi.ListItemsOptions searchOptions = new FoldersApi.ListItemsOptions();
            searchOptions.includeItems = "true";

            var listfromDraftsFolder = foldersApi.ListItems(testConfig.AccountId, ToFolderId, searchOptions);

            Assert.IsNotNull(listfromDraftsFolder);

            bool doesExists = false;

            foreach (var folders in listfromDraftsFolder.Folders)
            {
                foreach (var item in folders.FolderItems)
                {
                    if (item.EnvelopeId == testConfig.EnvelopeId)
                    {
                        doesExists = true;
                        break;
                    }
                }
            }

            Assert.IsTrue(doesExists);
        }
        public void MoveEnvelopes_CorrectInputParameters_ReturnFolderResponse()
        {
            CreateEnvelopeMethod.CreateEnvelope_CorrectAccountIdAndEnvelopeDefinition_ReturnEnvelopeSummary(ref _testConfig);

            var envelopesApi = new EnvelopesApi(_testConfig.ApiClient);

            Envelope envelope = envelopesApi.GetEnvelope(_testConfig.AccountId, _testConfig.EnvelopeId);

            Assert.IsNull(envelope?.VoidedDateTime);
            var foldersRequest = new FoldersRequest(new List <string> {
                _testConfig.EnvelopeId
            });

            var ToFolderId = "recyclebin";

            _foldersApi.MoveEnvelopes(_testConfig.AccountId, ToFolderId, foldersRequest);

            envelope = envelopesApi.GetEnvelope(_testConfig.AccountId, _testConfig.EnvelopeId);
            Assert.IsNotNull(envelope?.VoidedDateTime);
        }