diff --git a/AIStudyApp/AIStudyApp/Core/Services/APIService.swift b/AIStudyApp/AIStudyApp/Core/Services/APIService.swift index 557df83..1c8d0b9 100644 --- a/AIStudyApp/AIStudyApp/Core/Services/APIService.swift +++ b/AIStudyApp/AIStudyApp/Core/Services/APIService.swift @@ -69,6 +69,29 @@ class UserService { func updateProfileDetail(_ dto: UpdateProfileDataRequest) async throws -> UserProfileData { return try await client.request("/users/me/profile", method: "PATCH", body: dto) } + + func requestAccountDeletion() async throws -> GenericSuccessResponse { + return try await client.request("/users/me/deletion-request", method: "POST") + } + + func cancelDeletion() async throws -> GenericSuccessResponse { + return try await client.request("/users/me/deletion-request", method: "DELETE") + } + + func listDevices() async throws -> [UserDevice] { + return try await client.request("/users/me/devices") + } + + func removeDevice(id: String) async throws -> GenericSuccessResponse { + return try await client.request("/users/me/devices/\(id)", method: "DELETE") + } +} + +struct UserDevice: Codable, Identifiable { + let id: String + let deviceName: String? + let deviceType: String? + let lastSeenAt: String? } // MARK: - Knowledge Base @@ -234,6 +257,10 @@ class ReviewService { let body = SubmitReviewRequest(rating: rating, responseText: responseText) return try await client.request("/reviews/\(id)/submit", method: "POST", body: body) } + + func generateCards() async throws -> GenericSuccessResponse { + return try await client.request("/reviews/generate-cards", method: "POST") + } } // MARK: - Focus Items @@ -249,6 +276,17 @@ class FocusItemService { URLQueryItem(name: "limit", value: String(limit)), ]) } + + func update(id: String, masteryScore: Int? = nil, title: String? = nil) async throws -> FocusItem { + var body: [String: Any] = [:] + if let s = masteryScore { body["masteryScore"] = s } + if let t = title { body["title"] = t } + return try await client.request("/focus-items/\(id)", method: "PATCH", body: body) + } + + func complete(id: String) async throws -> GenericSuccessResponse { + return try await client.request("/focus-items/\(id)/complete", method: "POST") + } } // MARK: - Activity & Stats @@ -417,4 +455,34 @@ class NotificationService { func markRead(id: String) async throws -> NotificationItem { return try await client.request("/notifications/\(id)/read", method: "PATCH") } + + func markAllRead() async throws -> GenericSuccessResponse { + return try await client.request("/notifications/read-all", method: "POST") + } + + func getPreferences() async throws -> NotificationPreferences { + return try await client.request("/notifications/preferences") + } + + func updatePreferences(_ dto: NotificationPreferences) async throws -> NotificationPreferences { + return try await client.request("/notifications/preferences", method: "PATCH", body: dto) + } + + func registerPushToken(_ token: String) async throws -> GenericSuccessResponse { + return try await client.request("/notifications/push-token", method: "POST", body: ["token": token]) + } + + func removePushToken(_ token: String) async throws -> GenericSuccessResponse { + return try await client.request("/notifications/push-tokens/\(token)", method: "DELETE") + } +} + +struct NotificationPreferences: Codable { + var reviewReminder: Bool? + var newFeatures: Bool? + var systemNotice: Bool? +} + +struct FocusItemCompleteRequest: Codable { + let id: String }