-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPushNotificationRepositoryImpl.swift
More file actions
72 lines (60 loc) · 2.3 KB
/
PushNotificationRepositoryImpl.swift
File metadata and controls
72 lines (60 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// PushNotificationRepositoryImpl.swift
// DevLog
//
// Created by 최윤진 on 1/18/26.
//
import Foundation
import Combine
final class PushNotificationRepositoryImpl: PushNotificationRepository {
private let service: PushNotificationService
init(pushNotificationService: PushNotificationService) {
self.service = pushNotificationService
}
/// 푸시 알림 On/Off 설정
func fetchPushNotificationEnabled() async throws -> Bool {
return try await service.fetchPushNotificationEnabled()
}
/// 푸시 알림 시간 설정
func fetchPushNotificationTime() async throws -> DateComponents {
return try await service.fetchPushNotificationTime()
}
/// 푸시 알림 설정 업데이트
func updatePushNotificationSettings(_ settings: PushNotificationSettings) async throws {
try await service.updatePushNotificationSettings(
isEnabled: settings.isEnabled, components: settings.scheduledTime
)
}
/// 푸시 알림 기록 요청
func requestNotifications(
_ query: PushNotificationQuery,
cursor: PushNotificationCursor?
) async throws -> PushNotificationPage {
let cursorDTO = cursor.map { PushNotificationCursorDTO.fromDomain($0) }
let response = try await service.requestNotifications(query, cursor: cursorDTO)
return try response.toDomain()
}
func observeNotifications(
_ query: PushNotificationQuery,
limit: Int
) throws -> AnyPublisher<PushNotificationPage, Error> {
try service.observeNotifications(query, limit: limit)
.tryMap { try $0.toDomain() }
.eraseToAnyPublisher()
}
func observeUnreadPushCount() throws -> AnyPublisher<Int, Error> {
try service.observeUnreadPushCount()
.eraseToAnyPublisher()
}
// 푸시 알림 기록 삭제
func deleteNotification(_ notificationID: String) async throws {
try await service.deleteNotification(notificationID)
}
func undoDeleteNotification(_ notificationID: String) async throws {
try await service.undoDeleteNotification(notificationID)
}
// 푸시 알림 읽음/안읽음 토글
func toggleNotificationRead(_ todoId: String) async throws {
try await service.toggleNotificationRead(todoId)
}
}