Skip to content

Commit

Permalink
refactor/#373 모임 내 약속 목록 조회 메서드 RxMoya로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
JinUng41 committed Sep 9, 2024
1 parent 11d4355 commit d057715
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
23 changes: 17 additions & 6 deletions KkuMulKum/Network/Service/MeetingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,22 @@ extension MeetingService: MeetingInfoServiceProtocol {
func fetchMeetingPromiseList(
with meetingID: Int,
isParticipant: Bool?
) async throws -> ResponseBodyDTO<MeetingPromisesModel>? {
guard let isParticipant else {
return try await request(with: .fetchMeetingPromiseList(meetingID: meetingID))
) -> Single<ResponseBodyDTO<MeetingPromisesModel>> {
if let isParticipant {
return provider.rx.request(.fetchParticipatedPromiseList(meetingID: meetingID, isParticipant: isParticipant))
.map(ResponseBodyDTO<MeetingPromisesModel>.self)
.catch { error in
print(">>> 에러 발생: \(error.localizedDescription) : \(#function) : \(Self.self)")
return .error(error)
}
}
return try await request(with: .fetchParticipatedPromiseList(meetingID: meetingID, isParticipant: isParticipant))

return provider.rx.request(.fetchMeetingPromiseList(meetingID: meetingID))
.map(ResponseBodyDTO<MeetingPromisesModel>.self)
.catch { error in
print(">>> 에러 발생: \(error.localizedDescription) : \(#function) : \(Self.self)")
return .error(error)
}
}

func exitMeeting(with meetingID: Int) -> Single<ResponseBodyDTO<EmptyModel>> {
Expand Down Expand Up @@ -187,7 +198,7 @@ final class MockMeetingInfoService: MeetingInfoServiceProtocol {
func fetchMeetingPromiseList(
with meetingID: Int,
isParticipant: Bool?
) async throws -> ResponseBodyDTO<MeetingPromisesModel>? {
) -> Single<ResponseBodyDTO<MeetingPromisesModel>> {
let mockData = MeetingPromisesModel(
promises: [
MeetingPromise(promiseID: 1,name: "꾸물 리프레시 데이",dDay: 0,time: "PM 2:00",placeName: "DMC역"),
Expand All @@ -208,7 +219,7 @@ final class MockMeetingInfoService: MeetingInfoServiceProtocol {
]
)

return ResponseBodyDTO(success: true, data: mockData, error: nil)
return .just(ResponseBodyDTO(success: true, data: mockData, error: nil))
}

func exitMeeting(with meetingID: Int) -> Single<ResponseBodyDTO<EmptyModel>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import RxSwift
protocol MeetingInfoServiceProtocol {
func fetchMeetingInfo(with meetingID: Int) async throws -> ResponseBodyDTO<MeetingInfoModel>?
func fetchMeetingMemberList(with meetingID: Int) async throws -> ResponseBodyDTO<MeetingMembersModel>?
func fetchMeetingPromiseList(with meetingID: Int, isParticipant: Bool?) async throws -> ResponseBodyDTO<MeetingPromisesModel>?
func fetchMeetingPromiseList(
with meetingID: Int,
isParticipant: Bool?
) -> Single<ResponseBodyDTO<MeetingPromisesModel>>
func exitMeeting(with meetingID: Int) -> Single<ResponseBodyDTO<EmptyModel>>
}

0 comments on commit d057715

Please sign in to comment.