Skip to content

Commit

Permalink
add workspaces functions
Browse files Browse the repository at this point in the history
  • Loading branch information
patricioxavier8 committed Nov 6, 2024
1 parent 51027f4 commit 37febd9
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Sources/InternxtSwiftCore/Services/HttpAPI/DriveAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
50 changes: 50 additions & 0 deletions Sources/InternxtSwiftCore/Types/DriveTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

0 comments on commit 37febd9

Please sign in to comment.