-
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: ✨price post 요청 및 receive 구현(#42)
서버 에러 및 badURL으로 미완성채 커밋함
- Loading branch information
Showing
6 changed files
with
76 additions
and
52 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
+3.73 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
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,43 @@ | ||
// | ||
// PriceUseCase.swift | ||
// Airbnb | ||
// | ||
// Created by Lia on 2021/06/02. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
|
||
class PriceUseCase { | ||
|
||
@Published var prices: Prices! | ||
@Published var error: Error! | ||
|
||
private var networkManager: NetworkManageable | ||
private var cancelBag = Set<AnyCancellable>() | ||
|
||
init(networkManager: NetworkManageable = NetworkManager()) { | ||
self.networkManager = networkManager | ||
} | ||
|
||
} | ||
|
||
extension PriceUseCase { | ||
|
||
func requestMainPage(condition: Condition) { | ||
|
||
networkManager.post(url: EndPoint.url(path: "/rooms/price")!, data: condition, result: Prices.self) | ||
.receive(on: DispatchQueue.main) | ||
.sink { error in | ||
print("😡📮error", error) | ||
self.error = error as? Error | ||
} receiveValue: { games in | ||
self.prices = games.self | ||
}.store(in: &cancelBag) | ||
} | ||
|
||
} | ||
|
||
struct Prices: Decodable { | ||
var prices: [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
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