-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUserTravelTransform.swift
More file actions
51 lines (45 loc) · 1.5 KB
/
UserTravelTransform.swift
File metadata and controls
51 lines (45 loc) · 1.5 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
//
// UserTravelTransform.swift
// Data
//
// Created by 최안용 on 2/15/26.
// Copyright © 2026 NDGL-iOS. All rights reserved.
//
import Foundation
import Domain
import Networks
extension UpcomingResponse {
func toDomain() -> MyTripSummary {
return .init(
id: self.userTravelId,
title: self.title,
city: self.city,
country: self.country,
startDay: self.startDate.toDate() ?? .now,
endDay: self.endDate.toDate() ?? .now,
tripSchedule: .init(
id: self.upcomingUserTravelPlace.id,
day: 1, // 서버에서 첫 일정만 보내주고 있음
placeName: self.upcomingUserTravelPlace.place.name,
thumbnailUrl: self.upcomingUserTravelPlace.place.thumbnail ?? "",
transport: self.upcomingUserTravelPlace.place.category,
estimatedDuration: self.upcomingUserTravelPlace.estimatedDuration,
latitude: self.upcomingUserTravelPlace.place.latitude,
longitude: self.upcomingUserTravelPlace.place.longitude
)
)
}
}
extension CreateUserTravelResponse {
func toDomain() -> CreateTravelResponse {
.init(userTravelId: self.userTravelId)
}
}
extension String {
func toDate() -> Date? {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "yyyy-MM-dd"
return formatter.date(from: self)
}
}