-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUserTravelTransform.swift
More file actions
114 lines (104 loc) · 3 KB
/
UserTravelTransform.swift
File metadata and controls
114 lines (104 loc) · 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//
// UserTravelTransform.swift
// Data
//
// Created by 최안용 on 2/15/26.
// Copyright © 2026 NDGL-iOS. All rights reserved.
//
import Foundation
import Domain
import Networks
extension UserContentCardResponse {
func toDomain() -> TravelDetail {
TravelDetail(
travelId: userTravelId,
country: country,
city: city,
budgetPerPerson: 0,
nights: nights,
days: days,
youtube: YouTubeInfo(
title: title,
youtuber: "",
thumbnail: nil,
profileImage: nil,
link: nil,
summary: ""
)
)
}
}
extension UpcomingResponse {
func toDomain() -> MyTripSummary {
let schedule: Schedule?
if let place = self.upcomingUserTravelPlace {
schedule = .init(
id: place.id,
day: 1,
placeName: place.place.name,
thumbnailUrl: place.place.thumbnail ?? "",
transport: place.place.category,
estimatedDuration: place.estimatedDuration,
latitude: place.place.latitude,
longitude: place.place.longitude
)
} else {
schedule = nil
}
return .init(
id: self.userTravelId,
title: self.title,
city: self.city,
country: self.country,
startDay: self.startDate.toDate() ?? .now,
endDay: self.endDate.toDate() ?? .now,
thumbnail: self.thumbnail,
tripSchedule: schedule
)
}
}
extension CreateUserTravelResponse {
func toDomain() -> CreateTravelResponse {
.init(userTravelId: self.userTravelId)
}
}
extension UserTravelItineraryResponse {
func toDomain() -> [TravelPlace] {
itineraries.compactMap { $0.toDomain() }
}
}
extension UserTravelPlaceResponse {
func toDomain() -> TravelPlace? {
guard let place else { return nil }
return TravelPlace(
id: id,
day: day,
sequence: sequence,
distanceKm: distanceKm,
transportation: transportation?.map { $0.toDomain() } ?? [],
youtubeTips: travelerTips ?? [],
planB: planB?.map { $0.toDomain() } ?? [],
estimatedDuration: estimatedDuration,
place: place.toDomain()
)
}
}
extension UpcomingListResponse {
func toDomain() -> [UpcomingInfo] {
self.content.map {
.init(
id: $0.id,
title: $0.title,
country: $0.country,
city: $0.city,
startDate: $0.startDate.toDate() ?? .now,
endDate: $0.endDate.toDate() ?? .now,
nights: $0.nights,
days: $0.days,
templateId: $0.templateId,
thumbnail: $0.thumbnail,
profileImage: $0.profileImage
)
}
}
}