using Iceshrimp.Frontend.Core.Miscellaneous; using Iceshrimp.Frontend.Core.Services; using Iceshrimp.Shared.Schemas.Web; using Microsoft.AspNetCore.Components.Forms; namespace Iceshrimp.Frontend.Core.ControllerModels; internal class DriveControllerModel(ApiClient api) { public Task UploadFileAsync(IBrowserFile file) => api.CallAsync(HttpMethod.Post, "/drive", data: file); public Task UploadFileToFolderAsync(IBrowserFile file, string folderId) => api.CallAsync(HttpMethod.Post, "/drive", QueryString.Create("folderId", folderId), file); public Task GetFileAsync(string id) => api.CallNullableAsync(HttpMethod.Get, $"/drive/{id}"); public Task UpdateFileAsync(string id, UpdateDriveFileRequest request) => api.CallNullableAsync(HttpMethod.Patch, $"/drive/{id}", data: request); public Task DeleteFileAsync(string id) => api.CallNullableAsync(HttpMethod.Delete, $"/drive/{id}"); public Task UpdateFileParentAsync(string id, string? folderId) => api.CallNullableAsync(HttpMethod.Post, $"/drive/{id}/move", data: new DriveMoveRequest { FolderId = folderId }); public Task CreateFolderAsync(DriveFolderRequest request) => api.CallNullableAsync(HttpMethod.Post, $"/drive/folder", data: request); public Task GetFolderAsync(string? id) => api.CallNullableAsync(HttpMethod.Get, "/drive/folder" + (id != null ? $"/{id}" : "")); public Task UpdateFolderAsync(string id, string name) => api.CallNullableAsync(HttpMethod.Put, $"/drive/folder/{id}", data: name); public Task DeleteFolderAsync(string id) => api.CallNullableAsync(HttpMethod.Delete, $"/drive/folder/{id}"); public Task UpdateFolderParentAsync(string id, string? folderId) => api.CallNullableAsync(HttpMethod.Post, $"/drive/folder/{id}/move", data: new DriveMoveRequest { FolderId = folderId }); }