Skip to content

Commit

Permalink
✨ :: [#144] AuthDomain / WithdrawalUseCase Impl
Browse files Browse the repository at this point in the history
  • Loading branch information
baekteun committed Aug 2, 2023
1 parent b4fc22b commit f90a6cf
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ public protocol RemoteAuthDataSource {
func signin(req: SigninRequestDTO) async throws
func tokenRefresh() async throws
func networkIsConnected() async -> Bool
func withdrawal() async throws
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public protocol AuthRepository {
func tokenRefresh() async throws
func networkIsConnected() async -> Bool
func checkTokenIsExist() -> Bool
func withdrawal() async throws
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public protocol WithdrawalUseCase {
func callAsFunction() async throws
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Emdpoint
import NetworkingInterface

public enum AuthEndpoint {
case signin(email: String, password: String)
case refresh
case withdrawal
}

extension AuthEndpoint: DotoriEndpoint {
Expand All @@ -17,6 +19,9 @@ extension AuthEndpoint: DotoriEndpoint {

case .refresh:
return .patch("")

case .withdrawal:
return .post("/withdrawal")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ final class RemoteAuthDataSourceImpl: RemoteAuthDataSource {
monitor.start(queue: DispatchQueue(label: "InternetConnectionMonitor"))
})
}

func withdrawal() async throws {
try await networking.request(AuthEndpoint.withdrawal)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ final class AuthRepositoryImpl: AuthRepository {
func networkIsConnected() async -> Bool {
await remoteAuthDataSource.networkIsConnected()
}

func withdrawal() async throws {
try await remoteAuthDataSource.withdrawal()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import AuthDomainInterface

struct WithdrawalUseCaseImpl: WithdrawalUseCase {
private let authRepository: any AuthRepository

init(authRepository: any AuthRepository) {
self.authRepository = authRepository
}

func callAsFunction() async throws {
try await authRepository.withdrawal()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@ final class AuthRepositorySpy: AuthRepository {
checkTokenIsExistCallCount += 1
return checkTokenIsExistReturn
}

var withdrawalCallCount = 0
func withdrawal() async throws {
withdrawalCallCount += 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import AuthDomainInterface

final class WithdrawalUseCaseSpy: WithdrawalUseCase {
var withdrawalCallCount = 0
func callAsFunction() async throws {
withdrawalCallCount += 1
}
}

0 comments on commit f90a6cf

Please sign in to comment.