-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPushNotificationMapping.swift
More file actions
57 lines (50 loc) · 1.53 KB
/
Copy pathPushNotificationMapping.swift
File metadata and controls
57 lines (50 loc) · 1.53 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
//
// PushNotificationMapping.swift
// DevLogData
//
// Created by 최윤진 on 2/27/26.
//
import DevLogDomain
public extension PushNotificationResponse {
func toDomain() throws -> PushNotification {
let todoCategory: TodoCategory
switch self.todoCategory {
case .decoded(let category):
todoCategory = category
case .raw(let category):
throw DataError.invalidData(
"PushNotificationResponse.todoCategory must be resolved before toDomain(): \(category)"
)
}
return PushNotification(
id: id,
title: self.title,
body: self.body,
receivedAt: self.receivedAt,
isRead: self.isRead,
todoId: self.todoId,
todoCategory: todoCategory
)
}
}
public 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
)
}
}
public 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)
}
}