-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a80187
commit 1aa81b7
Showing
1 changed file
with
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// HomeUseCase.swift | ||
// GEON-PPANG-iOS | ||
// | ||
// Created by JEONGEUN KIM on 6/29/24. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
|
||
protocol HomeUseCase { | ||
func fetchBestBakeries() async throws -> [BestBakery] | ||
func fetchBestReviews() async throws -> [BestReview] | ||
} | ||
|
||
final class HomeUseCaseImpl: HomeUseCase { | ||
let bestRepository: BestRepository | ||
|
||
init(bestRepository: BestRepository) { | ||
self.bestRepository = bestRepository | ||
} | ||
|
||
func fetchBestBakeries() async throws -> [BestBakery] { | ||
do { | ||
return try await bestRepository.getBestBakeries() | ||
} | ||
catch MemberError.expiredToken { | ||
throw MemberError.expiredToken | ||
} | ||
catch MemberError.invalidToken { | ||
throw MemberError.invalidToken | ||
} | ||
} | ||
|
||
func fetchBestReviews() async throws -> [BestReview] { | ||
do { | ||
return try await bestRepository.getBestReviews() | ||
} | ||
catch MemberError.expiredToken { | ||
throw MemberError.expiredToken | ||
} | ||
catch MemberError.invalidToken { | ||
throw MemberError.invalidToken | ||
} | ||
} | ||
} |