-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨accommodation network usecase & DTO 생성(#45)
- Loading branch information
Showing
4 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+6.02 KB
(100%)
...roj/project.xcworkspace/xcuserdata/gimjigyeong.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AnyCancellable>() | ||
|
||
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) | ||
} | ||
|
||
} |