diff --git a/Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift b/Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift index 935238c..005beb9 100644 --- a/Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift +++ b/Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift @@ -50,6 +50,15 @@ public struct DriveAPI { return try await apiClient.fetch(type: GetFolderFilesResponseNew.self, endpoint, debugResponse: debug) } + + public func getFolderFilesV2(folderUuid: String, offset: Int = 0, limit: Int = 50, order: String = "ASC", debug: Bool = false) async throws -> GetFolderFilesResponseV2 { + + let query: String = "?limit=\(String(limit))&offset=\(String(offset))&order=\(order)" + let endpoint = Endpoint(path: "\(self.baseUrl)/folders/content/\(folderUuid)/files\(query)") + + return try await apiClient.fetch(type: GetFolderFilesResponseV2.self, endpoint, debugResponse: debug) + } + /// Get paginated folders inside the given folder using uuid public func getFolderFolders(folderUuid: String, offset: Int = 0, limit: Int = 50, order: String = "ASC", debug: Bool = false) async throws -> GetFolderFoldersResponseNew { @@ -211,6 +220,16 @@ public struct DriveAPI { return try await apiClient.fetch(type: GetFileMetaByIdResponse.self, endpoint, debugResponse: debug) } + /// Get file with fileid optional + public func getFileMetaByUuidV2(uuid: String, debug: Bool = false) async throws -> GetFileMetaByIdResponseV2 { + let endpoint = Endpoint( + path: "\(self.baseUrl)/files/\(uuid)/meta", + method: .GET + ) + + return try await apiClient.fetch(type: GetFileMetaByIdResponseV2.self, endpoint, debugResponse: debug) + } + public func moveFile(fileId: String, bucketId: String, destinationFolder: Int, debug: Bool = false) async throws -> MoveFileResponse { let endpoint = Endpoint( path: "\(self.baseUrl)/storage/move/file", diff --git a/Sources/InternxtSwiftCore/Types/DriveTypes.swift b/Sources/InternxtSwiftCore/Types/DriveTypes.swift index 07bd1d1..d4c5c26 100644 --- a/Sources/InternxtSwiftCore/Types/DriveTypes.swift +++ b/Sources/InternxtSwiftCore/Types/DriveTypes.swift @@ -34,6 +34,33 @@ public struct GetFolderFilesResult: Decodable { public let uuid: String } +public struct GetFolderFilesResultV2: Decodable { + public let id: Int + public let fileId: String? + public let name: String + public let type: String? + // Size string in bytes + public let size: String + public let bucket: String + public let folderId: Int + public let encryptVersion: String? + public let deleted: Bool? + // ISO string + public let deletedAt: String? + public let userId: Int + public let modificationTime: String + // ISO string + public let createdAt: String + // ISO string + public let updatedAt: String + public let plainName: String? + public let removed: Bool? + // ISO string + public let removedAt: String? + public let status: String + public let uuid: String +} + public struct GetFolderFilesResponse: Decodable { public let result: Array } @@ -42,6 +69,10 @@ public struct GetFolderFilesResponseNew: Decodable { public let files: Array } +public struct GetFolderFilesResponseV2: Decodable { + public let files: Array +} + public struct GetFolderFoldersResult: Decodable { public let type: String? public let id: Int @@ -201,6 +232,28 @@ public struct GetFileMetaByIdResponse: Decodable { public let folderUuid: String? } +public struct GetFileMetaByIdResponseV2: Decodable { + public let id: Int + public let fileId: String? + public let folderId: Int + public let name: String + public let type: String? + public let size: String + public let bucket: String + public let deleted: Bool? + public let deletedAt: String? + public let userId: Int + public let modificationTime: String + public let createdAt: String + public let updatedAt: String + public let uuid: String + public let plainName: String? + public let removed: Bool? + public let removedAt: String? + public let status: String + public let folderUuid: String? +} + public struct CreateFileData: Encodable { public let fileId: String @@ -363,7 +416,7 @@ public struct CreateFileResponseNew: Decodable { public let type: String? public let size: String? public let folderId: Int - public let fileId: String + public let fileId: String? public let bucket: String public let encrypt_version: String public let userId: Int