diff --git a/Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift b/Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift index d05da4b..bdd1c40 100644 --- a/Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift +++ b/Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift @@ -347,4 +347,33 @@ public struct DriveAPI { } + public func getAvailableWorkspaces(debug: Bool = false) async throws -> GetAvailableWorkspacesResponse { + let endpoint = Endpoint( + path: "\(self.baseUrl)/workspaces", + method: .GET + ) + + return try await apiClient.fetch(type: GetAvailableWorkspacesResponse.self, endpoint, debugResponse: debug) + } + + public func createFileWorkspace(createFile: CreateFileDataNew,workspaceUuid: String ,debug: Bool = false) async throws -> CreateFileResponseNew { + let endpoint = Endpoint( + path: "\(self.baseUrl)/workspaces/\(workspaceUuid)/files", + method: .POST, + body: createFile.toJson() + ) + + return try await apiClient.fetch(type: CreateFileResponseNew.self, endpoint, debugResponse: debug) + } + + public func createFolderWorkspace(parentFolderUuid: String, folderName: String, workspaceUuid: String,debug: Bool = false) async throws -> CreateFolderResponseNew { + let endpoint = Endpoint( + path: "\(self.baseUrl)/workspaces/\(workspaceUuid)/folders", + method: .POST, + body: CreateFolderPayloadNew(parentFolderUuid: parentFolderUuid, folderName: folderName).toJson() + ) + + return try await apiClient.fetch(type: CreateFolderResponseNew.self, endpoint, debugResponse: debug) + } + } diff --git a/Sources/InternxtSwiftCore/Types/DriveTypes.swift b/Sources/InternxtSwiftCore/Types/DriveTypes.swift index 9a8c25c..fc2e282 100644 --- a/Sources/InternxtSwiftCore/Types/DriveTypes.swift +++ b/Sources/InternxtSwiftCore/Types/DriveTypes.swift @@ -495,3 +495,53 @@ public struct GetDriveItemMetaByIdResponse: Decodable { } } + + +struct GetAvailableWorkspacesResponse: Codable { + let availableWorkspaces: [AvailableWorkspace] + let pendingWorkspaces: [PendingWorkspace] +} + + +struct AvailableWorkspace: Codable { + let workspaceUser: WorkspaceUser + let workspace: Workspace +} + + +struct WorkspaceUser: Codable { + let id: String + let memberId: String + let key: String + let workspaceId: String + let rootFolderId: String + let spaceLimit: Int64 + let driveUsage: Int64 + let backupsUsage: Int64 + let deactivated: Bool + let member: String? + let createdAt: String + let updatedAt: String +} + + +struct Workspace: Codable { + let id: String + let ownerId: String + let address: String + let name: String + let avatar: String? + let description: String + let defaultTeamId: String + let workspaceUserId: String + let setupCompleted: Bool + let rootFolderId: String + let numberOfSeats: Int + let phoneNumber: String + let createdAt: String + let updatedAt: String +} + +struct PendingWorkspace: Codable { +} +