-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPushNotificationMapping.swift
More file actions
48 lines (43 loc) · 1.32 KB
/
PushNotificationMapping.swift
File metadata and controls
48 lines (43 loc) · 1.32 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
//
// PushNotificationMapping.swift
// DevLog
//
// Created by 최윤진 on 2/27/26.
//
extension PushNotificationResponse {
func toDomain() throws -> PushNotification {
guard let todoKind = TodoKind(rawValue: self.todoKind) else {
throw DataError.invalidData("PushNotificationResponse.todoKind is invalid: \(self.todoKind)")
}
return PushNotification(
id: id,
title: self.title,
body: self.body,
receivedAt: self.receivedAt,
isRead: self.isRead,
todoID: self.todoID,
todoKind: todoKind
)
}
}
extension PushNotificationCursorDTO {
func toDomain() -> PushNotificationCursor {
PushNotificationCursor(
receivedAt: self.receivedAt,
documentID: self.documentID
)
}
static func fromDomain(_ cursor: PushNotificationCursor) -> Self {
PushNotificationCursorDTO(
receivedAt: cursor.receivedAt,
documentID: cursor.documentID
)
}
}
extension PushNotificationPageResponse {
func toDomain() throws -> PushNotificationPage {
let items = try self.items.map { try $0.toDomain() }
let nextCursor = self.nextCursor?.toDomain()
return PushNotificationPage(items: items, nextCursor: nextCursor)
}
}