Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GWL-329] Match를 취소 할 때 WorkoutID(운동 번호)를 기재하여 요청 #330

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// MatchCancelRequest.swift
// RecordFeature
//
// Created by MaraMincho on 12/10/23.
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved.
//

import Foundation

struct MatchCancelRequest: Encodable {
let workoutID: Int

enum CodingKeys: String, CodingKey {
case workoutID = "workoutId"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ extension WorkoutPeerRandomMatchingRepository: WorkoutPeerRandomMatchingReposito
}.eraseToAnyPublisher()
}

func matchCancel() {
func matchCancel(workoutTypeCode: Int) {
Task {
do {
let _ = try await provider.request(.matchCancel, interceptor: TNKeychainInterceptor.shared)
let _ = try await provider.request(.matchCancel(matchCancelRequest: .init(workoutID: workoutTypeCode)), interceptor: TNKeychainInterceptor.shared)
} catch {
// TODO: ERROR Handling
}
Expand Down Expand Up @@ -81,7 +81,7 @@ extension WorkoutPeerRandomMatchingRepository: WorkoutPeerRandomMatchingReposito

enum RepositoryError: LocalizedError {
case serverError
case unkwonError
case unknwonError
}

// MARK: - WorkoutPeerRandomMatchingRepository.WorkoutPeerRandomMatchingRepositoryEndPoint
Expand All @@ -90,7 +90,7 @@ extension WorkoutPeerRandomMatchingRepository {
enum WorkoutPeerRandomMatchingRepositoryEndPoint: TNEndPoint {
/// Property
case matchStart(matchStartRequest: MatchStartRequest)
case matchCancel
case matchCancel(matchCancelRequest: MatchCancelRequest)
case isMatchedRandomPeer(isMatchedRandomPeersRequest: IsMatchedRandomPeersRequest)

/// TNEndPoint
Expand Down Expand Up @@ -123,7 +123,7 @@ extension WorkoutPeerRandomMatchingRepository {
switch self {
case let .matchStart(matchStartRequest): return matchStartRequest
case let .isMatchedRandomPeer(isMatchedRandomPeersRequest): return isMatchedRandomPeersRequest
case .matchCancel: return nil
case let .matchCancel(typeCode): return typeCode
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ import Foundation

protocol WorkoutPeerRandomMatchingRepositoryRepresentable {
func matchStart(workoutTypeCode: Int) -> AnyPublisher<Result<Void, Error>, Never>
func matchCancel()
func matchCancel(workoutTypeCode: Int)
func isMatchedRandomPeer(isMatchedRandomPeersRequest: IsMatchedRandomPeersRequest) -> AnyPublisher<Result<IsMatchedRandomPeersResponse?, Error>, Never>
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Foundation

protocol WorkoutPeerRandomMatchingUseCaseRepresentable {
func matchStart(workoutSetting: WorkoutSetting) -> AnyPublisher<Result<Void, Error>, Never>
func matchCancel()
func matchCancel(workoutTypeCode: Int)
func isMatchedRandomPeer(isMatchedRandomPeersRequest: IsMatchedRandomPeersRequest) -> AnyPublisher<Result<IsMatchedRandomPeersResponse?, Error>, Never>
}

Expand All @@ -33,8 +33,8 @@ extension WorkoutPeerRandomMatchingUseCase: WorkoutPeerRandomMatchingUseCaseRepr
return repository.matchStart(workoutTypeCode: workoutSetting.workoutType.typeCode)
}

func matchCancel() {
return repository.matchCancel()
func matchCancel(workoutTypeCode: Int) {
return repository.matchCancel(workoutTypeCode: workoutTypeCode)
}

/// 만약 매칭이 잡혔으면 response의 값을 내려주고,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ extension WorkoutPeerRandomMatchingViewModel: WorkoutPeerRandomMatchingViewModel
}

private func cancelPeerRandomMatching() {
workoutPeerRandomMatchingUseCase.matchCancel()
let workoutTypeCode = workoutSetting.workoutType.typeCode
workoutPeerRandomMatchingUseCase.matchCancel(workoutTypeCode: workoutTypeCode)
coordinating?.popPeerRandomMatchingViewController()
}

Expand Down