diff --git a/iOS/Airbnb/Airbnb.xcodeproj/project.pbxproj b/iOS/Airbnb/Airbnb.xcodeproj/project.pbxproj index 2e2a8fa4b..04a5ff135 100644 --- a/iOS/Airbnb/Airbnb.xcodeproj/project.pbxproj +++ b/iOS/Airbnb/Airbnb.xcodeproj/project.pbxproj @@ -33,6 +33,8 @@ AE87A7862668DF22003E9541 /* ResultSupplementaryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE87A7852668DF22003E9541 /* ResultSupplementaryView.swift */; }; AE87A7892668DFB1003E9541 /* AccommodationCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE87A7872668DFB1003E9541 /* AccommodationCell.swift */; }; AE87A78A2668DFB1003E9541 /* AccommodationCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = AE87A7882668DFB1003E9541 /* AccommodationCell.xib */; }; + AE87A78C266906AE003E9541 /* SearchRoomsUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE87A78B266906AE003E9541 /* SearchRoomsUseCase.swift */; }; + AE87A78E26690954003E9541 /* RoomDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE87A78D26690954003E9541 /* RoomDTO.swift */; }; AE8CD3B42653538700BCB8FC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE8CD3B32653538700BCB8FC /* AppDelegate.swift */; }; AE8CD3B62653538700BCB8FC /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE8CD3B52653538700BCB8FC /* SceneDelegate.swift */; }; AE8CD3B82653538700BCB8FC /* MainPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE8CD3B72653538700BCB8FC /* MainPageViewController.swift */; }; @@ -94,6 +96,8 @@ AE87A7852668DF22003E9541 /* ResultSupplementaryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResultSupplementaryView.swift; sourceTree = ""; }; AE87A7872668DFB1003E9541 /* AccommodationCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccommodationCell.swift; sourceTree = ""; }; AE87A7882668DFB1003E9541 /* AccommodationCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AccommodationCell.xib; sourceTree = ""; }; + AE87A78B266906AE003E9541 /* SearchRoomsUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchRoomsUseCase.swift; sourceTree = ""; }; + AE87A78D26690954003E9541 /* RoomDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoomDTO.swift; sourceTree = ""; }; AE8CD3B02653538700BCB8FC /* Airbnb.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Airbnb.app; sourceTree = BUILT_PRODUCTS_DIR; }; AE8CD3B32653538700BCB8FC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; AE8CD3B52653538700BCB8FC /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -188,6 +192,8 @@ isa = PBXGroup; children = ( AE87A7832668D19D003E9541 /* SearchResultViewController.swift */, + AE87A78B266906AE003E9541 /* SearchRoomsUseCase.swift */, + AE87A78D26690954003E9541 /* RoomDTO.swift */, AE87A7852668DF22003E9541 /* ResultSupplementaryView.swift */, AE87A7872668DFB1003E9541 /* AccommodationCell.swift */, AE87A7882668DFB1003E9541 /* AccommodationCell.xib */, @@ -460,6 +466,8 @@ files = ( AEF03BA92667649000050531 /* PeopleViewController.swift in Sources */, AE9AC6A7265CCCBF0038C198 /* CalendarViewController.swift in Sources */, + AE87A78E26690954003E9541 /* RoomDTO.swift in Sources */, + AE87A78C266906AE003E9541 /* SearchRoomsUseCase.swift in Sources */, AEF03BA726675AB200050531 /* PriceUseCase.swift in Sources */, AE11F5AE265F3D920034779F /* Date+extension.swift in Sources */, AE0B5DE326560287000B35E7 /* MainPageUseCase.swift in Sources */, diff --git a/iOS/Airbnb/Airbnb.xcodeproj/project.xcworkspace/xcuserdata/gimjigyeong.xcuserdatad/UserInterfaceState.xcuserstate b/iOS/Airbnb/Airbnb.xcodeproj/project.xcworkspace/xcuserdata/gimjigyeong.xcuserdatad/UserInterfaceState.xcuserstate index 99bef6a48..ef4de2b24 100644 Binary files a/iOS/Airbnb/Airbnb.xcodeproj/project.xcworkspace/xcuserdata/gimjigyeong.xcuserdatad/UserInterfaceState.xcuserstate and b/iOS/Airbnb/Airbnb.xcodeproj/project.xcworkspace/xcuserdata/gimjigyeong.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/iOS/Airbnb/Airbnb/ResultPage/RoomDTO.swift b/iOS/Airbnb/Airbnb/ResultPage/RoomDTO.swift new file mode 100644 index 000000000..11308d222 --- /dev/null +++ b/iOS/Airbnb/Airbnb/ResultPage/RoomDTO.swift @@ -0,0 +1,55 @@ +// +// RoomDTO.swift +// Airbnb +// +// Created by Lia on 2021/06/03. +// + +import Foundation + +struct Rooms: Codable, Hashable { + var rooms : [Room] +} + +struct Room: Codable, Hashable { + var roomId: Int + var images: Images + var price: Int + var people: Int + var title: String + var description: String + var host: Host + var detail: Detail + var grade: Int + var review: Int + var tax: Tax + + struct Images: Codable, Hashable { + var mainImage: String + var detailImage: [String] + } + + struct Host: Codable, Hashable { + var image: String + var name: String + } + + struct Detail: Codable, Hashable { + var maxPeople: Int + var oneRoom: Bool + var bed: Int + var bath: Int + var hairDryer: Bool + var airConditioner: Bool + var WiFi: Bool + var kitchen: Bool + } + + struct Tax: Codable, Hashable { + var cleanTax: Int + var serviceTax: Int + var accommodationTax: Int + } +} + + diff --git a/iOS/Airbnb/Airbnb/ResultPage/SearchRoomsUseCase.swift b/iOS/Airbnb/Airbnb/ResultPage/SearchRoomsUseCase.swift new file mode 100644 index 000000000..3ffe920fa --- /dev/null +++ b/iOS/Airbnb/Airbnb/ResultPage/SearchRoomsUseCase.swift @@ -0,0 +1,37 @@ +// +// SearchRoomsUseCase.swift +// Airbnb +// +// Created by Lia on 2021/06/03. +// + +import Foundation +import Combine + +class SearchRoomsUseCase { + + @Published var rooms: Rooms! + @Published var error: Error! + + private var networkManager: NetworkManageable + private var cancelBag = Set() + + init(networkManager: NetworkManageable = NetworkManager()) { + self.networkManager = networkManager + } + +} + +extension SearchRoomsUseCase { + + func requestPirce(condition: ConditionData) { + networkManager.post(url: EndPoint.url(path: "/rooms")!, data: condition, result: Rooms.self) + .receive(on: DispatchQueue.main) + .sink { error in + self.error = error as? Error + } receiveValue: { rooms in + self.rooms = rooms.self + }.store(in: &cancelBag) + } + +}