feat: enhance notification handling with improved data structure and API integration
This commit is contained in:
@@ -6,14 +6,46 @@ actor NotificationsAPIService {
|
||||
|
||||
private init() {}
|
||||
|
||||
func getNotifications(page: Int = 1, perPage: Int = 20) async throws -> NotificationsPage {
|
||||
try await client.request(.getNotifications(page: page, perPage: perPage))
|
||||
// MARK: - Notifications
|
||||
|
||||
func getNotifications(limit: Int = 50, offset: Int = 0, unreadOnly: Bool = false, scope: String? = nil) async throws -> NotificationsPage {
|
||||
try await client.request(.getNotifications(limit: limit, offset: offset, unreadOnly: unreadOnly, scope: scope))
|
||||
}
|
||||
|
||||
func markAsRead(id: UUID) async throws {
|
||||
let _: AppNotification = try await client.request(.markAsRead(id: id))
|
||||
let _: EmptyResponse = try await client.request(.markAsRead(id: id))
|
||||
}
|
||||
|
||||
func markAllAsRead(scope: String? = nil) async throws {
|
||||
let _: EmptyResponse = try await client.request(.markAllAsRead(scope: scope))
|
||||
}
|
||||
|
||||
// MARK: - Devices
|
||||
|
||||
func listDevices() async throws -> [DeviceToken] {
|
||||
try await client.request(.listDevices)
|
||||
}
|
||||
|
||||
func registerDevice(token: String, platform: String = "ios") async throws -> DeviceToken {
|
||||
try await client.request(.registerDevice(token: token, platform: platform))
|
||||
}
|
||||
|
||||
func unregisterDevice(id: UUID) async throws {
|
||||
let _: EmptyResponse = try await client.request(.unregisterDevice(id: id))
|
||||
}
|
||||
|
||||
// MARK: - Preferences
|
||||
|
||||
func getPreferences() async throws -> [NotificationPreference] {
|
||||
try await client.request(.getPreferences)
|
||||
}
|
||||
|
||||
func upsertPreference(channel: String, enabled: Bool, config: [String: String]? = nil) async throws {
|
||||
let _: EmptyResponse = try await client.request(.upsertPreference(channel: channel, enabled: enabled, config: config))
|
||||
}
|
||||
|
||||
// MARK: - SSO (User Management)
|
||||
|
||||
func getSessions() async throws -> [SessionResponse] {
|
||||
try await client.request(.getSessions)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user