Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Sources/InternxtSwiftCore/Services/HttpAPI/BackupAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -90,4 +91,8 @@ public struct BackupAPI {
public func getExistenceFileInFolderByPlainName(uuid: String, files: Array<ExistenceFile>, 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)
}
}
18 changes: 18 additions & 0 deletions Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)/drive/notifications",
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)
}

}
11 changes: 10 additions & 1 deletion Sources/InternxtSwiftCore/Types/DriveTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public struct GetFolderFilesResponse: Decodable {
public let result: Array<GetFolderFilesResult>
}

public struct GetFolderFilesResponseNew: Decodable {
public let files: Array<GetFolderFilesResult>
}

public struct GetFolderFoldersResult: Decodable {
public let type: String?
public let id: Int
Expand All @@ -64,6 +68,11 @@ public struct GetFolderFoldersResponse: Decodable {
public let result: Array<GetFolderFoldersResult>
}

public struct GetFolderFoldersResponseNew: Decodable {
public let folders: Array<GetFolderFoldersResult>
}



public struct CreateFolderPayload: Encodable {
public let parentFolderId: Int
Expand Down Expand Up @@ -732,7 +741,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
Expand Down
Loading