From 5ab69c5ce94e2a03c827545c0ffab5a49b5e596b Mon Sep 17 00:00:00 2001 From: Kyoungmi <1mmgm.dev@gmail.com> Date: Sun, 15 Dec 2024 22:53:29 +0900 Subject: [PATCH 1/3] refactor api workers --- .../DIContainer/OAuthDIContainer.swift | 2 +- .../Home/Reactor/MainViewReactor.swift | 10 +- .../PostDetail/Reactor/PostReactor.swift | 3 +- .../Privacy/Reactor/PrivacyViewReactor.swift | 1 - .../FamilyWidget/FamilyWidgetEntry.swift | 2 +- .../FamilyWidget/FamilyWidgetView.swift | 2 +- .../APIs/App/AppAPI/AppAPIWorker.swift | 45 ------ .../Sources/APIs/App/AppAPI/AppAPIs.swift | 22 --- .../{CalendarAPI => }/CalendarAPIWorker.swift | 0 .../{CalendarAPI => }/CalendarAPIs.swift | 0 .../ArrayResponseCalendarResponseDTO.swift | 0 ...rrayResponseDailyCalendarResponseDTO.swift | 0 ...ayResponseMonthlyCalendarResponseDTO.swift | 0 .../DataMapping/BannerResponseDTO.swift | 0 .../FamilyMonthlyStatisticsResponseDTO.swift | 0 .../Comment/CommentAPI/CommentAPIWorker.swift | 37 +++-- .../APIs/Comment/CommentAPI/CommentAPIs.swift | 8 ++ .../CreatePostCommentReqeustDTO.swift | 2 +- ...ift => DeletePostCommentResponseDTO.swift} | 6 +- .../GetPostCommentResponseDTO.swift | 29 ++++ ...nationResponsePostCommentResponseDTO.swift | 65 --------- .../DataMapping/PostCommentResponseDTO.swift | 17 +-- .../UpdatePostCommentRequestDTO.swift | 2 +- .../Sources/APIs/DefaultResponseDTO.swift | 18 +++ ...milyWorker.swift => FamilyAPIWorker.swift} | 4 +- ....swift => FamilyInviteViewAPIWorker.swift} | 4 +- .../{LinkWorker.swift => LinkAPIWorker.swift} | 4 +- .../DataMapping/MainNightResponseDTO.swift | 0 .../DataMapping/MainRequestDTO.swift | 0 .../DataMapping/MainResponseDTO.swift | 0 .../MainViewAPI/MainViewAPIWorker.swift | 59 -------- .../MainView/MainViewAPI/MainViewAPIs.swift | 25 ---- .../APIs/MainView/MainViewAPIWorker.swift | 33 +++++ .../Sources/APIs/MainView/MainViewAPIs.swift | 34 +++++ .../Repository/MainViewRepository.swift | 51 ------- .../DataMapping/AddFCMTokenRequestDTO.swift | 0 .../DataMapping/AppVersionResponseDTO.swift | 19 +-- .../Data/Sources/APIs/Me/MeAPI.swift | 42 +++++- .../Me/{MeWorker.swift => MeeAPIWorker.swift} | 41 +++++- ...r.swift => MemberRealEmojiAPIWorker.swift} | 4 +- ...ersWorker.swift => MembersAPIWorker.swift} | 4 +- .../MissionContentResponseDTO.swift | 0 .../MissonTodayContentResponseDTO.swift | 0 .../{MissionAPI => }/MissionAPIWorker.swift | 4 +- .../{MissionAPI => }/MissionAPIs.swift | 0 .../Sources/APIs/OAuth/AuthAPIWorker.swift | 47 ++++++ .../Data/Sources/APIs/OAuth/AuthAPIs.swift | 43 ++++++ .../DataMapping/AuthResultResponseDTO.swift | 16 +-- .../NativeSocialLoginRequestDTO.swift | 12 ++ .../DataMapping/RefreshTokenRequestDTO.swift | 13 ++ .../DataMapping/RefreshTokenResponseDTO.swift | 24 ++++ .../OAuth/DataMapping/SignUpRequestDTO.swift | 14 ++ .../OAuth/DataMapping/SignUpResponseDTO.swift | 24 ++++ .../CreateNewMemberRequestDTO.swift | 19 --- .../DataMapping/DefaultResponseDTO.swift | 22 --- .../NativeSocialLoginRequestDTO.swift | 15 -- .../RefreshAccessTokenRequestDTO.swift | 16 --- .../APIs/OAuth/OAuthAPI/OAuthAPIWorker.swift | 99 ------------- .../APIs/OAuth/OAuthAPI/OAuthAPIs.swift | 35 ----- .../OAuthAPI/Repository/OAuthRepository.swift | 133 ----------------- .../CreatePostPresignedURLReqeustDTO.swift | 0 .../CreatePostPresignedURLResponseDTO.swift | 0 .../DataMapping/CreatePostRequestDTO.swift | 0 .../DataMapping/CreatePostResponseDTO.swift | 0 .../CreatePresignedURLRequestDTO.swift | 0 .../DataMapping/PostDetailResponseDTO.swift | 0 .../DataMapping/PostListQueryDTO.swift | 0 .../DataMapping/PostListResponseDTO.swift | 0 .../APIs/Post/{PostAPI => }/PostAPIs.swift | 0 .../{PostAPI => }/PostListAPIWorker.swift | 2 - .../GetRecentPostsResponseDTO.swift} | 4 +- .../RecentFamilyPostRequestDTO.swift | 0 .../Widget/WidgetAPI/WidgetAPIWorker.swift | 51 ------- .../APIs/Widget/WidgetAPI/WidgetAPIs.swift | 22 --- .../Sources/APIs/Widget/WidgetAPIWorker.swift | 20 +++ .../Data/Sources/APIs/Widget/WidgetAPIs.swift | 27 ++++ .../AppRepository.swift | 11 +- .../Sources/Repositories/AuthRepository.swift | 135 ++++++++++++++++++ .../CalendarRepository.swift | 0 .../CameraRepository.swift | 0 .../CommentRepository.swift | 2 +- .../Repositories/FamilyRepository.swift | 12 +- .../Repositories/MainViewRepository.swift | 53 +++++++ .../Repositories/MembersRepository.swift | 4 +- .../MissionRepository.swift | 8 +- .../MyRepository.swift | 0 .../Sources/Repositories/PickRepository.swift | 4 +- .../PostRepository.swift | 32 ++++- .../PrivacyRepository.swift | 0 .../Repositories/RealEmojiRepository.swift | 2 +- .../Repositories/ResignRepository.swift | 2 +- .../WidgetRepository.swift | 5 +- .../AccountRepository/AccountRepository.swift | 2 +- .../Trash/Account/MeAPI/MeAPIWorker.swift | 1 + ...ostEntity.swift => WidgetPostEntity.swift} | 2 +- .../Sources/Repositories/AppRepository.swift | 2 +- .../Repositories/MainViewRepository.swift | 4 +- .../Repositories/MissonRepository.swift | 4 +- .../Repositories/OAuthRepository.swift | 10 +- .../Repositories/WidgetRepository.swift | 2 +- .../UseCases/App/FetchAppVersionUseCase.swift | 4 +- .../UseCases/MainView/FetchMainUseCase.swift | 4 +- .../MainView/FetchNightMainViewUsecase.swift | 4 +- .../FetchDailyMissonContentUseCase.swift | 4 +- .../Misson/FetchMissionContentUseCase.swift | 4 +- .../OAuth/DeleteFCMTokenUseCase.swift | 4 +- .../OAuth/RefreshAccessTokenUseCase.swift | 4 +- .../OAuth/RegisterNewFCMTokenUseCase.swift | 4 +- .../OAuth/RegisterNewMemberUseCase.swift | 4 +- .../UseCases/OAuth/SignInUseCase.swift | 4 +- .../Widget/FetchRecentFamilyPostUseCase.swift | 4 +- Bibbi.xcworkspace/contents.xcworkspacedata | 21 +++ .../xcschemes/Bibbi-Workspace.xcscheme | 60 +++----- 113 files changed, 793 insertions(+), 886 deletions(-) delete mode 100644 14th-team5-iOS/Data/Sources/APIs/App/AppAPI/AppAPIWorker.swift delete mode 100644 14th-team5-iOS/Data/Sources/APIs/App/AppAPI/AppAPIs.swift rename 14th-team5-iOS/Data/Sources/APIs/Calendar/{CalendarAPI => }/CalendarAPIWorker.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Calendar/{CalendarAPI => }/CalendarAPIs.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Calendar/{CalendarAPI => }/DataMapping/ArrayResponseCalendarResponseDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Calendar/{CalendarAPI => }/DataMapping/ArrayResponseDailyCalendarResponseDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Calendar/{CalendarAPI => }/DataMapping/ArrayResponseMonthlyCalendarResponseDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Calendar/{CalendarAPI => }/DataMapping/BannerResponseDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Calendar/{CalendarAPI => }/DataMapping/FamilyMonthlyStatisticsResponseDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/{PostCommentDeleteResponseDTO.swift => DeletePostCommentResponseDTO.swift} (65%) create mode 100644 14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/GetPostCommentResponseDTO.swift delete mode 100644 14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/PaginationResponsePostCommentResponseDTO.swift create mode 100644 14th-team5-iOS/Data/Sources/APIs/DefaultResponseDTO.swift rename 14th-team5-iOS/Data/Sources/APIs/Family/{FamilyWorker.swift => FamilyAPIWorker.swift} (93%) rename 14th-team5-iOS/Data/Sources/APIs/FamilyInviteView/{FamilyInviteViewWorker.swift => FamilyInviteViewAPIWorker.swift} (83%) rename 14th-team5-iOS/Data/Sources/APIs/Link/{LinkWorker.swift => LinkAPIWorker.swift} (87%) rename 14th-team5-iOS/Data/Sources/APIs/MainView/{MainViewAPI => }/DataMapping/MainNightResponseDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/MainView/{MainViewAPI => }/DataMapping/MainRequestDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/MainView/{MainViewAPI => }/DataMapping/MainResponseDTO.swift (100%) delete mode 100644 14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/MainViewAPIWorker.swift delete mode 100644 14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/MainViewAPIs.swift create mode 100644 14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPIWorker.swift create mode 100644 14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPIs.swift delete mode 100644 14th-team5-iOS/Data/Sources/APIs/MainView/Repository/MainViewRepository.swift rename 14th-team5-iOS/Data/Sources/APIs/{OAuth/OAuthAPI => Me}/DataMapping/AddFCMTokenRequestDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/{App/AppAPI => Me}/DataMapping/AppVersionResponseDTO.swift (54%) rename 14th-team5-iOS/Data/Sources/APIs/Me/{MeWorker.swift => MeeAPIWorker.swift} (53%) rename 14th-team5-iOS/Data/Sources/APIs/MemberRealEmoji/{MemberRealEmojiWorker.swift => MemberRealEmojiAPIWorker.swift} (83%) rename 14th-team5-iOS/Data/Sources/APIs/Members/{MembersWorker.swift => MembersAPIWorker.swift} (98%) rename 14th-team5-iOS/Data/Sources/APIs/Mission/{MissionAPI => }/DataMapping/MissionContentResponseDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Mission/{MissionAPI => }/DataMapping/MissonTodayContentResponseDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Mission/{MissionAPI => }/MissionAPIWorker.swift (95%) rename 14th-team5-iOS/Data/Sources/APIs/Mission/{MissionAPI => }/MissionAPIs.swift (100%) create mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/AuthAPIWorker.swift create mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/AuthAPIs.swift rename 14th-team5-iOS/Data/Sources/APIs/OAuth/{OAuthAPI => }/DataMapping/AuthResultResponseDTO.swift (50%) create mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/NativeSocialLoginRequestDTO.swift create mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/RefreshTokenRequestDTO.swift create mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/RefreshTokenResponseDTO.swift create mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/SignUpRequestDTO.swift create mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/SignUpResponseDTO.swift delete mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/CreateNewMemberRequestDTO.swift delete mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/DefaultResponseDTO.swift delete mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/NativeSocialLoginRequestDTO.swift delete mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/RefreshAccessTokenRequestDTO.swift delete mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/OAuthAPIWorker.swift delete mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/OAuthAPIs.swift delete mode 100644 14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/Repository/OAuthRepository.swift rename 14th-team5-iOS/Data/Sources/APIs/Post/{PostAPI => }/DataMapping/CreatePostPresignedURLReqeustDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Post/{PostAPI => }/DataMapping/CreatePostPresignedURLResponseDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Post/{PostAPI => }/DataMapping/CreatePostRequestDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Post/{PostAPI => }/DataMapping/CreatePostResponseDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Post/{PostAPI => }/DataMapping/CreatePresignedURLRequestDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Post/{PostAPI => }/DataMapping/PostDetailResponseDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Post/{PostAPI => }/DataMapping/PostListQueryDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Post/{PostAPI => }/DataMapping/PostListResponseDTO.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Post/{PostAPI => }/PostAPIs.swift (100%) rename 14th-team5-iOS/Data/Sources/APIs/Post/{PostAPI => }/PostListAPIWorker.swift (99%) rename 14th-team5-iOS/Data/Sources/APIs/Widget/{WidgetAPI/DataMaaping/RecentFamilyPostResponseDTO.swift => DataMaaping/GetRecentPostsResponseDTO.swift} (85%) rename 14th-team5-iOS/Data/Sources/APIs/Widget/{WidgetAPI => }/DataMaaping/RecentFamilyPostRequestDTO.swift (100%) delete mode 100644 14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPI/WidgetAPIWorker.swift delete mode 100644 14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPI/WidgetAPIs.swift create mode 100644 14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPIWorker.swift create mode 100644 14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPIs.swift rename 14th-team5-iOS/Data/Sources/{APIs/App/Repository => Repositories}/AppRepository.swift (85%) create mode 100644 14th-team5-iOS/Data/Sources/Repositories/AuthRepository.swift rename 14th-team5-iOS/Data/Sources/{APIs/Calendar/Repository => Repositories}/CalendarRepository.swift (100%) rename 14th-team5-iOS/Data/Sources/{APIs/Camera/Repository => Repositories}/CameraRepository.swift (100%) rename 14th-team5-iOS/Data/Sources/{APIs/Comment/Repository => Repositories}/CommentRepository.swift (96%) create mode 100644 14th-team5-iOS/Data/Sources/Repositories/MainViewRepository.swift rename 14th-team5-iOS/Data/Sources/{APIs/Mission/Repository => Repositories}/MissionRepository.swift (93%) rename 14th-team5-iOS/Data/Sources/{APIs/My/Repository => Repositories}/MyRepository.swift (100%) rename 14th-team5-iOS/Data/Sources/{APIs/Post/Repository => Repositories}/PostRepository.swift (57%) rename 14th-team5-iOS/Data/Sources/{APIs/Privacy/Repository => Repositories}/PrivacyRepository.swift (100%) rename 14th-team5-iOS/Data/Sources/{APIs/Widget/Repository => Repositories}/WidgetRepository.swift (84%) rename 14th-team5-iOS/Domain/Sources/Entities/Widget/{RecentFamilyPostEntity.swift => WidgetPostEntity.swift} (93%) diff --git a/14th-team5-iOS/App/Sources/Application/DIContainer/OAuthDIContainer.swift b/14th-team5-iOS/App/Sources/Application/DIContainer/OAuthDIContainer.swift index 80cafa06c..09bbc1708 100644 --- a/14th-team5-iOS/App/Sources/Application/DIContainer/OAuthDIContainer.swift +++ b/14th-team5-iOS/App/Sources/Application/DIContainer/OAuthDIContainer.swift @@ -47,7 +47,7 @@ final class OAuthDIContainer: BaseContainer { // MARK: - Make Repository private func makeOAuthRepository() -> OAuthRepositoryProtocol { - return OAuthRepository() + return AuthRepository() } diff --git a/14th-team5-iOS/App/Sources/Presentation/Home/Reactor/MainViewReactor.swift b/14th-team5-iOS/App/Sources/Presentation/Home/Reactor/MainViewReactor.swift index 4d988f0ed..96edf8693 100644 --- a/14th-team5-iOS/App/Sources/Presentation/Home/Reactor/MainViewReactor.swift +++ b/14th-team5-iOS/App/Sources/Presentation/Home/Reactor/MainViewReactor.swift @@ -131,10 +131,7 @@ extension MainViewReactor { case .fetchMainUseCase: return fetchMainUseCase.execute() .asObservable() - .flatMap { result -> Observable in - guard let data = result else { - return Observable.empty() - } + .flatMap { data -> Observable in return Observable.concat( .just(.updateMainData(data)), .just(.setBalloonText), @@ -145,10 +142,7 @@ extension MainViewReactor { case .fetchMainNightUseCase: return fetchMainNightUseCase.execute() .asObservable() - .flatMap { result -> Observable in - guard let data = result else { - return .empty() - } + .flatMap { data -> Observable in return .just(.updateMainNight(data)) } case .setTimer(let isInTime, let time): diff --git a/14th-team5-iOS/App/Sources/Presentation/PostDetail/Reactor/PostReactor.swift b/14th-team5-iOS/App/Sources/Presentation/PostDetail/Reactor/PostReactor.swift index 1e6a99198..d1f6a0f66 100644 --- a/14th-team5-iOS/App/Sources/Presentation/PostDetail/Reactor/PostReactor.swift +++ b/14th-team5-iOS/App/Sources/Presentation/PostDetail/Reactor/PostReactor.swift @@ -70,10 +70,9 @@ extension PostReactor { return fetchMissionUseCase.execute(missionId: missionId) .asObservable() .flatMap { entity -> Observable in - guard let originEntity = entity else { return .empty() } return .concat( .just(.setSelectedPostIndex(index)), - .just(.setMissionContent(originEntity)) + .just(.setMissionContent(entity)) ) } diff --git a/14th-team5-iOS/App/Sources/Presentation/Privacy/Reactor/PrivacyViewReactor.swift b/14th-team5-iOS/App/Sources/Presentation/Privacy/Reactor/PrivacyViewReactor.swift index 957cf4459..5294fbef9 100644 --- a/14th-team5-iOS/App/Sources/Presentation/Privacy/Reactor/PrivacyViewReactor.swift +++ b/14th-team5-iOS/App/Sources/Presentation/Privacy/Reactor/PrivacyViewReactor.swift @@ -76,7 +76,6 @@ public final class PrivacyViewReactor: Reactor { owner.fetchPrivacyItemsUseCase.execute() .asObservable() .flatMap { privateInfo -> Observable in - guard let appVersionEntity = appVersionEntity else { return .empty() } var sectionItem: [PrivacyItemModel] = [] privateInfo.forEach { sectionItem.append(.privacyWithAuthItem(PrivacyCellReactor(descrption: $0, isCheck: appVersionEntity.latest))) diff --git a/14th-team5-iOS/App/WidgetExtension/Sources/FamilyWidget/FamilyWidgetEntry.swift b/14th-team5-iOS/App/WidgetExtension/Sources/FamilyWidget/FamilyWidgetEntry.swift index bccb73f3f..27d49333a 100644 --- a/14th-team5-iOS/App/WidgetExtension/Sources/FamilyWidget/FamilyWidgetEntry.swift +++ b/14th-team5-iOS/App/WidgetExtension/Sources/FamilyWidget/FamilyWidgetEntry.swift @@ -10,5 +10,5 @@ import Domain struct FamilyWidgetEntry: TimelineEntry { let date: Date - let family: RecentFamilyPostEntity? + let family: WidgetPostEntity? } diff --git a/14th-team5-iOS/App/WidgetExtension/Sources/FamilyWidget/FamilyWidgetView.swift b/14th-team5-iOS/App/WidgetExtension/Sources/FamilyWidget/FamilyWidgetView.swift index a3896d0e8..23dce9e5e 100644 --- a/14th-team5-iOS/App/WidgetExtension/Sources/FamilyWidget/FamilyWidgetView.swift +++ b/14th-team5-iOS/App/WidgetExtension/Sources/FamilyWidget/FamilyWidgetView.swift @@ -153,7 +153,7 @@ struct FamilyWidgetView: View { } // MARK: 가족중 일부가 사진을 올렸을 때 뷰 - private func getPhotoView(info: RecentFamilyPostEntity) -> some View { + private func getPhotoView(info: WidgetPostEntity) -> some View { ZStack { if let postImageUrl = info.postImageUrl { diff --git a/14th-team5-iOS/Data/Sources/APIs/App/AppAPI/AppAPIWorker.swift b/14th-team5-iOS/Data/Sources/APIs/App/AppAPI/AppAPIWorker.swift deleted file mode 100644 index 9c3693d07..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/App/AppAPI/AppAPIWorker.swift +++ /dev/null @@ -1,45 +0,0 @@ -// -// AppAPIWorker.swift -// Data -// -// Created by 김건우 on 7/10/24. -// - -import Core -import Domain -import Foundation - -import RxSwift - -public typealias AppAPIWorker = AppAPIs.Worker -extension AppAPIs { - public final class Worker: APIWorker { - static let queue = { - ConcurrentDispatchQueueScheduler(queue: DispatchQueue(label: "AppAPIQueue", qos: .utility)) - }() - - public override init() { - super.init() - self.id = "AppAPIWorker" - } - } -} - -// MARK: - Extensions - -extension AppAPIWorker { - - - // MARK: - Fetch App Info - - public func fetchAppVersion(appKey: String) -> Single { - let spec = AppAPIs.appVersion(appKey).spec - - return request(spec: spec) - .subscribe(on: Self.queue) - .map(AppVersionResponseDTO.self) - .catchAndReturn(nil) - .asSingle() - } - -} diff --git a/14th-team5-iOS/Data/Sources/APIs/App/AppAPI/AppAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/App/AppAPI/AppAPIs.swift deleted file mode 100644 index 34a7a714f..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/App/AppAPI/AppAPIs.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// AppAPIs.swift -// Data -// -// Created by 김건우 on 7/10/24. -// - -import Core -import Foundation - -public enum AppAPIs: API { - - case appVersion(String) - - public var spec: APISpec { - switch self { - case let .appVersion(appKey): - return APISpec(method: .get, url: "\(BibbiAPI.hostApi)/me/app-version?appKey=\(appKey)") - } - } - -} diff --git a/14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/CalendarAPIWorker.swift b/14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPIWorker.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/CalendarAPIWorker.swift rename to 14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPIWorker.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/CalendarAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPIs.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/CalendarAPIs.swift rename to 14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPIs.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/DataMapping/ArrayResponseCalendarResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Calendar/DataMapping/ArrayResponseCalendarResponseDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/DataMapping/ArrayResponseCalendarResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Calendar/DataMapping/ArrayResponseCalendarResponseDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/DataMapping/ArrayResponseDailyCalendarResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Calendar/DataMapping/ArrayResponseDailyCalendarResponseDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/DataMapping/ArrayResponseDailyCalendarResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Calendar/DataMapping/ArrayResponseDailyCalendarResponseDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/DataMapping/ArrayResponseMonthlyCalendarResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Calendar/DataMapping/ArrayResponseMonthlyCalendarResponseDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/DataMapping/ArrayResponseMonthlyCalendarResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Calendar/DataMapping/ArrayResponseMonthlyCalendarResponseDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/DataMapping/BannerResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Calendar/DataMapping/BannerResponseDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/DataMapping/BannerResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Calendar/DataMapping/BannerResponseDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/DataMapping/FamilyMonthlyStatisticsResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Calendar/DataMapping/FamilyMonthlyStatisticsResponseDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Calendar/CalendarAPI/DataMapping/FamilyMonthlyStatisticsResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Calendar/DataMapping/FamilyMonthlyStatisticsResponseDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/CommentAPIWorker.swift b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/CommentAPIWorker.swift index 2fc752db8..a41b62cf5 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/CommentAPIWorker.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/CommentAPIWorker.swift @@ -12,24 +12,17 @@ import Foundation import RxSwift typealias CommentAPIWorker = CommentAPIs.Worker -extension CommentAPIs { - public final class Worker: BBRxAPIWorker { - public init() { super.init() } - } -} - - -// MARK: - Extensions extension CommentAPIWorker { - - // MARK: - Fetch Comment - + /// 게시물에 등록 된 댓글을 페이지네이션으로 조회하는 Method입니다. + /// HTTP Method: GET + /// - Parameters: postId: String + /// - Returns: GetPostCommentResponseDTO func fetchComment( postId: String, query: PostCommentPaginationQuery - ) -> Observable { + ) -> Observable { let page = query.page let size = query.size let sort = query.sort.rawValue @@ -39,8 +32,10 @@ extension CommentAPIWorker { } - // MARK: - Create Comment - + /// 게시물에 댓글을 등록하는 Method입니다. + /// HTTP Method: POST + /// - Parameters: postId: String + /// - Returns: PostCommentResponseDTO func createComment( postId: String, body: CreatePostCommentReqeustDTO @@ -51,8 +46,10 @@ extension CommentAPIWorker { } - // MARK: - Update Comment - + /// 게시물에 등록된 댓글을 수정하는 Method입니다. + /// HTTP Method: PUT + /// - Parameters: postId: String, commentId: String + /// - Returns: PostCommentResponseDTO func updateComment( postId: String, commentId: String, @@ -64,12 +61,14 @@ extension CommentAPIWorker { } - // MARK: - Delete Comment - + /// 게시물에 등록된 댓글을 삭제하는 Method입니다. + /// HTTP Method: Delete + /// - Parameters: postId: String, commentId: String + /// - Returns: DeletePostCommentResponseDTO func deleteComment( postId: String, commentId: String - ) -> Observable { + ) -> Observable { let spec = CommentAPIs.deletePostComment(postId: postId, commentId: commentId).spec return request(spec) diff --git a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/CommentAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/CommentAPIs.swift index 5f25ffdb1..1412ff4f7 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/CommentAPIs.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/CommentAPIs.swift @@ -9,9 +9,13 @@ import Core import Foundation enum CommentAPIs: BBAPI { + /// 게시물 댓글 조회 case fetchPostComment(postId: String, page: Int, size: Int, sort: String) + /// 게시물 댓글 추가 case createPostComment(postId: String, body: CreatePostCommentReqeustDTO) + /// 게시물 댓글 수정 case updatePostComment(postId: String, commentId: String) + /// 게시물 댓글 삭제 case deletePostComment(postId: String, commentId: String) var spec: Spec { @@ -47,4 +51,8 @@ enum CommentAPIs: BBAPI { ) } } + + final class Worker: BBRxAPIWorker { + init() { } + } } diff --git a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/CreatePostCommentReqeustDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/CreatePostCommentReqeustDTO.swift index 6e99829c1..6e908e76d 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/CreatePostCommentReqeustDTO.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/CreatePostCommentReqeustDTO.swift @@ -8,5 +8,5 @@ import Foundation public struct CreatePostCommentReqeustDTO: Encodable { - var content: String + let content: String } diff --git a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/PostCommentDeleteResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/DeletePostCommentResponseDTO.swift similarity index 65% rename from 14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/PostCommentDeleteResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/DeletePostCommentResponseDTO.swift index 7ce370f22..c2fe026b5 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/PostCommentDeleteResponseDTO.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/DeletePostCommentResponseDTO.swift @@ -8,11 +8,11 @@ import Domain import Foundation -public struct PostCommentDeleteResponseDTO: Decodable { - var success: Bool +public struct DeletePostCommentResponseDTO: Decodable { + let success: Bool } -extension PostCommentDeleteResponseDTO { +extension DeletePostCommentResponseDTO { func toDomain() -> PostCommentDeleteEntity { return .init(success: success) } diff --git a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/GetPostCommentResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/GetPostCommentResponseDTO.swift new file mode 100644 index 000000000..cfcb6b01e --- /dev/null +++ b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/GetPostCommentResponseDTO.swift @@ -0,0 +1,29 @@ +// +// PaginationResponsePostCommentResponseDTO.swift +// Data +// +// Created by 김건우 on 1/17/24. +// + +import Domain +import Foundation + +public struct GetPostCommentResponseDTO: Decodable { + let currentPage: Int + let totalPage: Int + let itemPerPage: Int + let hasNext: Bool + let results: [PostCommentResponseDTO] +} + +extension GetPostCommentResponseDTO { + func toDomain() -> PaginationResponsePostCommentEntity { + return .init( + currentPage: currentPage, + totalPage: totalPage, + itemPerPage: itemPerPage, + hasNext: hasNext, + results: results.map { $0.toDomain() } + ) + } +} diff --git a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/PaginationResponsePostCommentResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/PaginationResponsePostCommentResponseDTO.swift deleted file mode 100644 index b1e7d3d31..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/PaginationResponsePostCommentResponseDTO.swift +++ /dev/null @@ -1,65 +0,0 @@ -// -// PaginationResponsePostCommentResponseDTO.swift -// Data -// -// Created by 김건우 on 1/17/24. -// - -import Domain -import Foundation - -public struct PaginationResponsePostCommentResponseDTO: Decodable { - private enum CodingKeys: String, CodingKey { - case currentPage - case totalPage - case itemPerPage - case hasNext - case results - } - var currentPage: Int - var totalPage: Int - var itemPerPage: Int - var hasNext: Bool - var results: [PostCommentResponseDTO] -} - -extension PaginationResponsePostCommentResponseDTO { - public struct PostCommentResponseDTO: Decodable { - private enum CodingKeys: String, CodingKey { - case commentId - case postId - case memberId - case comment - case createdAt - } - var commentId: String - var postId: String - var memberId: String - var comment: String - var createdAt: String - } -} - -extension PaginationResponsePostCommentResponseDTO { - func toDomain() -> PaginationResponsePostCommentEntity { - return .init( - currentPage: currentPage, - totalPage: totalPage, - itemPerPage: itemPerPage, - hasNext: hasNext, - results: results.map { $0.toDomain() } - ) - } -} - -extension PaginationResponsePostCommentResponseDTO.PostCommentResponseDTO { - func toDomain() -> PostCommentEntity { - return .init( - commentId: commentId, - postId: postId, - memberId: memberId, - comment: comment, - createdAt: createdAt.iso8601ToDate() - ) - } -} diff --git a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/PostCommentResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/PostCommentResponseDTO.swift index c9221ad1b..43a38a4bb 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/PostCommentResponseDTO.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/PostCommentResponseDTO.swift @@ -9,18 +9,11 @@ import Domain import Foundation public struct PostCommentResponseDTO: Decodable { - private enum CodingKeys: String, CodingKey { - case commentId - case postId - case memberId - case comment - case createdAt - } - var commentId: String - var postId: String - var memberId: String - var comment: String - var createdAt: String + let commentId: String + let postId: String + let memberId: String + let comment: String + let createdAt: String } extension PostCommentResponseDTO { diff --git a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/UpdatePostCommentRequestDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/UpdatePostCommentRequestDTO.swift index 81dde4523..77b79c531 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/UpdatePostCommentRequestDTO.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Comment/CommentAPI/DataMapping/UpdatePostCommentRequestDTO.swift @@ -8,5 +8,5 @@ import Foundation public struct UpdatePostCommentReqeustDTO: Encodable { - var content: String + let content: String } diff --git a/14th-team5-iOS/Data/Sources/APIs/DefaultResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/DefaultResponseDTO.swift new file mode 100644 index 000000000..5eea2d6fa --- /dev/null +++ b/14th-team5-iOS/Data/Sources/APIs/DefaultResponseDTO.swift @@ -0,0 +1,18 @@ +// +// DefaultResponseDTO.swift +// Data +// +// Created by 마경미 on 15.12.24. +// + +import Domain + +struct DefaultResponseDTO: Decodable { + let success: Bool +} + +extension DefaultResponseDTO { + func toDomain() -> DefaultEntity { + return .init(success: self.success) + } +} diff --git a/14th-team5-iOS/Data/Sources/APIs/Family/FamilyWorker.swift b/14th-team5-iOS/Data/Sources/APIs/Family/FamilyAPIWorker.swift similarity index 93% rename from 14th-team5-iOS/Data/Sources/APIs/Family/FamilyWorker.swift rename to 14th-team5-iOS/Data/Sources/APIs/Family/FamilyAPIWorker.swift index c9a1a3f05..24bfa0a19 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Family/FamilyWorker.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Family/FamilyAPIWorker.swift @@ -9,8 +9,8 @@ import Core import RxSwift -typealias FamilyWorker = FamilyAPIs.Worker -extension FamilyWorker { +typealias FamilyAPIWorker = FamilyAPIs.Worker +extension FamilyAPIWorker { /// 가족이 생성된 날짜를 조회하기 위한 Method입니다. /// HTTP Method: GET /// - Parameters: familyId: String diff --git a/14th-team5-iOS/Data/Sources/APIs/FamilyInviteView/FamilyInviteViewWorker.swift b/14th-team5-iOS/Data/Sources/APIs/FamilyInviteView/FamilyInviteViewAPIWorker.swift similarity index 83% rename from 14th-team5-iOS/Data/Sources/APIs/FamilyInviteView/FamilyInviteViewWorker.swift rename to 14th-team5-iOS/Data/Sources/APIs/FamilyInviteView/FamilyInviteViewAPIWorker.swift index c98458559..80bf4df13 100644 --- a/14th-team5-iOS/Data/Sources/APIs/FamilyInviteView/FamilyInviteViewWorker.swift +++ b/14th-team5-iOS/Data/Sources/APIs/FamilyInviteView/FamilyInviteViewAPIWorker.swift @@ -7,8 +7,8 @@ import RxSwift -typealias FamilyInviteViewWorker = FamilyInviteViewAPIs.Worker -extension FamilyInviteViewWorker { +typealias FamilyInviteViewAPIWorker = FamilyInviteViewAPIs.Worker +extension FamilyInviteViewAPIWorker { /// 가족방 초대 링크를 조회하기 위한 Method입니다. /// HTTP Method: GET /// - Parameters: familyId: String diff --git a/14th-team5-iOS/Data/Sources/APIs/Link/LinkWorker.swift b/14th-team5-iOS/Data/Sources/APIs/Link/LinkAPIWorker.swift similarity index 87% rename from 14th-team5-iOS/Data/Sources/APIs/Link/LinkWorker.swift rename to 14th-team5-iOS/Data/Sources/APIs/Link/LinkAPIWorker.swift index e39fd6f48..4c30d6960 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Link/LinkWorker.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Link/LinkAPIWorker.swift @@ -9,8 +9,8 @@ import Core import RxSwift -typealias LinkWorker = LinkAPIs.Worker -extension LinkWorker { +typealias LinkAPIWorker = LinkAPIs.Worker +extension LinkAPIWorker { /// 가족 초대 링크를 생성하는 Method입니다. /// HTTP Method: POST /// - Parameters: familyId: String diff --git a/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/DataMapping/MainNightResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/MainView/DataMapping/MainNightResponseDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/DataMapping/MainNightResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/MainView/DataMapping/MainNightResponseDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/DataMapping/MainRequestDTO.swift b/14th-team5-iOS/Data/Sources/APIs/MainView/DataMapping/MainRequestDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/DataMapping/MainRequestDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/MainView/DataMapping/MainRequestDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/DataMapping/MainResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/MainView/DataMapping/MainResponseDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/DataMapping/MainResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/MainView/DataMapping/MainResponseDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/MainViewAPIWorker.swift b/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/MainViewAPIWorker.swift deleted file mode 100644 index 6313231a8..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/MainViewAPIWorker.swift +++ /dev/null @@ -1,59 +0,0 @@ -// -// MainAPIWorker.swift -// Data -// -// Created by 마경미 on 20.04.24. -// - -import Foundation - -import Core -import Domain - -import RxSwift - -typealias MainAPIWorker = MainViewAPIs.Worker -extension MainViewAPIs { - final class Worker: APIWorker { - static let queue = { - ConcurrentDispatchQueueScheduler(queue: DispatchQueue(label: "MainAPIWorker", qos: .utility)) - }() - - override init() { - super.init() - self.id = "MainAPIWorker" - } - - var headers: [APIHeader] { - var headers: [any APIHeader] = [] - - _headers.subscribe(onNext: { result in - if let unwrappedHeaders = result { - headers = unwrappedHeaders - } - }).dispose() - - return headers - } - } -} - -extension MainAPIWorker { - func fetchMain() -> Single { - let spec = MainViewAPIs.fetchMain.spec - return request(spec: spec, headers: headers) - .subscribe(on: Self.queue) - .map(MainResponseDTO.self) - .catchAndReturn(nil) - .asSingle() - } - - func fetchMainNight() -> Single { - let spec = MainViewAPIs.fetchMainNight.spec - return request(spec: spec, headers: headers) - .subscribe(on: Self.queue) - .map(MainNightResponseDTO.self) - .catchAndReturn(nil) - .asSingle() - } -} diff --git a/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/MainViewAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/MainViewAPIs.swift deleted file mode 100644 index ba2346705..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPI/MainViewAPIs.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// MainAPIs.swift -// Data -// -// Created by 마경미 on 20.04.24. -// - -import Core -import Foundation - -enum MainViewAPIs: API { - case fetchMain - case fetchMainNight - - var spec: APISpec { - switch self { - case .fetchMain: - let urlString = "\(BibbiAPI.hostApi)/view/main/daytime-page" - return APISpec(method: .get, url: urlString) - case .fetchMainNight: - let urlString = "\(BibbiAPI.hostApi)/view/main/nighttime-page" - return APISpec(method: .get, url: urlString) - } - } -} diff --git a/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPIWorker.swift b/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPIWorker.swift new file mode 100644 index 000000000..535257bc2 --- /dev/null +++ b/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPIWorker.swift @@ -0,0 +1,33 @@ +// +// MainAPIWorker.swift +// Data +// +// Created by 마경미 on 20.04.24. +// + +import Foundation + +import Core +import Domain + +import RxSwift + +typealias MainAPIWorker = MainViewAPIs.Worker + +extension MainAPIWorker { + /// 생존신고 활성화 시간에 main 화면 데이터를 조회하기 위한 Method입니다. + /// HTTP Method: GET + /// - Returns: MainResponseDTO + func fetchMain() -> Observable { + let spec = MainViewAPIs.fetchMain.spec + return request(spec) + } + + /// 생존신고 비활성화 시간에 main 화면 데이터를 조회하기 위한 Method입니다. + /// HTTP Method: GET + /// - Returns: MainNightResponseDTO + func fetchMainNight() -> Observable { + let spec = MainViewAPIs.fetchMainNight.spec + return request(spec) + } +} diff --git a/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPIs.swift new file mode 100644 index 000000000..4cd774562 --- /dev/null +++ b/14th-team5-iOS/Data/Sources/APIs/MainView/MainViewAPIs.swift @@ -0,0 +1,34 @@ +// +// MainAPIs.swift +// Data +// +// Created by 마경미 on 20.04.24. +// + +import Core + +enum MainViewAPIs: BBAPI { + /// 주간의 메인페이지 조회 + case fetchMain + /// 야간의 메인페이지 조회 + case fetchMainNight + + var spec: Spec { + switch self { + case .fetchMain: + return .init( + method: .get, + path: "/view/main/daytime-page" + ) + case .fetchMainNight: + return .init( + method: .get, + path: "/view/main/nighttime-page" + ) + } + } + + final class Worker: BBRxAPIWorker { + init() { } + } +} diff --git a/14th-team5-iOS/Data/Sources/APIs/MainView/Repository/MainViewRepository.swift b/14th-team5-iOS/Data/Sources/APIs/MainView/Repository/MainViewRepository.swift deleted file mode 100644 index c1b92c31f..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/MainView/Repository/MainViewRepository.swift +++ /dev/null @@ -1,51 +0,0 @@ -// -// MainRepository.swift -// Data -// -// Created by 마경미 on 20.04.24. -// - -import Foundation - -import Domain - -import RxSwift - -public final class MainViewRepository: MainViewRepositoryProtocol { - public let disposeBag: DisposeBag = DisposeBag() - - private let familyUserDefaults: FamilyInfoUserDefaults = FamilyInfoUserDefaults() - private let mainApiWorker: MainAPIWorker = MainAPIWorker() - - public init() { } -} - -extension MainViewRepository { - public func fetchMain() -> Observable { - return mainApiWorker.fetchMain() - .map { $0?.toDomain() } - .do(onSuccess: { [weak self] in - guard - let self, - let profiles = $0?.mainFamilyProfileDatas else { - return - } - self.familyUserDefaults.saveFamilyMembers(profiles) - }) - .asObservable() - } - - public func fetchMainNight() -> Observable { - return mainApiWorker.fetchMainNight() - .map { $0?.toDomain() } - .do(onSuccess: { [weak self] in - guard - let self, - let profiles = $0?.mainFamilyProfileDatas else { - return - } - self.familyUserDefaults.saveFamilyMembers(profiles) - }) - .asObservable() - } -} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/AddFCMTokenRequestDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Me/DataMapping/AddFCMTokenRequestDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/AddFCMTokenRequestDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Me/DataMapping/AddFCMTokenRequestDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/App/AppAPI/DataMapping/AppVersionResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Me/DataMapping/AppVersionResponseDTO.swift similarity index 54% rename from 14th-team5-iOS/Data/Sources/APIs/App/AppAPI/DataMapping/AppVersionResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Me/DataMapping/AppVersionResponseDTO.swift index 5c4a64372..939aa57e5 100644 --- a/14th-team5-iOS/Data/Sources/APIs/App/AppAPI/DataMapping/AppVersionResponseDTO.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Me/DataMapping/AppVersionResponseDTO.swift @@ -8,19 +8,12 @@ import Domain import Foundation -public struct AppVersionResponseDTO: Decodable { - private enum CodingKeys: String, CodingKey { - case appKey - case appVersion - case latest - case inReview - case inService - } - var appKey: String - var appVersion: String - var latest: Bool - var inReview: Bool - var inService: Bool +struct AppVersionResponseDTO: Decodable { + let appKey: String + let appVersion: String + let latest: Bool + let inReview: Bool + let inService: Bool } extension AppVersionResponseDTO { diff --git a/14th-team5-iOS/Data/Sources/APIs/Me/MeAPI.swift b/14th-team5-iOS/Data/Sources/APIs/Me/MeAPI.swift index 3470ba86d..8f8eea620 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Me/MeAPI.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Me/MeAPI.swift @@ -17,17 +17,51 @@ enum MeAPI: BBAPI { case createFamily /// 내 가족 정보 조회 case fetchFamilyInfo + /// fcm 토큰 등록 + case registerFCMToken + /// fcm 토큰 삭제 + case deleteFCMToken(_ token: String) + /// 내 접속 버전 조회 + case appVersion(_ appKey: String) var spec: Spec { switch self { case .joinFamily: - return .init(method: .post, path: "/me/join-family") + return .init( + method: .post, + path: "/me/join-family" + ) case .resignFamily: - return .init(method: .post, path: "/me/quit-family") + return .init( + method: .post, + path: "/me/quit-family" + ) case .createFamily: - return .init(method: .post, path: "/me/create-family") + return .init( + method: .post, + path: "/me/create-family" + ) case .fetchFamilyInfo: - return .init(method: .get, path: "/me/family-info") + return .init( + method: .get, + path: "/me/family-info" + ) + case .registerFCMToken: + return .init( + method: .post, + path: "/me/fcm" + ) + case let .deleteFCMToken(token): + return .init( + method: .delete, + path: "/me/fcm/\(token)" + ) + case let .appVersion(version): + return .init( + method: .get, + path: "/me/app-version", + queryParametersEncodable: version + ) } } diff --git a/14th-team5-iOS/Data/Sources/APIs/Me/MeWorker.swift b/14th-team5-iOS/Data/Sources/APIs/Me/MeeAPIWorker.swift similarity index 53% rename from 14th-team5-iOS/Data/Sources/APIs/Me/MeWorker.swift rename to 14th-team5-iOS/Data/Sources/APIs/Me/MeeAPIWorker.swift index 49bea8d0f..f6391149c 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Me/MeWorker.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Me/MeeAPIWorker.swift @@ -10,8 +10,8 @@ import Core import RxSwift // TODO: MeWorker로 이름 바꾸기 -typealias MeeWorker = MeAPI.Worker -extension MeeWorker { +typealias MeeAPIWorker = MeAPI.Worker +extension MeeAPIWorker { /// 가족방 탈퇴를 위한 Method입니다. /// HTTP Method: Post /// - Returns: DefaultResponseDTO? @@ -50,4 +50,41 @@ extension MeeWorker { return request(spec) } + + /// FCM 토큰을 등록하기 위한 Method입니다. + /// HTTP Method: POST + /// - parameters: body: AddFCMTokenRequestDTO + /// - Returns: DefaultResponseDTO + func registerNewFCMToken( + body: AddFCMTokenRequestDTO + ) -> Observable { + let spec = MeAPI.registerFCMToken.spec + + return request(spec) + } + + + /// 등록된 FCM 토큰을 삭제하기 위한 Method입니다. + /// HTTP Method: Delete + /// - parameters: token: String + /// - Returns: DefaultResponseDTO + func deleteFCMToken( + fcmToken token: String + ) -> Observable { + let spec = MeAPI.deleteFCMToken(token).spec + + return request(spec) + } + + /// 현재 설치된 앱 버전 정보를 조회하기 위한 Method입니다. + /// HTTP Method: Get + /// - parameters: appKey: String + /// - Returns: AppVersionResponseDTO + func fetchAppVersion( + appKey: String + ) -> Observable { + let spec = MeAPI.appVersion(appKey).spec + + return request(spec) + } } diff --git a/14th-team5-iOS/Data/Sources/APIs/MemberRealEmoji/MemberRealEmojiWorker.swift b/14th-team5-iOS/Data/Sources/APIs/MemberRealEmoji/MemberRealEmojiAPIWorker.swift similarity index 83% rename from 14th-team5-iOS/Data/Sources/APIs/MemberRealEmoji/MemberRealEmojiWorker.swift rename to 14th-team5-iOS/Data/Sources/APIs/MemberRealEmoji/MemberRealEmojiAPIWorker.swift index 9bc6b2720..088fade50 100644 --- a/14th-team5-iOS/Data/Sources/APIs/MemberRealEmoji/MemberRealEmojiWorker.swift +++ b/14th-team5-iOS/Data/Sources/APIs/MemberRealEmoji/MemberRealEmojiAPIWorker.swift @@ -7,8 +7,8 @@ import RxSwift -typealias MemberRealEmojiWorker = MemberRealEmojiAPIs.Worker -extension MemberRealEmojiWorker { +typealias MemberRealEmojiAPIWorker = MemberRealEmojiAPIs.Worker +extension MemberRealEmojiAPIWorker { /// 회원에 등록된 리얼 이모지를 조회하는 Method입니다. /// HTTP Method: GET diff --git a/14th-team5-iOS/Data/Sources/APIs/Members/MembersWorker.swift b/14th-team5-iOS/Data/Sources/APIs/Members/MembersAPIWorker.swift similarity index 98% rename from 14th-team5-iOS/Data/Sources/APIs/Members/MembersWorker.swift rename to 14th-team5-iOS/Data/Sources/APIs/Members/MembersAPIWorker.swift index 4bf4a9cf3..5fef4f0fe 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Members/MembersWorker.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Members/MembersAPIWorker.swift @@ -11,8 +11,8 @@ import Core import RxSwift -typealias MembersWorker = MembersAPIs.Worker -extension MembersWorker { +typealias MembersAPIWorker = MembersAPIs.Worker +extension MembersAPIWorker { /// 회원 프로필 정보를 조회하기 위한 Method 입니다. /// HTTP Method : GET diff --git a/14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPI/DataMapping/MissionContentResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Mission/DataMapping/MissionContentResponseDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPI/DataMapping/MissionContentResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Mission/DataMapping/MissionContentResponseDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPI/DataMapping/MissonTodayContentResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Mission/DataMapping/MissonTodayContentResponseDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPI/DataMapping/MissonTodayContentResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Mission/DataMapping/MissonTodayContentResponseDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPI/MissionAPIWorker.swift b/14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPIWorker.swift similarity index 95% rename from 14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPI/MissionAPIWorker.swift rename to 14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPIWorker.swift index b15c78f6d..ef7d144d0 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPI/MissionAPIWorker.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPIWorker.swift @@ -20,7 +20,7 @@ extension MissionAPIWorker { /// HTTP Method : GET /// - Parameters : missonid(미션 ID) /// - Returns : MissionContentResponseDTO - func fetchMissonContent(missonId: String) -> Observable { + func fetchMissonContent(missonId: String) -> Observable { let spec = MissionAPIs.fetchMissonContent(missonId: missonId).spec return request(spec) @@ -29,7 +29,7 @@ extension MissionAPIWorker { /// 미션 일일 정보를 조회하기 위한 API 입니다. /// HTTP Method : GET /// - Returns : CameraTodayMissionResponseDTO - func fetchDailyMisson() -> Observable { + func fetchDailyMisson() -> Observable { let spec = MissionAPIs.fetchDailyMisson.spec return request(spec) diff --git a/14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPI/MissionAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPIs.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPI/MissionAPIs.swift rename to 14th-team5-iOS/Data/Sources/APIs/Mission/MissionAPIs.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/AuthAPIWorker.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/AuthAPIWorker.swift new file mode 100644 index 000000000..9422c906a --- /dev/null +++ b/14th-team5-iOS/Data/Sources/APIs/OAuth/AuthAPIWorker.swift @@ -0,0 +1,47 @@ +// +// OAuthAPIWorker.swift +// Data +// +// Created by 김건우 on 6/6/24. +// + +import Core +import Domain +import Foundation + +import RxSwift + +typealias AuthAPIWorker = AuthAPIs.Worker +extension AuthAPIWorker { + /// 리프레시 토큰으로 새로운 토큰을 발급받는 Method입니다. + /// HTTP Method: POST + /// - Parameters: body: RefreshAcceessTokenRequestDTO + /// - Returns: AuthResultResponseDTO + func refreshAccessToken(body: RefreshTokenRequestDTO) -> Observable { + let spec = AuthAPIs.refreshToken.spec + return request(spec) + } + + /// 회원가입을 위한 Method입니다 + /// HTTP Method: POST + /// - Parameters: body: SignUpRequestDTO + /// - Returns: SignUpResponseDTO + func registerNewMember(body: SignUpRequestDTO) -> Observable { + let spec = AuthAPIs.registerMember.spec + + // TODO: 헤더 테스트 해보기 + return request(spec) + } + + + /// apple, kakao등 소셜 로그인 Method입니다. + /// HTTP Method: POST + /// - Parameters: type: SignInType, body: NativeSocialLoginRequestDTO + /// - Returns: NativeSocialLoginResponseDTO + func signIn(_ type: SignInType, body: NativeSocialLoginRequestDTO) -> Observable { + let spec = AuthAPIs.signIn(type).spec + + // TODO: 헤더 테스트 해보기 + return request(spec) + } +} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/AuthAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/AuthAPIs.swift new file mode 100644 index 000000000..73b5b0b5e --- /dev/null +++ b/14th-team5-iOS/Data/Sources/APIs/OAuth/AuthAPIs.swift @@ -0,0 +1,43 @@ +// +// OAuthAPIs.swift +// Data +// +// Created by 김건우 on 6/6/24. +// + +import Core +import Domain +import Foundation + +enum AuthAPIs: BBAPI { + // 토큰 재발행 + case refreshToken + /// 회원가입 + case registerMember + /// 네이티브 소셜 로그인 + case signIn(SignInType) + + var spec: Spec { + switch self { + case .refreshToken: + return .init( + method: .post, + path: "/auth/refresh" + ) + case .registerMember: + return .init( + method: .post, + path: "/auth/register" + ) + case let .signIn(type): + return .init( + method: .post, + path: "/auth/social/\(type)" + ) + } + } + + final class Worker: BBRxAPIWorker { + init() { } + } +} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/AuthResultResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/AuthResultResponseDTO.swift similarity index 50% rename from 14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/AuthResultResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/AuthResultResponseDTO.swift index 1d58ec3b8..02a759b4a 100644 --- a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/AuthResultResponseDTO.swift +++ b/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/AuthResultResponseDTO.swift @@ -6,20 +6,14 @@ // import Domain -import Foundation -public struct AuthResultResponseDTO: Decodable { - private enum CodingKeys: String, CodingKey { - case accessToken - case refreshToken - case isTemporaryToken - } - var accessToken: String - var refreshToken: String - var isTemporaryToken: Bool +struct NativeSocialLoginResponseDTO: Decodable { + let accessToken: String + let refreshToken: String + let isTemporaryToken: Bool } -extension AuthResultResponseDTO { +extension NativeSocialLoginResponseDTO { public func toDomain() -> AuthResultEntity { return .init( refreshToken: self.refreshToken, diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/NativeSocialLoginRequestDTO.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/NativeSocialLoginRequestDTO.swift new file mode 100644 index 000000000..0f4362d5d --- /dev/null +++ b/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/NativeSocialLoginRequestDTO.swift @@ -0,0 +1,12 @@ +// +// NativeSocialLoginRequestDTO.swift +// Data +// +// Created by 김건우 on 6/6/24. +// + +import Foundation + +struct NativeSocialLoginRequestDTO: Encodable { + let accessToken: String +} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/RefreshTokenRequestDTO.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/RefreshTokenRequestDTO.swift new file mode 100644 index 000000000..f09355abc --- /dev/null +++ b/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/RefreshTokenRequestDTO.swift @@ -0,0 +1,13 @@ +// +// RefreshAccessTokenRequestDTO.swift +// Data +// +// Created by 김건우 on 6/6/24. +// + +import Domain +import Foundation + +public struct RefreshTokenRequestDTO: Encodable { + let refreshToken: String +} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/RefreshTokenResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/RefreshTokenResponseDTO.swift new file mode 100644 index 000000000..83f31d967 --- /dev/null +++ b/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/RefreshTokenResponseDTO.swift @@ -0,0 +1,24 @@ +// +// RefreshTokenResponseDTO.swift +// Data +// +// Created by 마경미 on 15.12.24. +// + +import Domain + +struct RefreshTokenResponseDTO: Decodable { + let accessToken: String + let refreshToken: String + let isTemporaryToken: Bool +} + +extension RefreshTokenResponseDTO { + func toDomain() -> AuthResultEntity { + return .init( + refreshToken: self.refreshToken, + accessToken: self.accessToken, + isTemporaryToken: self.isTemporaryToken + ) + } +} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/SignUpRequestDTO.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/SignUpRequestDTO.swift new file mode 100644 index 000000000..10ee07359 --- /dev/null +++ b/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/SignUpRequestDTO.swift @@ -0,0 +1,14 @@ +// +// CreateNewMemberRequestDTO.swift +// Data +// +// Created by 김건우 on 6/6/24. +// + +import Foundation + +struct SignUpRequestDTO: Encodable { + let memberName: String + let dayOfBirth: String + let profileImageUrl: String +} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/SignUpResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/SignUpResponseDTO.swift new file mode 100644 index 000000000..c716aab26 --- /dev/null +++ b/14th-team5-iOS/Data/Sources/APIs/OAuth/DataMapping/SignUpResponseDTO.swift @@ -0,0 +1,24 @@ +// +// SignUpResponseDTO.swift +// Data +// +// Created by 마경미 on 15.12.24. +// + +import Domain + +struct SignUpResponseDTO: Decodable { + let accessToken: String + let refreshToken: String + let isTemporaryToken: Bool +} + +extension SignUpResponseDTO { + func toDomain() -> AuthResultEntity { + return .init( + refreshToken: self.refreshToken, + accessToken: self.accessToken, + isTemporaryToken: self.isTemporaryToken + ) + } +} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/CreateNewMemberRequestDTO.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/CreateNewMemberRequestDTO.swift deleted file mode 100644 index 7f85c8f54..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/CreateNewMemberRequestDTO.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// CreateNewMemberRequestDTO.swift -// Data -// -// Created by 김건우 on 6/6/24. -// - -import Foundation - -public struct CreateNewMemberRequestDTO: Encodable { - private enum CodingKeys: String, CodingKey { - case memberName - case dayOfBirth - case profileImageUrl - } - var memberName: String - var dayOfBirth: String - var profileImageUrl: String -} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/DefaultResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/DefaultResponseDTO.swift deleted file mode 100644 index a14e6d2b7..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/DefaultResponseDTO.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// DefaultResponseDTO.swift -// Data -// -// Created by 김건우 on 6/6/24. -// - -import Domain -import Foundation - -public struct DefaultResponseDTO: Decodable { - private enum CodingKeys: String, CodingKey { - case success - } - var success: Bool -} - -extension DefaultResponseDTO { - func toDomain() -> DefaultEntity { - return .init(success: self.success) - } -} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/NativeSocialLoginRequestDTO.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/NativeSocialLoginRequestDTO.swift deleted file mode 100644 index 879a86ab8..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/NativeSocialLoginRequestDTO.swift +++ /dev/null @@ -1,15 +0,0 @@ -// -// NativeSocialLoginRequestDTO.swift -// Data -// -// Created by 김건우 on 6/6/24. -// - -import Foundation - -public struct NativeSocialLoginRequestDTO: Encodable { - private enum CodingKeys: String, CodingKey { - case accessToken - } - var accessToken: String -} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/RefreshAccessTokenRequestDTO.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/RefreshAccessTokenRequestDTO.swift deleted file mode 100644 index 0ab28a00f..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/DataMapping/RefreshAccessTokenRequestDTO.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// RefreshAccessTokenRequestDTO.swift -// Data -// -// Created by 김건우 on 6/6/24. -// - -import Domain -import Foundation - -public struct RefreshAccessTokenRequestDTO: Encodable { - private enum CodingKeys: String, CodingKey { - case refreshToken - } - var refreshToken: String -} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/OAuthAPIWorker.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/OAuthAPIWorker.swift deleted file mode 100644 index 172d1c6a1..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/OAuthAPIWorker.swift +++ /dev/null @@ -1,99 +0,0 @@ -// -// OAuthAPIWorker.swift -// Data -// -// Created by 김건우 on 6/6/24. -// - -import Core -import Domain -import Foundation - -import RxSwift - -public typealias OAuthAPIWorker = OAuthAPIs.Worker -extension OAuthAPIs { - final public class Worker: APIWorker { - static let queue = { - ConcurrentDispatchQueueScheduler(queue: DispatchQueue(label: "OAuthAPIQueue", qos: .utility)) - }() - - override init() { - super.init() - self.id = "OAuthAPIWorker" - } - } -} - -// MARK: - Extensions - -extension OAuthAPIWorker { - - // MARK: - Refresh Access Token - - public func refreshAccessToken(body: RefreshAccessTokenRequestDTO) -> Single { - let spec = OAuthAPIs.refreshToken.spec - let headers = BibbiHeader.commonHeaders() // TODO: - Header 없애기 - - return request(spec: spec, headers: headers, jsonEncodable: body) - .subscribe(on: Self.queue) - .map(AuthResultResponseDTO.self) - .catchAndReturn(nil) - .asSingle() - } - - - // MARK: - Register New Member - - public func registerNewMember(body: CreateNewMemberRequestDTO) -> Single { - let spec = OAuthAPIs.registerMember.spec - - return request(spec: spec, jsonEncodable: body) - .subscribe(on: Self.queue) - .map(AuthResultResponseDTO.self) - .catchAndReturn(nil) - .asSingle() - } - - - // MARK: - Sign In With SNS - - public func signIn(_ type: SignInType, body: NativeSocialLoginRequestDTO) -> Single { - let spec = OAuthAPIs.signIn(type).spec - - return request(spec: spec, jsonEncodable: body) - .subscribe(on: Self.queue) - .map(AuthResultResponseDTO.self) - .catchAndReturn(nil) - .asSingle() - } - - - - // MARK: - Register FCM Token - - public func registerNewFCMToken(body: AddFCMTokenRequestDTO) -> Single { - let spec = OAuthAPIs.registerFCMToken.spec - - return request(spec: spec, jsonEncodable: body) - .subscribe(on: Self.queue) - .map(DefaultResponseDTO.self) - .catchAndReturn(nil) - .asSingle() - } - - - // MARK: - Delete FCM Token - - public func deleteFCMToken(fcmToken token: String) -> Single { - let spec = OAuthAPIs.deleteFCMToken(token).spec - - return request(spec: spec) - .subscribe(on: Self.queue) - .map(DefaultResponseDTO.self) - .catchAndReturn(nil) - .asSingle() - } - - -} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/OAuthAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/OAuthAPIs.swift deleted file mode 100644 index abdb96967..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/OAuthAPIs.swift +++ /dev/null @@ -1,35 +0,0 @@ -// -// OAuthAPIs.swift -// Data -// -// Created by 김건우 on 6/6/24. -// - -import Core -import Domain -import Foundation - -public enum OAuthAPIs: API { - case refreshToken - case registerMember - case signIn(SignInType) - - case registerFCMToken - case deleteFCMToken(String) - - public var spec: APISpec { - switch self { - case .refreshToken: - return APISpec(method: .post, url: "\(BibbiAPI.hostApi)/auth/refresh") - case .registerMember: - return APISpec(method: .post, url: "\(BibbiAPI.hostApi)/auth/register") - case let .signIn(type): - return APISpec(method: .post, url: "\(BibbiAPI.hostApi)/auth/social/\(type.rawValue)") - - case .registerFCMToken: - return APISpec(method: .post, url: "\(BibbiAPI.hostApi)/me/fcm") - case let .deleteFCMToken(token): - return APISpec(method: .delete, url: "\(BibbiAPI.hostApi)/me/fcm/\(token)") - } - } -} diff --git a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/Repository/OAuthRepository.swift b/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/Repository/OAuthRepository.swift deleted file mode 100644 index 98a960184..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/OAuth/OAuthAPI/Repository/OAuthRepository.swift +++ /dev/null @@ -1,133 +0,0 @@ -// -// OAuthRepository.swift -// Data -// -// Created by 김건우 on 6/6/24. -// - -import Core -import Domain - -import RxSwift -import RxCocoa - -public final class OAuthRepository: OAuthRepositoryProtocol { - - // MARK: - Properties - public var disposeBag = DisposeBag() - - public var oAuthApiWorker = OAuthAPIWorker() - public var tokenKeychainStorage = TokenKeychain() - - // MARK: - Intializer - public init() { } - -} - -extension OAuthRepository { - - // MARK: - Refresh Access Token - - public func refreshAccessToken(body: RefreshAccessTokenRequest) -> Observable { - let body = RefreshAccessTokenRequestDTO( - refreshToken: body.refreshToken - ) - return oAuthApiWorker.refreshAccessToken(body: body) - .observe(on: RxScheduler.main) - .map { $0?.toDomain() } - .do(onSuccess: { [weak self] in - guard - let keychain = self?.tokenKeychainStorage - else { return } - let accessToken = AccessToken( - accessToken: $0?.accessToken, - refreshToken: $0?.refreshToken, - isTemporaryToken: $0?.isTemporaryToken - ) - keychain.saveAccessToken(accessToken) - }) - .asObservable() - } - - - // MARK: - Register New Member - - public func registerNewMember(body: CreateNewMemberRequest) -> Observable { - let body = CreateNewMemberRequestDTO( - memberName: body.memberName, - dayOfBirth: body.dayOfBirth, - profileImageUrl: body.profileImageUrl - ) - return oAuthApiWorker.registerNewMember(body: body) - .observe(on: RxScheduler.main) - .map { $0?.toDomain() } - .do(onSuccess: { [weak self] in - guard - let keychain = self?.tokenKeychainStorage - else { return } - let accessToken = AccessToken( - accessToken: $0?.accessToken, - refreshToken: $0?.refreshToken, - isTemporaryToken: $0?.isTemporaryToken - ) - keychain.saveAccessToken(accessToken) - }) - .asObservable() - } - - - // MARK: - Sign In With SNS - - public func signIn(_ type: SignInType, body: NativeSocialLoginRequest) -> Observable { - let body = NativeSocialLoginRequestDTO( - accessToken: body.accessToken - ) - return oAuthApiWorker.signIn(type, body: body) - .observe(on: RxScheduler.main) - .map { $0?.toDomain() } - .do(onSuccess: { [weak self] in - guard - let keychain = self?.tokenKeychainStorage - else { return } - let accessToken = AccessToken( - accessToken: $0?.accessToken, - refreshToken: $0?.refreshToken, - isTemporaryToken: $0?.isTemporaryToken - ) - keychain.saveAccessToken(accessToken) - }) - .asObservable() - } - - - // MARK: - Register FCM Token - - public func registerNewFCMToken(body: AddFCMTokenRequest) -> Observable { - let body = AddFCMTokenRequestDTO( - fcmToken: body.fcmToken - ) - return oAuthApiWorker.registerNewFCMToken(body: body) - .observe(on: RxScheduler.main) - .map { $0?.toDomain() } - .asObservable() - } - - - // MARK: - Delete FCM Token - - public func deleteFCMToken() -> Observable { - - guard - let fcmToken = tokenKeychainStorage.loadFCMToken() - else { - return Observable.just(DefaultEntity(success: false)) - } - - return oAuthApiWorker.deleteFCMToken(fcmToken: fcmToken) - .observe(on: RxScheduler.main) - .map { $0?.toDomain() } - .asObservable() - - } - -} diff --git a/14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/CreatePostPresignedURLReqeustDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/CreatePostPresignedURLReqeustDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/CreatePostPresignedURLReqeustDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/CreatePostPresignedURLReqeustDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/CreatePostPresignedURLResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/CreatePostPresignedURLResponseDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/CreatePostPresignedURLResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/CreatePostPresignedURLResponseDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/CreatePostRequestDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/CreatePostRequestDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/CreatePostRequestDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/CreatePostRequestDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/CreatePostResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/CreatePostResponseDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/CreatePostResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/CreatePostResponseDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/CreatePresignedURLRequestDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/CreatePresignedURLRequestDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/CreatePresignedURLRequestDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/CreatePresignedURLRequestDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/PostDetailResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/PostDetailResponseDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/PostDetailResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/PostDetailResponseDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/PostListQueryDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/PostListQueryDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/PostListQueryDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/PostListQueryDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/PostListResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/PostListResponseDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/DataMapping/PostListResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Post/DataMapping/PostListResponseDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/PostAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/Post/PostAPIs.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/PostAPIs.swift rename to 14th-team5-iOS/Data/Sources/APIs/Post/PostAPIs.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/PostListAPIWorker.swift b/14th-team5-iOS/Data/Sources/APIs/Post/PostListAPIWorker.swift similarity index 99% rename from 14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/PostListAPIWorker.swift rename to 14th-team5-iOS/Data/Sources/APIs/Post/PostListAPIWorker.swift index 5b8e38b19..85908962b 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Post/PostAPI/PostListAPIWorker.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Post/PostListAPIWorker.swift @@ -16,8 +16,6 @@ import RxSwift typealias PostAPIWorker = PostsAPIs.Worker - - extension PostAPIWorker { /// 게시물 전체 조회하기 위한 Method 입니다. diff --git a/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPI/DataMaaping/RecentFamilyPostResponseDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Widget/DataMaaping/GetRecentPostsResponseDTO.swift similarity index 85% rename from 14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPI/DataMaaping/RecentFamilyPostResponseDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Widget/DataMaaping/GetRecentPostsResponseDTO.swift index cbd8c5076..0f5ad1201 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPI/DataMaaping/RecentFamilyPostResponseDTO.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Widget/DataMaaping/GetRecentPostsResponseDTO.swift @@ -9,14 +9,14 @@ import Foundation import Domain -struct RecentFamilyPostResponseDTO: Codable { +struct GetRecentPostsResponseDTO: Codable { let authorName: String let authorProfileImageUrl: String? let postId: String? let postImageUrl: String? let postContent: String? - func toDomain() -> RecentFamilyPostEntity { + func toDomain() -> WidgetPostEntity { return .init(authorName: authorName, authorProfileImageUrl: authorProfileImageUrl, postId: postId, diff --git a/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPI/DataMaaping/RecentFamilyPostRequestDTO.swift b/14th-team5-iOS/Data/Sources/APIs/Widget/DataMaaping/RecentFamilyPostRequestDTO.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPI/DataMaaping/RecentFamilyPostRequestDTO.swift rename to 14th-team5-iOS/Data/Sources/APIs/Widget/DataMaaping/RecentFamilyPostRequestDTO.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPI/WidgetAPIWorker.swift b/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPI/WidgetAPIWorker.swift deleted file mode 100644 index bdec40477..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPI/WidgetAPIWorker.swift +++ /dev/null @@ -1,51 +0,0 @@ -// -// WidgetAPIWorker.swift -// Data -// -// Created by 마경미 on 05.06.24. -// - -import Foundation - -import Core -import Domain - -import RxSwift - -typealias WidgetAPIWorker = WidgetAPIs.Worker -extension WidgetAPIs { - public final class Worker: APIWorker { - static let queue = { - ConcurrentDispatchQueueScheduler(queue: DispatchQueue(label: "WidgetAPIQueue", qos: .utility)) - }() - - public override init() { - super.init() - self.id = "WidgetAPIWorker" - } - - var headers: [APIHeader] { - guard let token = App.Repository.token.keychain.string(forKey: "accessToken") else { - return [] - } - - let headers = [BibbiAPI.Header.xAppKey, BibbiAPI.Header.xAuthToken(token), BibbiAPI.Header.acceptJson] - return headers - } - } -} - -extension WidgetAPIWorker { - func fetchRecentFamilyPost() -> Observable { - - let spec = WidgetAPIs.fetchRecentFamilyPost.spec - let parameters = RecentFamilyPostParameter() - - return request(spec: spec, headers: headers, parameters: parameters) - .subscribe(on: Self.queue) - .map(RecentFamilyPostResponseDTO.self) - .catchAndReturn(nil) - .map { $0?.toDomain() } - .asObservable() - } -} diff --git a/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPI/WidgetAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPI/WidgetAPIs.swift deleted file mode 100644 index ae13870c9..000000000 --- a/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPI/WidgetAPIs.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// WidgetAPIs.swift -// Data -// -// Created by 마경미 on 05.06.24. -// - -import Foundation - -import Core - -enum WidgetAPIs: API { - case fetchRecentFamilyPost - - public var spec: APISpec { - switch self { - case .fetchRecentFamilyPost: - let urlString = "\(BibbiAPI.hostApi)/widgets/single-recent-family-post" - return APISpec(method: .get, url: urlString) - } - } -} diff --git a/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPIWorker.swift b/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPIWorker.swift new file mode 100644 index 000000000..9bf59470c --- /dev/null +++ b/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPIWorker.swift @@ -0,0 +1,20 @@ +// +// WidgetAPIWorker.swift +// Data +// +// Created by 마경미 on 05.06.24. +// + +import RxSwift + +typealias WidgetAPIWorker = WidgetAPIs.Worker +extension WidgetAPIWorker { + /// 가장 최근에 올라온 가족의 게시글 하나를 조회하는 Method입니다. + /// HTTP Method: GET + /// - Returns: GetRecentPostsResponseDTO + func fetchRecentFamilyPost() -> Observable { + let spec = WidgetAPIs.fetchRecentFamilyPost.spec + + return request(spec) + } +} diff --git a/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPIs.swift new file mode 100644 index 000000000..210da2320 --- /dev/null +++ b/14th-team5-iOS/Data/Sources/APIs/Widget/WidgetAPIs.swift @@ -0,0 +1,27 @@ +// +// WidgetAPIs.swift +// Data +// +// Created by 마경미 on 05.06.24. +// + +import Core + +enum WidgetAPIs: BBAPI { + /// 당일 최근 가족 게시물 타입 위젯 조회 + case fetchRecentFamilyPost + + var spec: Spec { + switch self { + case .fetchRecentFamilyPost: + return .init( + method: .get, + path: "/widgets/single-recent-family-post" + ) + } + } + + final class Worker: BBRxAPIWorker { + init() { } + } +} diff --git a/14th-team5-iOS/Data/Sources/APIs/App/Repository/AppRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/AppRepository.swift similarity index 85% rename from 14th-team5-iOS/Data/Sources/APIs/App/Repository/AppRepository.swift rename to 14th-team5-iOS/Data/Sources/Repositories/AppRepository.swift index 2708349de..c8dbfd030 100644 --- a/14th-team5-iOS/Data/Sources/APIs/App/Repository/AppRepository.swift +++ b/14th-team5-iOS/Data/Sources/Repositories/AppRepository.swift @@ -13,10 +13,10 @@ import RxSwift public final class AppRepository: AppRepositoryProtocol { // MARK: - Properties - public let disposeBag = DisposeBag() + private let disposeBag = DisposeBag() // MARK: - APIWorker - private let appApiWorker = AppAPIWorker() + private let meAPIWorker = MeeAPIWorker() // MARK: - UserDefaults private let appUserDefaults = AppUserDefaults() @@ -31,13 +31,12 @@ public final class AppRepository: AppRepositoryProtocol { extension AppRepository { - public func fetchAppVersion() -> Observable { + public func fetchAppVersion() -> Observable { // TODO: - xAppKey 불러오는 코드 다시 작성하기 let appKey = "7b159d28-b106-4b6d-a490-1fd654ce40c2" - return appApiWorker.fetchAppVersion(appKey: appKey) - .map { $0?.toDomain() } - .asObservable() + return meAPIWorker.fetchAppVersion(appKey: appKey) + .map { $0.toDomain() } } public func loadIsFirstFamilyManagement() -> RxSwift.Observable { diff --git a/14th-team5-iOS/Data/Sources/Repositories/AuthRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/AuthRepository.swift new file mode 100644 index 000000000..f9cef0338 --- /dev/null +++ b/14th-team5-iOS/Data/Sources/Repositories/AuthRepository.swift @@ -0,0 +1,135 @@ +// +// OAuthRepository.swift +// Data +// +// Created by 김건우 on 6/6/24. +// + +import Core +import Domain +import Foundation + +import RxSwift +import RxCocoa + +public final class AuthRepository: OAuthRepositoryProtocol { + + // MARK: - Properties + private let disposeBag = DisposeBag() + + private let meAPIWorker = MeeAPIWorker() + private let authAPIWorker = AuthAPIWorker() + private let tokenKeychainStorage = TokenKeychain() + + // MARK: - Intializer + public init() { } +} + +extension AuthRepository { + + // MARK: - Refresh Access Token + + public func refreshAccessToken( + body: RefreshAccessTokenRequest + ) -> Observable { + let requestBody = RefreshTokenRequestDTO( + refreshToken: body.refreshToken + ) + + return authAPIWorker.refreshAccessToken(body: requestBody) + .flatMap { [weak self] response -> Observable in + guard let self = self else { + return Observable.error(NSError(domain: "RefreshError", code: -1, userInfo: nil)) + } + + let accessToken = AuthToken( + accessToken: response.accessToken, + refreshToken: response.refreshToken, + isTemporaryToken: response.isTemporaryToken + ) + + self.tokenKeychainStorage.saveAuthToken(accessToken) + return Observable.just(response.toDomain()) + } + } + + + // MARK: - Register New Member + + public func registerNewMember( + body: CreateNewMemberRequest + ) -> Observable { + let body = SignUpRequestDTO( + memberName: body.memberName, + dayOfBirth: body.dayOfBirth, + profileImageUrl: body.profileImageUrl + ) + + return authAPIWorker.registerNewMember(body: body) + .flatMap { [weak self] response -> Observable in + guard let keychain = self?.tokenKeychainStorage else { + return Observable.error(NSError(domain: "RegisterError", code: -1, userInfo: nil)) + } + let accessToken = AuthToken( + accessToken: response.accessToken, + refreshToken: response.refreshToken, + isTemporaryToken: response.isTemporaryToken + ) + keychain.saveAuthToken(accessToken) + + return Observable.just(response.toDomain()) + } + } + + + // MARK: - Sign In With SNS + + public func signIn( + _ type: SignInType, + body: NativeSocialLoginRequest + ) -> Observable { + let body = NativeSocialLoginRequestDTO( + accessToken: body.accessToken + ) + return authAPIWorker.signIn(type, body: body) + .flatMap { [weak self] response -> Observable in + guard let keychain = self?.tokenKeychainStorage else { + return Observable.error(NSError(domain: "SignInError", code: -1, userInfo: nil)) + } + let accessToken = AuthToken( + accessToken: response.accessToken, + refreshToken: response.refreshToken, + isTemporaryToken: response.isTemporaryToken + ) + keychain.saveAuthToken(accessToken) + + return Observable.just(response.toDomain()) + } + } + + + // MARK: - Register FCM Token + public func registerNewFCMToken( + body: AddFCMTokenRequest + ) -> Observable { + let body = AddFCMTokenRequestDTO( + fcmToken: body.fcmToken + ) + + return meAPIWorker.registerNewFCMToken(body: body) + .map { $0.toDomain() } + } + + + public func deleteFCMToken() -> Observable { + + guard + let fcmToken = tokenKeychainStorage.loadFCMToken() + else { + return Observable.just(DefaultEntity(success: false)) + } + + return meAPIWorker.deleteFCMToken(fcmToken: fcmToken) + .map { $0.toDomain() } + } +} diff --git a/14th-team5-iOS/Data/Sources/APIs/Calendar/Repository/CalendarRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/CalendarRepository.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Calendar/Repository/CalendarRepository.swift rename to 14th-team5-iOS/Data/Sources/Repositories/CalendarRepository.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Camera/Repository/CameraRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/CameraRepository.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Camera/Repository/CameraRepository.swift rename to 14th-team5-iOS/Data/Sources/Repositories/CameraRepository.swift diff --git a/14th-team5-iOS/Data/Sources/APIs/Comment/Repository/CommentRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/CommentRepository.swift similarity index 96% rename from 14th-team5-iOS/Data/Sources/APIs/Comment/Repository/CommentRepository.swift rename to 14th-team5-iOS/Data/Sources/Repositories/CommentRepository.swift index 26fb6a41c..458bf6557 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Comment/Repository/CommentRepository.swift +++ b/14th-team5-iOS/Data/Sources/Repositories/CommentRepository.swift @@ -11,7 +11,7 @@ import Foundation import RxSwift public final class CommentRepository: CommentRepositoryProtocol { - public let disposeBag: DisposeBag = DisposeBag() + private let disposeBag: DisposeBag = DisposeBag() private let commentApiWorker: CommentAPIWorker = CommentAPIWorker() diff --git a/14th-team5-iOS/Data/Sources/Repositories/FamilyRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/FamilyRepository.swift index 55c3da342..06d4b8c4b 100644 --- a/14th-team5-iOS/Data/Sources/Repositories/FamilyRepository.swift +++ b/14th-team5-iOS/Data/Sources/Repositories/FamilyRepository.swift @@ -13,13 +13,13 @@ import RxSwift public final class FamilyRepository: FamilyRepositoryProtocol { // MARK: - Properties - public let disposeBag: DisposeBag = DisposeBag() + private let disposeBag: DisposeBag = DisposeBag() - private let linkWorker: LinkWorker = LinkWorker() - private let meWorker: MeeWorker = MeeWorker() - private let membersWorker: MembersWorker = MembersWorker() - private let familyInviteViewWorker: FamilyInviteViewWorker = FamilyInviteViewWorker() - private let familyWorker: FamilyWorker = FamilyWorker() + private let linkWorker: LinkAPIWorker = LinkAPIWorker() + private let meWorker: MeeAPIWorker = MeeAPIWorker() + private let membersWorker: MembersAPIWorker = MembersAPIWorker() + private let familyInviteViewWorker: FamilyInviteViewAPIWorker = FamilyInviteViewAPIWorker() + private let familyWorker: FamilyAPIWorker = FamilyAPIWorker() private let familyUserDefaults: FamilyInfoUserDefaultsType = FamilyInfoUserDefaults() // MARK: - Intializer diff --git a/14th-team5-iOS/Data/Sources/Repositories/MainViewRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/MainViewRepository.swift new file mode 100644 index 000000000..e2d0291ac --- /dev/null +++ b/14th-team5-iOS/Data/Sources/Repositories/MainViewRepository.swift @@ -0,0 +1,53 @@ +// +// MainRepository.swift +// Data +// +// Created by 마경미 on 20.04.24. +// + +import Foundation + +import Domain + +import RxSwift + +public final class MainViewRepository: MainViewRepositoryProtocol { + public let disposeBag: DisposeBag = DisposeBag() + + private let familyUserDefaults: FamilyInfoUserDefaults = FamilyInfoUserDefaults() + private let mainApiWorker: MainAPIWorker = MainAPIWorker() + + public init() { } +} + +extension MainViewRepository { + public func fetchMain() -> Observable { + return mainApiWorker.fetchMain() + .flatMap { [weak self] response -> Observable in + guard let self else { + return Observable.error( + NSError(domain: "MainError", code: -1, userInfo: nil) + ) + } + let entities = response.toDomain() + let profiles = entities.mainFamilyProfileDatas + self.familyUserDefaults.saveFamilyMembers(profiles) + return Observable.just(entities) + } + } + + public func fetchMainNight() -> Observable { + return mainApiWorker.fetchMainNight() + .flatMap { [weak self] response -> Observable in + guard let self else { + return Observable.error( + NSError(domain: "MainError", code: -1, userInfo: nil) + ) + } + let entities = response.toDomain() + let profiles = entities.mainFamilyProfileDatas + self.familyUserDefaults.saveFamilyMembers(profiles) + return Observable.just(entities) + } + } +} diff --git a/14th-team5-iOS/Data/Sources/Repositories/MembersRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/MembersRepository.swift index 78b0c8b43..a3850a06a 100644 --- a/14th-team5-iOS/Data/Sources/Repositories/MembersRepository.swift +++ b/14th-team5-iOS/Data/Sources/Repositories/MembersRepository.swift @@ -15,10 +15,10 @@ import RxCocoa public final class MembersRepository { - public var disposeBag: DisposeBag = DisposeBag() + public let disposeBag: DisposeBag = DisposeBag() private let familyUserDefaults: FamilyInfoUserDefaults = FamilyInfoUserDefaults() - private let membersAPIWorker: MembersWorker = MembersWorker() + private let membersAPIWorker: MembersAPIWorker = MembersAPIWorker() public init() { } } diff --git a/14th-team5-iOS/Data/Sources/APIs/Mission/Repository/MissionRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/MissionRepository.swift similarity index 93% rename from 14th-team5-iOS/Data/Sources/APIs/Mission/Repository/MissionRepository.swift rename to 14th-team5-iOS/Data/Sources/Repositories/MissionRepository.swift index 6adbc53eb..9701c234f 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Mission/Repository/MissionRepository.swift +++ b/14th-team5-iOS/Data/Sources/Repositories/MissionRepository.swift @@ -24,14 +24,14 @@ public final class MissionRepository: MissionRepositoryProtocol { extension MissionRepository { - public func fetchMissonContentItem(missonId: String) -> Observable { + public func fetchMissonContentItem(missonId: String) -> Observable { return missionAPIWorker.fetchMissonContent(missonId: missonId) - .map { $0?.toDomain() } + .map { $0.toDomain() } } - public func fetchDailyMissonItem() -> Observable { + public func fetchDailyMissonItem() -> Observable { return missionAPIWorker.fetchDailyMisson() - .map { $0?.toDomain() } + .map { $0.toDomain() } } public func isAlreadyShowMissionAlert() -> Observable { diff --git a/14th-team5-iOS/Data/Sources/APIs/My/Repository/MyRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/MyRepository.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/My/Repository/MyRepository.swift rename to 14th-team5-iOS/Data/Sources/Repositories/MyRepository.swift diff --git a/14th-team5-iOS/Data/Sources/Repositories/PickRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/PickRepository.swift index 7f712f7f9..e0f3f1ebe 100644 --- a/14th-team5-iOS/Data/Sources/Repositories/PickRepository.swift +++ b/14th-team5-iOS/Data/Sources/Repositories/PickRepository.swift @@ -12,8 +12,8 @@ import RxSwift public final class PickRepository { - public let disposeBag: DisposeBag = DisposeBag() - private let membersAPIWorker: MembersWorker = MembersWorker() + private let disposeBag: DisposeBag = DisposeBag() + private let membersAPIWorker: MembersAPIWorker = MembersAPIWorker() public init() { } } diff --git a/14th-team5-iOS/Data/Sources/APIs/Post/Repository/PostRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/PostRepository.swift similarity index 57% rename from 14th-team5-iOS/Data/Sources/APIs/Post/Repository/PostRepository.swift rename to 14th-team5-iOS/Data/Sources/Repositories/PostRepository.swift index 290ed5884..8b7cccbab 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Post/Repository/PostRepository.swift +++ b/14th-team5-iOS/Data/Sources/Repositories/PostRepository.swift @@ -20,7 +20,9 @@ public final class PostRepository: PostListRepositoryProtocol { extension PostRepository { - public func fetchPostList(query: PostListQuery) -> Observable { + public func fetchPostList( + query: PostListQuery + ) -> Observable { let query = PostListQueryDTO( page: query.page, size: query.size, @@ -34,25 +36,41 @@ extension PostRepository { .map { $0?.toDomain() } } - public func fetchPostDetailItem(postId: String) -> Observable { + public func fetchPostDetailItem( + postId: String + ) -> Observable { return postAPIWorker.fetchPostDetail(postId: postId) .map { $0?.toDomain() } } - public func createPostItem(query: CreatePostQuery, body: CreatePostRequest) -> Observable { - let body = CreatePostRequestDTO(imageUrl: body.imageUrl, content: body.content, uploadTime: body.uploadTime) + public func createPostItem( + query: CreatePostQuery, + body: CreatePostRequest + ) -> Observable { + let body = CreatePostRequestDTO( + imageUrl: body.imageUrl, + content: body.content, + uploadTime: body.uploadTime + ) return postAPIWorker.createPost(query: query, body: body) .map { $0?.toDomain() } } - public func createPostPresignedURLItem(body: CreatePostPresignedURLRequest) -> Observable { - let body = CreatePostPresignedURLReqeustDTO(imageName: body.imageName) + public func createPostPresignedURLItem( + body: CreatePostPresignedURLRequest + ) -> Observable { + let body = CreatePostPresignedURLReqeustDTO( + imageName: body.imageName + ) return postAPIWorker.createPostPresignedURL(body: body) .map { $0?.toDomain() } } - public func uploadPostImageToS3Bucket(_ presignedURL: String, image: Data) -> Observable { + public func uploadPostImageToS3Bucket( + _ presignedURL: String, + image: Data + ) -> Observable { return postAPIWorker.updateS3PostImageUpload(presignedURL, image: image) } } diff --git a/14th-team5-iOS/Data/Sources/APIs/Privacy/Repository/PrivacyRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/PrivacyRepository.swift similarity index 100% rename from 14th-team5-iOS/Data/Sources/APIs/Privacy/Repository/PrivacyRepository.swift rename to 14th-team5-iOS/Data/Sources/Repositories/PrivacyRepository.swift diff --git a/14th-team5-iOS/Data/Sources/Repositories/RealEmojiRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/RealEmojiRepository.swift index b33a366e0..b812c7898 100644 --- a/14th-team5-iOS/Data/Sources/Repositories/RealEmojiRepository.swift +++ b/14th-team5-iOS/Data/Sources/Repositories/RealEmojiRepository.swift @@ -17,7 +17,7 @@ public final class RealEmojiRepository: RealEmojiRepositoryProtocol { private let myUserDefaults: MyUserDefaults = .init() private let postRealEmojiWorker: PostRealEmojiWorker = PostRealEmojiWorker() - private let memberRealEmojiWorker: MemberRealEmojiWorker = MemberRealEmojiWorker() + private let memberRealEmojiWorker: MemberRealEmojiAPIWorker = MemberRealEmojiAPIWorker() public init () { } diff --git a/14th-team5-iOS/Data/Sources/Repositories/ResignRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/ResignRepository.swift index 54b7c0dff..fe7f26d94 100644 --- a/14th-team5-iOS/Data/Sources/Repositories/ResignRepository.swift +++ b/14th-team5-iOS/Data/Sources/Repositories/ResignRepository.swift @@ -12,7 +12,7 @@ import RxSwift public final class ResignRepository { private let disposeBag: DisposeBag = DisposeBag() - private let membersAPIWorker: MembersWorker = MembersWorker() + private let membersAPIWorker: MembersAPIWorker = MembersAPIWorker() public init() { } } diff --git a/14th-team5-iOS/Data/Sources/APIs/Widget/Repository/WidgetRepository.swift b/14th-team5-iOS/Data/Sources/Repositories/WidgetRepository.swift similarity index 84% rename from 14th-team5-iOS/Data/Sources/APIs/Widget/Repository/WidgetRepository.swift rename to 14th-team5-iOS/Data/Sources/Repositories/WidgetRepository.swift index 75dd5ebce..2dd65ca99 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Widget/Repository/WidgetRepository.swift +++ b/14th-team5-iOS/Data/Sources/Repositories/WidgetRepository.swift @@ -13,13 +13,14 @@ import RxSwift public final class WidgetRepository: WidgetRepositoryProtocol { - public let disposeBag: DisposeBag = DisposeBag() + private let disposeBag: DisposeBag = DisposeBag() private let widgetAPIWorker: WidgetAPIWorker = WidgetAPIWorker() public init () { } - public func fetchRecentFamilyPost(completion: @escaping (Result) -> Void) { + public func fetchRecentFamilyPost(completion: @escaping (Result) -> Void) { widgetAPIWorker.fetchRecentFamilyPost() + .map { $0.toDomain() } .subscribe( onNext: { result in completion(.success(result)) diff --git a/14th-team5-iOS/Data/Sources/Trash/Account/AccountRepository/AccountRepository.swift b/14th-team5-iOS/Data/Sources/Trash/Account/AccountRepository/AccountRepository.swift index 37a8bed5f..3fbf36d3d 100644 --- a/14th-team5-iOS/Data/Sources/Trash/Account/AccountRepository/AccountRepository.swift +++ b/14th-team5-iOS/Data/Sources/Trash/Account/AccountRepository/AccountRepository.swift @@ -34,7 +34,7 @@ public final class AccountRepository: AccountImpl { let signInHelper = AccountSignInHelper() private let apiWorker = AccountAPIWorker() - private let profileWorker = MembersWorker() + private let profileWorker = MembersAPIWorker() private let meApiWorekr = MeAPIWorker() private let fetchMemberInfo = PublishRelay() diff --git a/14th-team5-iOS/Data/Sources/Trash/Account/MeAPI/MeAPIWorker.swift b/14th-team5-iOS/Data/Sources/Trash/Account/MeAPI/MeAPIWorker.swift index 5afa38b23..49c5085d6 100644 --- a/14th-team5-iOS/Data/Sources/Trash/Account/MeAPI/MeAPIWorker.swift +++ b/14th-team5-iOS/Data/Sources/Trash/Account/MeAPI/MeAPIWorker.swift @@ -31,6 +31,7 @@ extension MeAPIs { } extension MeAPIWorker: MeRepositoryProtocol, JoinFamilyRepository, FCMRepositoryProtocol { + private func saveFcmToken(headers: [APIHeader]?, token: FCMToken) -> Single { let spec = MeAPIs.saveFcmToken.spec diff --git a/14th-team5-iOS/Domain/Sources/Entities/Widget/RecentFamilyPostEntity.swift b/14th-team5-iOS/Domain/Sources/Entities/Widget/WidgetPostEntity.swift similarity index 93% rename from 14th-team5-iOS/Domain/Sources/Entities/Widget/RecentFamilyPostEntity.swift rename to 14th-team5-iOS/Domain/Sources/Entities/Widget/WidgetPostEntity.swift index 41ad38079..33afacc66 100644 --- a/14th-team5-iOS/Domain/Sources/Entities/Widget/RecentFamilyPostEntity.swift +++ b/14th-team5-iOS/Domain/Sources/Entities/Widget/WidgetPostEntity.swift @@ -7,7 +7,7 @@ import Foundation -public struct RecentFamilyPostEntity: Codable { +public struct WidgetPostEntity: Codable { public var authorName: String public var authorProfileImageUrl: String? public var postId: String? diff --git a/14th-team5-iOS/Domain/Sources/Repositories/AppRepository.swift b/14th-team5-iOS/Domain/Sources/Repositories/AppRepository.swift index 85d11b1f4..97b1526dd 100644 --- a/14th-team5-iOS/Domain/Sources/Repositories/AppRepository.swift +++ b/14th-team5-iOS/Domain/Sources/Repositories/AppRepository.swift @@ -10,7 +10,7 @@ import Foundation import RxSwift public protocol AppRepositoryProtocol { - func fetchAppVersion() -> Observable + func fetchAppVersion() -> Observable func loadIsFirstFamilyManagement() -> Observable func saveIsFirstFamilyManagement(isFirst: Bool) -> Void diff --git a/14th-team5-iOS/Domain/Sources/Repositories/MainViewRepository.swift b/14th-team5-iOS/Domain/Sources/Repositories/MainViewRepository.swift index 06f5a37bd..29f042a35 100644 --- a/14th-team5-iOS/Domain/Sources/Repositories/MainViewRepository.swift +++ b/14th-team5-iOS/Domain/Sources/Repositories/MainViewRepository.swift @@ -10,6 +10,6 @@ import Foundation import RxSwift public protocol MainViewRepositoryProtocol { - func fetchMain() -> Observable - func fetchMainNight() -> Observable + func fetchMain() -> Observable + func fetchMainNight() -> Observable } diff --git a/14th-team5-iOS/Domain/Sources/Repositories/MissonRepository.swift b/14th-team5-iOS/Domain/Sources/Repositories/MissonRepository.swift index a62ce0e31..0c0202a56 100644 --- a/14th-team5-iOS/Domain/Sources/Repositories/MissonRepository.swift +++ b/14th-team5-iOS/Domain/Sources/Repositories/MissonRepository.swift @@ -13,8 +13,8 @@ import RxSwift public protocol MissionRepositoryProtocol { /// FETCH - func fetchMissonContentItem(missonId: String) -> Observable - func fetchDailyMissonItem() -> Observable + func fetchMissonContentItem(missonId: String) -> Observable + func fetchDailyMissonItem() -> Observable /// LOCAL DB func isAlreadyShowMissionAlert() -> Observable diff --git a/14th-team5-iOS/Domain/Sources/Repositories/OAuthRepository.swift b/14th-team5-iOS/Domain/Sources/Repositories/OAuthRepository.swift index a4e39f66f..71a02bba8 100644 --- a/14th-team5-iOS/Domain/Sources/Repositories/OAuthRepository.swift +++ b/14th-team5-iOS/Domain/Sources/Repositories/OAuthRepository.swift @@ -10,9 +10,9 @@ import Foundation import RxSwift public protocol OAuthRepositoryProtocol { - func refreshAccessToken(body: RefreshAccessTokenRequest) -> Observable - func registerNewMember(body: CreateNewMemberRequest) -> Observable - func signIn(_ type: SignInType, body: NativeSocialLoginRequest) -> Observable - func registerNewFCMToken(body: AddFCMTokenRequest) -> Observable - func deleteFCMToken() -> Observable + func refreshAccessToken(body: RefreshAccessTokenRequest) -> Observable + func registerNewMember(body: CreateNewMemberRequest) -> Observable + func signIn(_ type: SignInType, body: NativeSocialLoginRequest) -> Observable + func registerNewFCMToken(body: AddFCMTokenRequest) -> Observable + func deleteFCMToken() -> Observable } diff --git a/14th-team5-iOS/Domain/Sources/Repositories/WidgetRepository.swift b/14th-team5-iOS/Domain/Sources/Repositories/WidgetRepository.swift index 9cd7f9ffa..cfdf7f2e3 100644 --- a/14th-team5-iOS/Domain/Sources/Repositories/WidgetRepository.swift +++ b/14th-team5-iOS/Domain/Sources/Repositories/WidgetRepository.swift @@ -8,5 +8,5 @@ import Foundation public protocol WidgetRepositoryProtocol { - func fetchRecentFamilyPost(completion: @escaping (Result) -> Void) + func fetchRecentFamilyPost(completion: @escaping (Result) -> Void) } diff --git a/14th-team5-iOS/Domain/Sources/UseCases/App/FetchAppVersionUseCase.swift b/14th-team5-iOS/Domain/Sources/UseCases/App/FetchAppVersionUseCase.swift index a0c89d1ff..f971868ec 100644 --- a/14th-team5-iOS/Domain/Sources/UseCases/App/FetchAppVersionUseCase.swift +++ b/14th-team5-iOS/Domain/Sources/UseCases/App/FetchAppVersionUseCase.swift @@ -10,7 +10,7 @@ import Foundation import RxSwift public protocol FetchAppVersionUseCaseProtocol { - func execute() -> Observable + func execute() -> Observable } public class FetchAppVersionUseCase: FetchAppVersionUseCaseProtocol { @@ -25,7 +25,7 @@ public class FetchAppVersionUseCase: FetchAppVersionUseCaseProtocol { // MARK: - Execute - public func execute() -> Observable { + public func execute() -> Observable { appRepository.fetchAppVersion() } diff --git a/14th-team5-iOS/Domain/Sources/UseCases/MainView/FetchMainUseCase.swift b/14th-team5-iOS/Domain/Sources/UseCases/MainView/FetchMainUseCase.swift index 3e881c69a..b0fa03609 100644 --- a/14th-team5-iOS/Domain/Sources/UseCases/MainView/FetchMainUseCase.swift +++ b/14th-team5-iOS/Domain/Sources/UseCases/MainView/FetchMainUseCase.swift @@ -10,7 +10,7 @@ import Foundation import RxSwift public protocol FetchMainUseCaseProtocol { - func execute() -> Observable + func execute() -> Observable } public final class FetchMainUseCase: FetchMainUseCaseProtocol { @@ -20,7 +20,7 @@ public final class FetchMainUseCase: FetchMainUseCaseProtocol { self.mainRepository = mainRepository } - public func execute() -> Observable { + public func execute() -> Observable { return mainRepository.fetchMain() } } diff --git a/14th-team5-iOS/Domain/Sources/UseCases/MainView/FetchNightMainViewUsecase.swift b/14th-team5-iOS/Domain/Sources/UseCases/MainView/FetchNightMainViewUsecase.swift index 2ed78b6d8..ce51d8594 100644 --- a/14th-team5-iOS/Domain/Sources/UseCases/MainView/FetchNightMainViewUsecase.swift +++ b/14th-team5-iOS/Domain/Sources/UseCases/MainView/FetchNightMainViewUsecase.swift @@ -10,7 +10,7 @@ import Foundation import RxSwift public protocol FetchNightMainViewUseCaseProtocol { - func execute() -> Observable + func execute() -> Observable } public final class FetchNightMainViewUseCase: FetchNightMainViewUseCaseProtocol { @@ -20,7 +20,7 @@ public final class FetchNightMainViewUseCase: FetchNightMainViewUseCaseProtocol self.mainRepository = mainRepository } - public func execute() -> Observable { + public func execute() -> Observable { return mainRepository.fetchMainNight() } } diff --git a/14th-team5-iOS/Domain/Sources/UseCases/Misson/FetchDailyMissonContentUseCase.swift b/14th-team5-iOS/Domain/Sources/UseCases/Misson/FetchDailyMissonContentUseCase.swift index 70968dbe4..e38c2ae13 100644 --- a/14th-team5-iOS/Domain/Sources/UseCases/Misson/FetchDailyMissonContentUseCase.swift +++ b/14th-team5-iOS/Domain/Sources/UseCases/Misson/FetchDailyMissonContentUseCase.swift @@ -11,7 +11,7 @@ import RxSwift public protocol FetchDailyMissonContentUseCaseProtocol { - func execute() -> Observable + func execute() -> Observable } public final class FetchDailyMissonContentUseCase: FetchDailyMissonContentUseCaseProtocol { @@ -22,7 +22,7 @@ public final class FetchDailyMissonContentUseCase: FetchDailyMissonContentUseCas self.missionRepository = missionRepository } - public func execute() -> Observable { + public func execute() -> Observable { return missionRepository.fetchDailyMissonItem() } } diff --git a/14th-team5-iOS/Domain/Sources/UseCases/Misson/FetchMissionContentUseCase.swift b/14th-team5-iOS/Domain/Sources/UseCases/Misson/FetchMissionContentUseCase.swift index 670a33f9e..6cb3f40b0 100644 --- a/14th-team5-iOS/Domain/Sources/UseCases/Misson/FetchMissionContentUseCase.swift +++ b/14th-team5-iOS/Domain/Sources/UseCases/Misson/FetchMissionContentUseCase.swift @@ -12,7 +12,7 @@ import RxCocoa public protocol FetchMissionContentUseCaseProtocol { - func execute(missionId: String) -> Observable + func execute(missionId: String) -> Observable } public final class FetchMissionContentUseCase: FetchMissionContentUseCaseProtocol { @@ -22,7 +22,7 @@ public final class FetchMissionContentUseCase: FetchMissionContentUseCaseProtoco self.missionRepository = missionRepository } - public func execute(missionId: String) -> Observable { + public func execute(missionId: String) -> Observable { return missionRepository.fetchMissonContentItem(missonId: missionId) } diff --git a/14th-team5-iOS/Domain/Sources/UseCases/OAuth/DeleteFCMTokenUseCase.swift b/14th-team5-iOS/Domain/Sources/UseCases/OAuth/DeleteFCMTokenUseCase.swift index c92be7b0a..054d8ffa7 100644 --- a/14th-team5-iOS/Domain/Sources/UseCases/OAuth/DeleteFCMTokenUseCase.swift +++ b/14th-team5-iOS/Domain/Sources/UseCases/OAuth/DeleteFCMTokenUseCase.swift @@ -10,7 +10,7 @@ import Foundation import RxSwift public protocol DeleteFCMTokenUseCaseProtocol { - func execute() -> Observable + func execute() -> Observable } public class DeleteFCMTokenUseCase: DeleteFCMTokenUseCaseProtocol { @@ -24,7 +24,7 @@ public class DeleteFCMTokenUseCase: DeleteFCMTokenUseCaseProtocol { } // MARK: - Execute - public func execute() -> Observable { + public func execute() -> Observable { return oauthRepository.deleteFCMToken() } } diff --git a/14th-team5-iOS/Domain/Sources/UseCases/OAuth/RefreshAccessTokenUseCase.swift b/14th-team5-iOS/Domain/Sources/UseCases/OAuth/RefreshAccessTokenUseCase.swift index 9c0a65d76..7754843bc 100644 --- a/14th-team5-iOS/Domain/Sources/UseCases/OAuth/RefreshAccessTokenUseCase.swift +++ b/14th-team5-iOS/Domain/Sources/UseCases/OAuth/RefreshAccessTokenUseCase.swift @@ -10,7 +10,7 @@ import Foundation import RxSwift public protocol RefreshAccessTokenUseCaseProtocol { - func execute(body: RefreshAccessTokenRequest) -> Observable + func execute(body: RefreshAccessTokenRequest) -> Observable } public final class RefreshAccessTokenUseCase: RefreshAccessTokenUseCaseProtocol { @@ -24,7 +24,7 @@ public final class RefreshAccessTokenUseCase: RefreshAccessTokenUseCaseProtocol } // MARK: - Execute - public func execute(body: RefreshAccessTokenRequest) -> Observable { + public func execute(body: RefreshAccessTokenRequest) -> Observable { return oauthRepository.refreshAccessToken(body: body) } } diff --git a/14th-team5-iOS/Domain/Sources/UseCases/OAuth/RegisterNewFCMTokenUseCase.swift b/14th-team5-iOS/Domain/Sources/UseCases/OAuth/RegisterNewFCMTokenUseCase.swift index eff633b07..b424c9b0e 100644 --- a/14th-team5-iOS/Domain/Sources/UseCases/OAuth/RegisterNewFCMTokenUseCase.swift +++ b/14th-team5-iOS/Domain/Sources/UseCases/OAuth/RegisterNewFCMTokenUseCase.swift @@ -10,7 +10,7 @@ import Foundation import RxSwift public protocol RegisterNewFCMTokenUseCaseProtocol { - func execute(body: AddFCMTokenRequest) -> Observable + func execute(body: AddFCMTokenRequest) -> Observable } public class RegisterNewFCMTokenUseCase: RegisterNewFCMTokenUseCaseProtocol { @@ -24,7 +24,7 @@ public class RegisterNewFCMTokenUseCase: RegisterNewFCMTokenUseCaseProtocol { } // MARK: - Execute - public func execute(body: AddFCMTokenRequest) -> Observable { + public func execute(body: AddFCMTokenRequest) -> Observable { return oauthRepository.registerNewFCMToken(body: body) } } diff --git a/14th-team5-iOS/Domain/Sources/UseCases/OAuth/RegisterNewMemberUseCase.swift b/14th-team5-iOS/Domain/Sources/UseCases/OAuth/RegisterNewMemberUseCase.swift index 567c1aed1..440d33e4d 100644 --- a/14th-team5-iOS/Domain/Sources/UseCases/OAuth/RegisterNewMemberUseCase.swift +++ b/14th-team5-iOS/Domain/Sources/UseCases/OAuth/RegisterNewMemberUseCase.swift @@ -10,7 +10,7 @@ import Foundation import RxSwift public protocol RegisterNewMemberUseCaseProtocol { - func execute(body: CreateNewMemberRequest) -> Observable + func execute(body: CreateNewMemberRequest) -> Observable } public class RegisterNewMemberUseCase: RegisterNewMemberUseCaseProtocol { @@ -24,7 +24,7 @@ public class RegisterNewMemberUseCase: RegisterNewMemberUseCaseProtocol { } // MARK: - Execute - public func execute(body: CreateNewMemberRequest) -> Observable { + public func execute(body: CreateNewMemberRequest) -> Observable { return oauthRepository.registerNewMember(body: body) } } diff --git a/14th-team5-iOS/Domain/Sources/UseCases/OAuth/SignInUseCase.swift b/14th-team5-iOS/Domain/Sources/UseCases/OAuth/SignInUseCase.swift index c867945e3..8d89132b0 100644 --- a/14th-team5-iOS/Domain/Sources/UseCases/OAuth/SignInUseCase.swift +++ b/14th-team5-iOS/Domain/Sources/UseCases/OAuth/SignInUseCase.swift @@ -10,7 +10,7 @@ import Foundation import RxSwift public protocol SignInUseCaseProtocol { - func execute(_ type: SignInType, body: NativeSocialLoginRequest) -> Observable + func execute(_ type: SignInType, body: NativeSocialLoginRequest) -> Observable } public class SignInUseCase: SignInUseCaseProtocol { @@ -27,7 +27,7 @@ public class SignInUseCase: SignInUseCaseProtocol { public func execute( _ type: SignInType, body: NativeSocialLoginRequest - ) -> Observable { + ) -> Observable { return oauthRepository.signIn(type, body: body) } } diff --git a/14th-team5-iOS/Domain/Sources/UseCases/Widget/FetchRecentFamilyPostUseCase.swift b/14th-team5-iOS/Domain/Sources/UseCases/Widget/FetchRecentFamilyPostUseCase.swift index 1d0507363..72764af8a 100644 --- a/14th-team5-iOS/Domain/Sources/UseCases/Widget/FetchRecentFamilyPostUseCase.swift +++ b/14th-team5-iOS/Domain/Sources/UseCases/Widget/FetchRecentFamilyPostUseCase.swift @@ -8,7 +8,7 @@ import Foundation public protocol FetchRecentFamilyPostUseCaseProtocol { - func excute(completion: @escaping (Result) -> Void) + func excute(completion: @escaping (Result) -> Void) } public class FetchRecentFamilyPostUseCase: FetchRecentFamilyPostUseCaseProtocol { @@ -18,7 +18,7 @@ public class FetchRecentFamilyPostUseCase: FetchRecentFamilyPostUseCaseProtocol self.widgetRepository = widgetRepository } - public func excute(completion: @escaping (Result) -> Void) { + public func excute(completion: @escaping (Result) -> Void) { return widgetRepository.fetchRecentFamilyPost(completion: completion) } } diff --git a/Bibbi.xcworkspace/contents.xcworkspacedata b/Bibbi.xcworkspace/contents.xcworkspacedata index 7e570dad8..7bb900224 100644 --- a/Bibbi.xcworkspace/contents.xcworkspacedata +++ b/Bibbi.xcworkspace/contents.xcworkspacedata @@ -26,6 +26,9 @@ + + @@ -35,6 +38,9 @@ + + @@ -44,6 +50,9 @@ + + @@ -77,15 +86,27 @@ + + + + + + + + diff --git a/Bibbi.xcworkspace/xcshareddata/xcschemes/Bibbi-Workspace.xcscheme b/Bibbi.xcworkspace/xcshareddata/xcschemes/Bibbi-Workspace.xcscheme index 5fd01fa86..1781b4e89 100644 --- a/Bibbi.xcworkspace/xcshareddata/xcschemes/Bibbi-Workspace.xcscheme +++ b/Bibbi.xcworkspace/xcshareddata/xcschemes/Bibbi-Workspace.xcscheme @@ -20,20 +20,6 @@ ReferencedContainer = "container:Tuist/.build/tuist-derived/Alamofire/Alamofire.xcodeproj"> - - - - @@ -574,9 +560,9 @@ buildForAnalyzing = "YES"> @@ -588,9 +574,9 @@ buildForAnalyzing = "YES"> @@ -602,9 +588,9 @@ buildForAnalyzing = "YES"> @@ -616,9 +602,9 @@ buildForAnalyzing = "YES"> @@ -630,9 +616,9 @@ buildForAnalyzing = "YES"> @@ -644,9 +630,9 @@ buildForAnalyzing = "YES"> @@ -658,9 +644,9 @@ buildForAnalyzing = "YES"> @@ -1154,20 +1140,6 @@ ReferencedContainer = "container:Tuist/.build/tuist-derived/SnapKit/SnapKit.xcodeproj"> - - - - Date: Mon, 16 Dec 2024 20:22:12 +0900 Subject: [PATCH 2/3] fix the query url --- .../Privacy/Reactor/PrivacyViewReactor.swift | 18 ++++++++++-------- .../Privacy/View/BibbiInquireBannerView.swift | 14 -------------- .../Data/Sources/APIs/Family/FamilyAPIs.swift | 16 +++++++++++++--- .../FamilyInviteViewAPIs.swift | 5 ++++- .../Data/Sources/APIs/Link/LinkAPIs.swift | 5 ++++- .../Data/Sources/APIs/Me/MeAPI.swift | 4 +++- 6 files changed, 34 insertions(+), 28 deletions(-) diff --git a/14th-team5-iOS/App/Sources/Presentation/Privacy/Reactor/PrivacyViewReactor.swift b/14th-team5-iOS/App/Sources/Presentation/Privacy/Reactor/PrivacyViewReactor.swift index 5294fbef9..b49e66237 100644 --- a/14th-team5-iOS/App/Sources/Presentation/Privacy/Reactor/PrivacyViewReactor.swift +++ b/14th-team5-iOS/App/Sources/Presentation/Privacy/Reactor/PrivacyViewReactor.swift @@ -12,8 +12,6 @@ import Domain import Data import ReactorKit - - public final class PrivacyViewReactor: Reactor { public var initialState: State @Injected var fetchAppVersionUseCase: FetchAppVersionUseCaseProtocol @@ -70,16 +68,20 @@ public final class PrivacyViewReactor: Reactor { .just(.setLoading(true)), .merge( fetchAppVersionUseCase.execute() - .asObservable() .withUnretained(self) .flatMap { owner, appVersionEntity -> Observable in - owner.fetchPrivacyItemsUseCase.execute() - .asObservable() + return owner.fetchPrivacyItemsUseCase.execute() .flatMap { privateInfo -> Observable in var sectionItem: [PrivacyItemModel] = [] privateInfo.forEach { - sectionItem.append(.privacyWithAuthItem(PrivacyCellReactor(descrption: $0, isCheck: appVersionEntity.latest))) - + sectionItem.append( + .privacyWithAuthItem( + PrivacyCellReactor( + descrption: $0, + isCheck: appVersionEntity.latest + ) + ) + ) } return .concat( @@ -87,7 +89,7 @@ public final class PrivacyViewReactor: Reactor { .just(.setBibbiAppInfo(appVersionEntity)) ) } - + }, fetchAuthorizationItemUseCase.execute() diff --git a/14th-team5-iOS/App/Sources/Presentation/Privacy/View/BibbiInquireBannerView.swift b/14th-team5-iOS/App/Sources/Presentation/Privacy/View/BibbiInquireBannerView.swift index feef9bc16..05297fe79 100644 --- a/14th-team5-iOS/App/Sources/Presentation/Privacy/View/BibbiInquireBannerView.swift +++ b/14th-team5-iOS/App/Sources/Presentation/Privacy/View/BibbiInquireBannerView.swift @@ -13,8 +13,6 @@ import SnapKit import Then final class BibbiInquireBannerView: UIView { - - private let mainLogoView: UIImageView = UIImageView() private let subLogoView: UIImageView = UIImageView() private let descrptionLabel: UILabel = BBLabel(.body1Bold, textAlignment: .left) @@ -27,7 +25,6 @@ final class BibbiInquireBannerView: UIView { setupUI() setupAttributes() setupAutoLayout() - print("Device Size: \(UIScreen.main.bounds.size.width)") } required init?(coder: NSCoder) { @@ -38,8 +35,6 @@ final class BibbiInquireBannerView: UIView { addSubviews(mainLogoView, subLogoView, arrowImageView, descrptionLabel, subtitleLabel) } - - private func setupAttributes() { mainLogoView.do { @@ -68,10 +63,6 @@ final class BibbiInquireBannerView: UIView { $0.text = "의견 남기러 가기" $0.textColor = .blue500 } - - - - } @@ -107,12 +98,7 @@ final class BibbiInquireBannerView: UIView { $0.width.height.equalTo(11) $0.centerY.equalTo(subtitleLabel) } - - - } - - } diff --git a/14th-team5-iOS/Data/Sources/APIs/Family/FamilyAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/Family/FamilyAPIs.swift index 38c8162ca..4eea1bf65 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Family/FamilyAPIs.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Family/FamilyAPIs.swift @@ -18,11 +18,21 @@ enum FamilyAPIs: BBAPI { var spec: Spec { switch self { case .createFamily: - return .init(method: .post, path: "/families") + return .init( + method: .post, + path: "/families" + ) case .fetchFamilyCreatedAt(let familyId): - return .init(method: .get, path: "/families/\(familyId)/created-at") + return .init( + method: .get, + path: "/families/\(familyId)/created-at" + ) case .updateFamilyName(let familyId, let body): - return .init(method: .put, path: "/families/\(familyId)/name", bodyParametersEncodable: body) + return .init( + method: .put, + path: "/families/\(familyId)/name", + bodyParametersEncodable: body + ) } } diff --git a/14th-team5-iOS/Data/Sources/APIs/FamilyInviteView/FamilyInviteViewAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/FamilyInviteView/FamilyInviteViewAPIs.swift index c8517deed..87a384065 100644 --- a/14th-team5-iOS/Data/Sources/APIs/FamilyInviteView/FamilyInviteViewAPIs.swift +++ b/14th-team5-iOS/Data/Sources/APIs/FamilyInviteView/FamilyInviteViewAPIs.swift @@ -16,7 +16,10 @@ enum FamilyInviteViewAPIs: BBAPI { var spec: Spec { switch self { case .fetchFamilyInfoWithLink(let linkId): - return .init(method: .get, path: "/view/family-invite/\(linkId)") + return .init( + method: .get, + path: "/view/family-invite/\(linkId)" + ) } } diff --git a/14th-team5-iOS/Data/Sources/APIs/Link/LinkAPIs.swift b/14th-team5-iOS/Data/Sources/APIs/Link/LinkAPIs.swift index fe9164870..2cc69f518 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Link/LinkAPIs.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Link/LinkAPIs.swift @@ -14,7 +14,10 @@ enum LinkAPIs: BBAPI { var spec: Spec { switch self { case let .createFamilyLink(familyId): - return .init(method: .post, path: "/links/family/\(familyId)") + return .init( + method: .post, + path: "/links/family/\(familyId)" + ) } } diff --git a/14th-team5-iOS/Data/Sources/APIs/Me/MeAPI.swift b/14th-team5-iOS/Data/Sources/APIs/Me/MeAPI.swift index 8f8eea620..609643226 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Me/MeAPI.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Me/MeAPI.swift @@ -60,7 +60,9 @@ enum MeAPI: BBAPI { return .init( method: .get, path: "/me/app-version", - queryParametersEncodable: version + queryParameters: [ + "appKey": "\(version)" + ] ) } } From 806933e49cd8fd267fc0e5f6a490233923c7991b Mon Sep 17 00:00:00 2001 From: Kyoungmi <1mmgm.dev@gmail.com> Date: Tue, 17 Dec 2024 00:34:35 +0900 Subject: [PATCH 3/3] fix: miss body --- .../Presentation/Profile/ProfileViewController.swift | 9 +++++---- 14th-team5-iOS/Data/Sources/APIs/Me/MeAPI.swift | 9 +++++---- 14th-team5-iOS/Data/Sources/APIs/Me/MeeAPIWorker.swift | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/14th-team5-iOS/App/Sources/Presentation/Profile/ProfileViewController.swift b/14th-team5-iOS/App/Sources/Presentation/Profile/ProfileViewController.swift index d7e1bb4f4..a37b1af05 100644 --- a/14th-team5-iOS/App/Sources/Presentation/Profile/ProfileViewController.swift +++ b/14th-team5-iOS/App/Sources/Presentation/Profile/ProfileViewController.swift @@ -263,7 +263,7 @@ public final class ProfileViewController: BaseViewController } // 기본 이미지가 true 이고 닉네임 변경 할 경우 redraw -extension ProfileViewController { +extension ProfileViewController { private func setupProfileImage(url: URL) { let processor = DownsamplingImageProcessor(size: profileView.bounds.size) @@ -324,10 +324,11 @@ extension ProfileViewController: PHPickerViewControllerDelegate { picker.dismiss(animated: true, completion: nil) if let imageProvider = itemProvider, imageProvider.canLoadObject(ofClass: UIImage.self) { - imageProvider.loadObject(ofClass: UIImage.self) { image, error in - guard let photoImage: UIImage = image as? UIImage, + imageProvider.loadObject(ofClass: UIImage.self) { [weak self] image, error in + guard let self = self, + let photoImage: UIImage = image as? UIImage, let originalData: Data = photoImage.jpegData(compressionQuality: 1.0) else { return } - imageProvider.didSelectProfileImageWithProcessing(photo: originalData, error: error) + self.reactor?.action.onNext(.didSelectPHAssetsImage(originalData)) } } diff --git a/14th-team5-iOS/Data/Sources/APIs/Me/MeAPI.swift b/14th-team5-iOS/Data/Sources/APIs/Me/MeAPI.swift index 609643226..f73c83245 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Me/MeAPI.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Me/MeAPI.swift @@ -10,7 +10,7 @@ import Core // TODO: MeAPIs로 이름 바꾸기 - Trash 지워야 함 enum MeAPI: BBAPI { /// 가족 가입하기 - case joinFamily + case joinFamily(_ body: JoinFamilyRequestDTO) /// 가족 탈퇴하기 case resignFamily /// 가족 생성 및 가족 정보 조회 @@ -26,13 +26,14 @@ enum MeAPI: BBAPI { var spec: Spec { switch self { - case .joinFamily: + case let .joinFamily(body): return .init( method: .post, - path: "/me/join-family" + path: "/me/join-family", + bodyParametersEncodable: body ) case .resignFamily: - return .init( + return .init( method: .post, path: "/me/quit-family" ) diff --git a/14th-team5-iOS/Data/Sources/APIs/Me/MeeAPIWorker.swift b/14th-team5-iOS/Data/Sources/APIs/Me/MeeAPIWorker.swift index f6391149c..aef734692 100644 --- a/14th-team5-iOS/Data/Sources/APIs/Me/MeeAPIWorker.swift +++ b/14th-team5-iOS/Data/Sources/APIs/Me/MeeAPIWorker.swift @@ -37,7 +37,7 @@ extension MeeAPIWorker { func joinFamily( body: JoinFamilyRequestDTO ) -> Observable { - let spec = MeAPI.joinFamily.spec + let spec = MeAPI.joinFamily(body).spec return request(spec) }