Skip to content

Commit

Permalink
refactor/#334 API 명세에 따른 수정
Browse files Browse the repository at this point in the history
- 모임 약속은 요청 파라미터 없이
- 내가 속한 약속은 요청 파라미터 필요
  • Loading branch information
JinUng41 committed Aug 26, 2024
1 parent 0ea3f94 commit 651b653
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
12 changes: 9 additions & 3 deletions KkuMulKum/Network/Service/MeetingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ final class MeetingService {
}
}


// MARK: - MeetingInfoServiceProtocol

extension MeetingService: MeetingInfoServiceProtocol {
func fetchMeetingInfo(with meetingID: Int) async throws -> ResponseBodyDTO<MeetingInfoModel>? {
return try await request(with: .fetchMeetingInfo(meetingID: meetingID))
Expand All @@ -53,9 +56,12 @@ extension MeetingService: MeetingInfoServiceProtocol {

func fetchMeetingPromiseList(
with meetingID: Int,
isParticipant: Bool
isParticipant: Bool?
) async throws -> ResponseBodyDTO<MeetingPromisesModel>? {
return try await request(with: .fetchMeetingPromiseList(meetingID: meetingID, isParticipant: isParticipant))
guard let isParticipant else {
return try await request(with: .fetchMeetingPromiseList(meetingID: meetingID))
}
return try await request(with: .fetchParticipatedPromiseList(meetingID: meetingID, isParticipant: isParticipant))
}

func exitMeeting(with meetingID: Int) -> Single<ResponseBodyDTO<EmptyModel>> {
Expand Down Expand Up @@ -180,7 +186,7 @@ final class MockMeetingInfoService: MeetingInfoServiceProtocol {

func fetchMeetingPromiseList(
with meetingID: Int,
isParticipant: Bool
isParticipant: Bool?
) async throws -> ResponseBodyDTO<MeetingPromisesModel>? {
let mockData = MeetingPromisesModel(
promises: [
Expand Down
14 changes: 10 additions & 4 deletions KkuMulKum/Network/TargetType/MeetingTargetType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ enum MeetingTargetType {
case fetchMeetingList
case fetchMeetingInfo(meetingID: Int)
case fetchMeetingMember(meetingID: Int)
case fetchMeetingPromiseList(meetingID: Int, isParticipant: Bool)
case fetchMeetingPromiseList(meetingID: Int)
case fetchParticipatedPromiseList(meetingID: Int, isParticipant: Bool)
case exitMeeting(meetingID: Int)
}

Expand All @@ -41,7 +42,7 @@ extension MeetingTargetType: TargetType {
return "/api/v1/meetings/\(meetingID)"
case .fetchMeetingMember(let meetingID):
return "/api/v1/meetings/\(meetingID)/members"
case .fetchMeetingPromiseList(let meetingID, _):
case .fetchMeetingPromiseList(let meetingID), .fetchParticipatedPromiseList(let meetingID, _):
return "/api/v1/meetings/\(meetingID)/promises"
case .exitMeeting(let meetingID):
return "/api/v1/meetings/\(meetingID)"
Expand All @@ -52,7 +53,7 @@ extension MeetingTargetType: TargetType {
switch self {
case .createMeeting, .joinMeeting:
return .post
case .fetchMeetingList, .fetchMeetingInfo, .fetchMeetingMember, .fetchMeetingPromiseList:
case .fetchMeetingList, .fetchMeetingInfo, .fetchMeetingMember, .fetchMeetingPromiseList, .fetchParticipatedPromiseList:
return .get
case .exitMeeting:
return .delete
Expand All @@ -67,7 +68,12 @@ extension MeetingTargetType: TargetType {
return .requestJSONEncodable(request)
case .fetchMeetingList, .fetchMeetingInfo, .fetchMeetingMember, .exitMeeting:
return .requestPlain
case .fetchMeetingPromiseList(_, let isParticipant):
case .fetchMeetingPromiseList:
let parameters: [String: Any] = [
"done": "false"
]
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
case .fetchParticipatedPromiseList(_, let isParticipant):
let parameters: [String: Any] = [
"done": "false",
"isParticipant": isParticipant
Expand Down

0 comments on commit 651b653

Please sign in to comment.