Box.V2.Managers.BoxFoldersManager.RestoreTrashedFolderAsync C# (CSharp) Méthode

RestoreTrashedFolderAsync() public méthode

Restores an item that has been moved to the trash. Default behavior is to restore the item to the folder it was in before it was moved to the trash. If that parent folder no longer exists or if there is now an item with the same name in that parent folder, the new parent folder and/or new name will need to be included in the request.
public RestoreTrashedFolderAsync ( Box.V2.Models.BoxFolderRequest folderRequest, List fields = null ) : Task
folderRequest Box.V2.Models.BoxFolderRequest BoxFolderRequest object (specify Parent.Id if you wish to restore to a different parent)
fields List Attribute(s) to include in the response
Résultat Task
        public async Task<BoxFolder> RestoreTrashedFolderAsync(BoxFolderRequest folderRequest, List<string> fields = null)
        {
            folderRequest.ThrowIfNull("folderRequest")
                .Id.ThrowIfNullOrWhiteSpace("folderRequest.Id");
            
            BoxRequest request = new BoxRequest(_config.FoldersEndpointUri, folderRequest.Id)
                    .Method(RequestMethod.Post)
                    .Param(ParamFields, fields);

            // ID shall not be used in request body it is used only as url attribute
            string oldId = folderRequest.Id;
            folderRequest.Id = null;

            request.Payload(_converter.Serialize(folderRequest));

            folderRequest.Id = oldId;

            IBoxResponse<BoxFolder> response = await ToResponseAsync<BoxFolder>(request).ConfigureAwait(false);

            return response.ResponseObject;
        }