From 0f058fc935c59421d8c32291389df632d58ac5e3 Mon Sep 17 00:00:00 2001 From: patricioxavier8 <116120453+patricioxavier8@users.noreply.github.com> Date: Sat, 11 Oct 2025 05:25:50 -0500 Subject: [PATCH 1/4] fix : fix path --- .../InternxtSwiftCore/Services/HttpAPI/NotificationsAPI.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/InternxtSwiftCore/Services/HttpAPI/NotificationsAPI.swift b/Sources/InternxtSwiftCore/Services/HttpAPI/NotificationsAPI.swift index 9972312..17a06c7 100644 --- a/Sources/InternxtSwiftCore/Services/HttpAPI/NotificationsAPI.swift +++ b/Sources/InternxtSwiftCore/Services/HttpAPI/NotificationsAPI.swift @@ -26,7 +26,7 @@ public struct NotificationsAPI { public func getNotifications(debug: Bool = false) async throws -> GetNotificationsResponse { let endpoint = Endpoint( - path: "\(self.baseUrl)/drive/notifications", + path: "\(self.baseUrl)/notifications", method: .GET ) From 7190e67b227ef94a50c1f5dadc58ce51e1dcdb55 Mon Sep 17 00:00:00 2001 From: patricioxavier8 <116120453+patricioxavier8@users.noreply.github.com> Date: Thu, 16 Oct 2025 08:32:00 -0500 Subject: [PATCH 2/4] fix: fix response type in notifications api --- .../InternxtSwiftCore/Services/HttpAPI/NotificationsAPI.swift | 4 ++-- Sources/InternxtSwiftCore/Types/DriveTypes.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/InternxtSwiftCore/Services/HttpAPI/NotificationsAPI.swift b/Sources/InternxtSwiftCore/Services/HttpAPI/NotificationsAPI.swift index 17a06c7..09b6a40 100644 --- a/Sources/InternxtSwiftCore/Services/HttpAPI/NotificationsAPI.swift +++ b/Sources/InternxtSwiftCore/Services/HttpAPI/NotificationsAPI.swift @@ -24,13 +24,13 @@ public struct NotificationsAPI { } - public func getNotifications(debug: Bool = false) async throws -> GetNotificationsResponse { + public func getNotifications(debug: Bool = false) async throws -> [GetNotificationsResponse] { let endpoint = Endpoint( path: "\(self.baseUrl)/notifications", method: .GET ) - return try await apiClient.fetch(type: GetNotificationsResponse.self, endpoint, debugResponse: debug) + return try await apiClient.fetch(type: [GetNotificationsResponse].self, endpoint, debugResponse: debug) } } diff --git a/Sources/InternxtSwiftCore/Types/DriveTypes.swift b/Sources/InternxtSwiftCore/Types/DriveTypes.swift index f5ff09b..e127c01 100644 --- a/Sources/InternxtSwiftCore/Types/DriveTypes.swift +++ b/Sources/InternxtSwiftCore/Types/DriveTypes.swift @@ -732,7 +732,7 @@ public struct GetNotificationsResponse: Codable { public let id: String public let link: String public let message: String - public let expiresAt: String + public let expiresAt: String? public let createdAt: String public let deliveredAt: String public let readAt: String From c533035bddfaadb1c74f589923179bf4fe63f28b Mon Sep 17 00:00:00 2001 From: patricioxavier8 <116120453+patricioxavier8@users.noreply.github.com> Date: Mon, 10 Nov 2025 17:40:38 -0500 Subject: [PATCH 3/4] refactor: add new functions to get files and folders by uuid --- .../Services/HttpAPI/DriveAPI.swift | 18 ++++++++++++++++++ .../InternxtSwiftCore/Types/DriveTypes.swift | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift b/Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift index 9baed07..935238c 100644 --- a/Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift +++ b/Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift @@ -41,6 +41,24 @@ public struct DriveAPI { return try await apiClient.fetch(type: GetFolderFoldersResponse.self, endpoint, debugResponse: debug) } + /// Get paginated files inside the given folder using uuid + public func getFolderFiles(folderUuid: String, offset: Int = 0, limit: Int = 50, order: String = "ASC", debug: Bool = false) async throws -> GetFolderFilesResponseNew { + + 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: GetFolderFilesResponseNew.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 { + + let query: String = "?limit=\(String(limit))&offset=\(String(offset))&order=\(order)" + let endpoint = Endpoint(path: "\(self.baseUrl)/folders/content/\(folderUuid)/folders\(query)") + + return try await apiClient.fetch(type: GetFolderFoldersResponseNew.self, endpoint, debugResponse: debug) + } + /// Creates a folder inside the given parentFolderId with the given name public func createFolder(parentFolderId: Int, folderName: String, debug: Bool = false) async throws -> CreateFolderResponse { diff --git a/Sources/InternxtSwiftCore/Types/DriveTypes.swift b/Sources/InternxtSwiftCore/Types/DriveTypes.swift index e127c01..07bd1d1 100644 --- a/Sources/InternxtSwiftCore/Types/DriveTypes.swift +++ b/Sources/InternxtSwiftCore/Types/DriveTypes.swift @@ -38,6 +38,10 @@ public struct GetFolderFilesResponse: Decodable { public let result: Array } +public struct GetFolderFilesResponseNew: Decodable { + public let files: Array +} + public struct GetFolderFoldersResult: Decodable { public let type: String? public let id: Int @@ -64,6 +68,11 @@ public struct GetFolderFoldersResponse: Decodable { public let result: Array } +public struct GetFolderFoldersResponseNew: Decodable { + public let folders: Array +} + + public struct CreateFolderPayload: Encodable { public let parentFolderId: Int From 1ba3fc8add7f5b97cf120c164570ef8d0f97b98e Mon Sep 17 00:00:00 2001 From: patricioxavier8 <116120453+patricioxavier8@users.noreply.github.com> Date: Thu, 13 Nov 2025 12:26:10 -0500 Subject: [PATCH 4/4] refactor: - remove old endpoints - add new functions to using endpoints with uuid --- .../Services/HttpAPI/BackupAPI.swift | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Sources/InternxtSwiftCore/Services/HttpAPI/BackupAPI.swift b/Sources/InternxtSwiftCore/Services/HttpAPI/BackupAPI.swift index b9e3532..e3ec0df 100644 --- a/Sources/InternxtSwiftCore/Services/HttpAPI/BackupAPI.swift +++ b/Sources/InternxtSwiftCore/Services/HttpAPI/BackupAPI.swift @@ -58,13 +58,14 @@ public struct BackupAPI { return try await apiClient.fetch(type: DeviceAsFolder.self, endpoint, debugResponse: debug) } - - public func getBackupChilds(folderId: String, offset: Int = 0, limit: Int = 50, sort: String = "ASC", debug: Bool = false) async throws -> GetFolderFoldersResponse { - return try await driveAPI.getFolderFolders(folderId: folderId, offset: offset, limit: limit, sort: sort, debug: debug) + + public func getBackupChilds(folderUuid: String, offset: Int = 0, limit: Int = 50, order: String = "ASC", debug: Bool = false) async throws -> GetFolderFoldersResponseNew { + return try await driveAPI.getFolderFolders(folderUuid: folderUuid, offset: offset, limit: limit, order: order, debug: debug) } - public func getBackupFiles(folderId: String, offset: Int = 0, limit: Int = 50, sort: String = "ASC", debug: Bool = false) async throws -> GetFolderFilesResponse { - return try await driveAPI.getFolderFiles(folderId: folderId, offset: offset, limit: limit, sort: sort, debug: debug) + + public func getBackupFiles(folderUuid: String, offset: Int = 0, limit: Int = 50, order: String = "ASC", debug: Bool = false) async throws -> GetFolderFilesResponseNew { + return try await driveAPI.getFolderFiles(folderUuid: folderUuid, offset: offset, limit: limit, order: order, debug: debug) } public func createBackupFolder(parentFolderUuid: String, folderName: String, debug: Bool = false) async throws -> CreateFolderResponseNew { @@ -90,4 +91,8 @@ public struct BackupAPI { public func getExistenceFileInFolderByPlainName(uuid: String, files: Array, debug: Bool = false) async throws -> ExistenceFilesResponse { return try await driveAPI.getExistenceFileInFolderByPlainName(uuid: uuid, files: files) } + + public func getBackupFolderMeta(folderId: String, debug: Bool = false) async throws -> GetFolderMetaByIdResponse { + return try await driveAPI.getFolderMetaById(id: folderId, debug: debug) + } }