-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultNotificationRepository.swift
More file actions
41 lines (36 loc) · 1.21 KB
/
DefaultNotificationRepository.swift
File metadata and controls
41 lines (36 loc) · 1.21 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
// Copyright © 2025 Booket. All rights reserved
import BKCore
import BKDomain
import Combine
public struct DefaultNotificationRepository: NotificationRepository {
private let networkProvider: NetworkProvider
public init(networkProvider: NetworkProvider) {
self.networkProvider = networkProvider
}
public func upsertFCMToken(
fcmToken: String
) -> AnyPublisher<Void, DomainError> {
networkProvider.request(
target: UserAPI.upsertFCMToken(fcmToken: fcmToken),
type: UserProfileResponseDTO.self
)
.debugError(logger: AppLogger.network)
.mapError { $0.toDomainError() }
.map { _ in }
.eraseToAnyPublisher()
}
public func upsertNotificationSettings(
notificationSettings: Bool
) -> AnyPublisher<Bool, DomainError> {
networkProvider.request(
target: UserAPI.upsertNotificationSettings(
notificationEnabled: notificationSettings
),
type: UserProfileResponseDTO.self
)
.debugError(logger: AppLogger.network)
.mapError { $0.toDomainError() }
.map { $0.notificationEnabled }
.eraseToAnyPublisher()
}
}