From cf77edf11359c67efccd7492e6ed65c422bcd0d5 Mon Sep 17 00:00:00 2001 From: jeongdung-eo Date: Thu, 14 Mar 2024 14:06:37 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20#245=20-=20API=20&=20Service=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iOS-NOTTODO.xcodeproj/project.pbxproj | 74 ++++++------ .../Network/API/Auth/AuthAPI.swift | 81 ------------- .../Network/API/AuthAPI/AuthAPI.swift | 78 +++++++++++++ .../MissionAPI.swift} | 6 +- .../Network/API/Recommend/RecommendAPI.swift | 88 +++++--------- .../Network/Service/Auth/AuthService.swift | 107 +++++++++--------- .../Network/{API => Service}/BaseAPI.swift | 4 +- .../Mission/MissionService.swift} | 10 +- .../Service/Recommend/RecommendService.swift | 88 +++++++++----- .../AchievementViewController.swift | 2 +- .../DetailAchievementViewController.swift | 2 +- .../Cells/NottodoCollectionViewCell.swift | 2 +- .../Cells/SituationCollectionViewCell.swift | 2 +- .../AddMissionViewController.swift | 8 +- .../Auth/AuthViewController.swift | 4 +- .../Modal/NottodoModalViewController.swift | 2 +- .../DetailCalendarViewController.swift | 4 +- .../ViewControllers/HomeViewController.swift | 8 +- .../MissionDetailViewController.swift | 4 +- .../MyInfoAccountViewController.swift | 2 +- .../RecommendViewController.swift | 2 +- .../RecommendActionViewController.swift | 2 +- 22 files changed, 289 insertions(+), 291 deletions(-) delete mode 100644 iOS-NOTTODO/iOS-NOTTODO/Network/API/Auth/AuthAPI.swift create mode 100644 iOS-NOTTODO/iOS-NOTTODO/Network/API/AuthAPI/AuthAPI.swift rename iOS-NOTTODO/iOS-NOTTODO/Network/{Service/MissionService.swift => API/MissionAPI.swift} (97%) rename iOS-NOTTODO/iOS-NOTTODO/Network/{API => Service}/BaseAPI.swift (95%) rename iOS-NOTTODO/iOS-NOTTODO/Network/{API/Mission/MissionAPI.swift => Service/Mission/MissionService.swift} (96%) diff --git a/iOS-NOTTODO/iOS-NOTTODO.xcodeproj/project.pbxproj b/iOS-NOTTODO/iOS-NOTTODO.xcodeproj/project.pbxproj index 97e0f111..2c8cc1ae 100644 --- a/iOS-NOTTODO/iOS-NOTTODO.xcodeproj/project.pbxproj +++ b/iOS-NOTTODO/iOS-NOTTODO.xcodeproj/project.pbxproj @@ -34,7 +34,7 @@ 0982DE5429ADCCE000D933D2 /* HomeEmptyCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0982DE5329ADCCE000D933D2 /* HomeEmptyCollectionViewCell.swift */; }; 0982DE5829AE40FB00D933D2 /* UITabBar+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0982DE5729AE40FB00D933D2 /* UITabBar+.swift */; }; 0982DE5A29AE5E6000D933D2 /* CompositionalLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0982DE5929AE5E6000D933D2 /* CompositionalLayout.swift */; }; - 0987C8402B9DD4DC007EE8DE /* MissionService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0987C83F2B9DD242007EE8DE /* MissionService.swift */; }; + 0987C8402B9DD4DC007EE8DE /* MissionAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0987C83F2B9DD242007EE8DE /* MissionAPI.swift */; }; 098904292B81AF3E004AAD3C /* API_KEY.plist in Resources */ = {isa = PBXBuildFile; fileRef = 098904282B81AF3E004AAD3C /* API_KEY.plist */; }; 098904302B81BB3A004AAD3C /* Coordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0989042F2B81BB3A004AAD3C /* Coordinator.swift */; }; 098904322B81BB43004AAD3C /* CoordinatorDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 098904312B81BB43004AAD3C /* CoordinatorDelegate.swift */; }; @@ -62,13 +62,12 @@ 099FC98929B3233D005B37E6 /* CalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 099FC98829B3233D005B37E6 /* CalendarView.swift */; }; 09A1465F2A192C4900DDC308 /* WeekMissionResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A1465E2A192C4900DDC308 /* WeekMissionResponseDTO.swift */; }; 09A146652A1964B500DDC308 /* AddAnotherDayResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A146642A19649A00DDC308 /* AddAnotherDayResponseDTO.swift */; }; - 09A8E48C2B9DBE5C00C0F48F /* API_KEY.plist in Resources */ = {isa = PBXBuildFile; fileRef = 09A8E48B2B9DBE5C00C0F48F /* API_KEY.plist */; }; 09A8E48E2B9DBEC700C0F48F /* BaseAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09A8E48D2B9DBEC700C0F48F /* BaseAPI.swift */; }; 09C8602D2AB14B4800C4F4B1 /* FSCalendar in Frameworks */ = {isa = PBXBuildFile; productRef = 09C8602C2AB14B4800C4F4B1 /* FSCalendar */; }; 09CF56022B09E98A00526C8C /* DetailAchieveHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CF56012B09E98A00526C8C /* DetailAchieveHeaderView.swift */; }; 09CF56042B09F23800526C8C /* HomeDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CF56032B09F23800526C8C /* HomeDataSource.swift */; }; 09DCCD1F2A18ED76003DCF8A /* DailyMissionResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09DCCD1E2A18ED76003DCF8A /* DailyMissionResponseDTO.swift */; }; - 09DCCD232A18EFB0003DCF8A /* MissionAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09DCCD222A18EFB0003DCF8A /* MissionAPI.swift */; }; + 09DCCD232A18EFB0003DCF8A /* MissionService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09DCCD222A18EFB0003DCF8A /* MissionService.swift */; }; 09ED941B2B2ABAB7001864EF /* CommonNotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09ED941A2B2ABAB7001864EF /* CommonNotificationViewController.swift */; }; 09F6718029CAD76C00708725 /* SecondOnboardingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09F6717F29CAD76C00708725 /* SecondOnboardingViewController.swift */; }; 09F6718229CAD86100708725 /* OnboardingCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09F6718129CAD86100708725 /* OnboardingCollectionViewCell.swift */; }; @@ -161,14 +160,14 @@ 6C44128129A35A1000313C3F /* KakaoSDKUser in Frameworks */ = {isa = PBXBuildFile; productRef = 6C44128029A35A1000313C3F /* KakaoSDKUser */; }; 6C9628A72A22208F003ADE25 /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 6C9628A62A22208F003ADE25 /* Lottie */; }; 6C9628A92A22209E003ADE25 /* LogoOnboardingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C9628A82A22209E003ADE25 /* LogoOnboardingViewController.swift */; }; - 6CA208232A18FE78001C4247 /* RecommendAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA208222A18FE78001C4247 /* RecommendAPI.swift */; }; - 6CA208252A18FEEA001C4247 /* RecommendService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA208242A18FEEA001C4247 /* RecommendService.swift */; }; + 6CA208232A18FE78001C4247 /* RecommendService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA208222A18FE78001C4247 /* RecommendService.swift */; }; + 6CA208252A18FEEA001C4247 /* RecommendAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA208242A18FEEA001C4247 /* RecommendAPI.swift */; }; 6CA208272A18FFCF001C4247 /* RecommendResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA208262A18FFCF001C4247 /* RecommendResponseDTO.swift */; }; 6CA208292A191185001C4247 /* UIImageView+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA208282A191185001C4247 /* UIImageView+.swift */; }; 6CA2082C2A19122A001C4247 /* Kingfisher in Frameworks */ = {isa = PBXBuildFile; productRef = 6CA2082B2A19122A001C4247 /* Kingfisher */; }; 6CA208302A1925EE001C4247 /* RecommendActionResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA2082F2A1925EE001C4247 /* RecommendActionResponseDTO.swift */; }; - 6CA208342A1956ED001C4247 /* AuthService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA208332A1956ED001C4247 /* AuthService.swift */; }; - 6CA208362A1957CA001C4247 /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA208352A1957CA001C4247 /* AuthAPI.swift */; }; + 6CA208342A1956ED001C4247 /* AuthAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA208332A1956ED001C4247 /* AuthAPI.swift */; }; + 6CA208362A1957CA001C4247 /* AuthService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA208352A1957CA001C4247 /* AuthService.swift */; }; 6CA2083A2A195906001C4247 /* AuthResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA208392A195906001C4247 /* AuthResponseDTO.swift */; }; 6CA2B7BB2A222D2300A9E549 /* ValueOnboardingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CA2B7BA2A222D2300A9E549 /* ValueOnboardingViewController.swift */; }; 6CC54C1A2A28C3AE00AAD76D /* value.json in Resources */ = {isa = PBXBuildFile; fileRef = 6CC54C192A28C3AE00AAD76D /* value.json */; }; @@ -216,7 +215,7 @@ 0982DE5329ADCCE000D933D2 /* HomeEmptyCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeEmptyCollectionViewCell.swift; sourceTree = ""; }; 0982DE5729AE40FB00D933D2 /* UITabBar+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITabBar+.swift"; sourceTree = ""; }; 0982DE5929AE5E6000D933D2 /* CompositionalLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompositionalLayout.swift; sourceTree = ""; }; - 0987C83F2B9DD242007EE8DE /* MissionService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MissionService.swift; sourceTree = ""; }; + 0987C83F2B9DD242007EE8DE /* MissionAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MissionAPI.swift; sourceTree = ""; }; 098904282B81AF3E004AAD3C /* API_KEY.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = API_KEY.plist; path = ../../../../Desktop/API_KEY.plist; sourceTree = ""; }; 0989042F2B81BB3A004AAD3C /* Coordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Coordinator.swift; sourceTree = ""; }; 098904312B81BB43004AAD3C /* CoordinatorDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoordinatorDelegate.swift; sourceTree = ""; }; @@ -244,12 +243,11 @@ 099FC98829B3233D005B37E6 /* CalendarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarView.swift; sourceTree = ""; }; 09A1465E2A192C4900DDC308 /* WeekMissionResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeekMissionResponseDTO.swift; sourceTree = ""; }; 09A146642A19649A00DDC308 /* AddAnotherDayResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAnotherDayResponseDTO.swift; sourceTree = ""; }; - 09A8E48B2B9DBE5C00C0F48F /* API_KEY.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = API_KEY.plist; path = ../../../../Desktop/API_KEY.plist; sourceTree = ""; }; 09A8E48D2B9DBEC700C0F48F /* BaseAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseAPI.swift; sourceTree = ""; }; 09CF56012B09E98A00526C8C /* DetailAchieveHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailAchieveHeaderView.swift; sourceTree = ""; }; 09CF56032B09F23800526C8C /* HomeDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeDataSource.swift; sourceTree = ""; }; 09DCCD1E2A18ED76003DCF8A /* DailyMissionResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DailyMissionResponseDTO.swift; sourceTree = ""; }; - 09DCCD222A18EFB0003DCF8A /* MissionAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MissionAPI.swift; sourceTree = ""; }; + 09DCCD222A18EFB0003DCF8A /* MissionService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MissionService.swift; sourceTree = ""; }; 09ED941A2B2ABAB7001864EF /* CommonNotificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonNotificationViewController.swift; sourceTree = ""; }; 09F6717F29CAD76C00708725 /* SecondOnboardingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondOnboardingViewController.swift; sourceTree = ""; }; 09F6718129CAD86100708725 /* OnboardingCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingCollectionViewCell.swift; sourceTree = ""; }; @@ -330,13 +328,13 @@ 6C16016129C59EFD005AE3F5 /* MyInfoAccountModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyInfoAccountModel.swift; sourceTree = ""; }; 6C16016329C5E37D005AE3F5 /* MyInfoAccountStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyInfoAccountStackView.swift; sourceTree = ""; }; 6C9628A82A22209E003ADE25 /* LogoOnboardingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogoOnboardingViewController.swift; sourceTree = ""; }; - 6CA208222A18FE78001C4247 /* RecommendAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendAPI.swift; sourceTree = ""; }; - 6CA208242A18FEEA001C4247 /* RecommendService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendService.swift; sourceTree = ""; }; + 6CA208222A18FE78001C4247 /* RecommendService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendService.swift; sourceTree = ""; }; + 6CA208242A18FEEA001C4247 /* RecommendAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendAPI.swift; sourceTree = ""; }; 6CA208262A18FFCF001C4247 /* RecommendResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendResponseDTO.swift; sourceTree = ""; }; 6CA208282A191185001C4247 /* UIImageView+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImageView+.swift"; sourceTree = ""; }; 6CA2082F2A1925EE001C4247 /* RecommendActionResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendActionResponseDTO.swift; sourceTree = ""; }; - 6CA208332A1956ED001C4247 /* AuthService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthService.swift; sourceTree = ""; }; - 6CA208352A1957CA001C4247 /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; + 6CA208332A1956ED001C4247 /* AuthAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthAPI.swift; sourceTree = ""; }; + 6CA208352A1957CA001C4247 /* AuthService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthService.swift; sourceTree = ""; }; 6CA208392A195906001C4247 /* AuthResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthResponseDTO.swift; sourceTree = ""; }; 6CA2B7BA2A222D2300A9E549 /* ValueOnboardingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValueOnboardingViewController.swift; sourceTree = ""; }; 6CC54C192A28C3AE00AAD76D /* value.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = value.json; sourceTree = ""; }; @@ -422,7 +420,7 @@ path = Protocol; sourceTree = ""; }; - 093DB02B2A14687300ECA5F6 /* API */ = { + 093DB02B2A14687300ECA5F6 /* Service */ = { isa = PBXGroup; children = ( 09A8E48D2B9DBEC700C0F48F /* BaseAPI.swift */, @@ -430,7 +428,7 @@ 3B892AB22A2FB67000A316BC /* Recommend */, 09A363D12A45F08B003F8DB5 /* Mission */, ); - path = API; + path = Service; sourceTree = ""; }; 093DB02F2A1468CE00ECA5F6 /* DataModel */ = { @@ -445,14 +443,14 @@ path = DataModel; sourceTree = ""; }; - 093DB0312A1468F100ECA5F6 /* Service */ = { + 093DB0312A1468F100ECA5F6 /* API */ = { isa = PBXGroup; children = ( - 0987C83E2B9DD234007EE8DE /* MissionService */, - 3B892AB32A2FB67B00A316BC /* Auth */, + 0987C83E2B9DD234007EE8DE /* Mission */, + 3B892AB32A2FB67B00A316BC /* AuthAPI */, 3B892AB02A2FB63E00A316BC /* Recommend */, ); - path = Service; + path = API; sourceTree = ""; }; 093DB0352A146BE800ECA5F6 /* Enum */ = { @@ -466,12 +464,12 @@ path = Enum; sourceTree = ""; }; - 0987C83E2B9DD234007EE8DE /* MissionService */ = { + 0987C83E2B9DD234007EE8DE /* Mission */ = { isa = PBXGroup; children = ( - 0987C83F2B9DD242007EE8DE /* MissionService.swift */, + 0987C83F2B9DD242007EE8DE /* MissionAPI.swift */, ); - name = MissionService; + name = Mission; sourceTree = ""; }; 0989042D2B81BB22004AAD3C /* Coordinator */ = { @@ -610,7 +608,7 @@ 09A363D12A45F08B003F8DB5 /* Mission */ = { isa = PBXGroup; children = ( - 09DCCD222A18EFB0003DCF8A /* MissionAPI.swift */, + 09DCCD222A18EFB0003DCF8A /* MissionService.swift */, ); path = Mission; sourceTree = ""; @@ -800,9 +798,9 @@ isa = PBXGroup; children = ( 155E45672B5FF2DE008628E7 /* External */, - 093DB0312A1468F100ECA5F6 /* Service */, + 093DB0312A1468F100ECA5F6 /* API */, 093DB02F2A1468CE00ECA5F6 /* DataModel */, - 093DB02B2A14687300ECA5F6 /* API */, + 093DB02B2A14687300ECA5F6 /* Service */, 6CF4705929A68E7F008D145C /* Base */, ); path = Network; @@ -1024,7 +1022,7 @@ 3B892AB02A2FB63E00A316BC /* Recommend */ = { isa = PBXGroup; children = ( - 6CA208242A18FEEA001C4247 /* RecommendService.swift */, + 6CA208242A18FEEA001C4247 /* RecommendAPI.swift */, ); path = Recommend; sourceTree = ""; @@ -1041,17 +1039,17 @@ 3B892AB22A2FB67000A316BC /* Recommend */ = { isa = PBXGroup; children = ( - 6CA208222A18FE78001C4247 /* RecommendAPI.swift */, + 6CA208222A18FE78001C4247 /* RecommendService.swift */, ); path = Recommend; sourceTree = ""; }; - 3B892AB32A2FB67B00A316BC /* Auth */ = { + 3B892AB32A2FB67B00A316BC /* AuthAPI */ = { isa = PBXGroup; children = ( - 6CA208332A1956ED001C4247 /* AuthService.swift */, + 6CA208332A1956ED001C4247 /* AuthAPI.swift */, ); - path = Auth; + path = AuthAPI; sourceTree = ""; }; 3B892AB42A2FB68700A316BC /* Auth */ = { @@ -1065,7 +1063,7 @@ 3B892AB52A2FB69200A316BC /* Auth */ = { isa = PBXGroup; children = ( - 6CA208352A1957CA001C4247 /* AuthAPI.swift */, + 6CA208352A1957CA001C4247 /* AuthService.swift */, ); path = Auth; sourceTree = ""; @@ -1448,11 +1446,11 @@ 09F6719529CBFCD200708725 /* GradientView.swift in Sources */, 09CF56022B09E98A00526C8C /* DetailAchieveHeaderView.swift in Sources */, 3B4E12F82A27C12F001D1EC1 /* WithdrawModalView.swift in Sources */, - 6CA208252A18FEEA001C4247 /* RecommendService.swift in Sources */, + 6CA208252A18FEEA001C4247 /* RecommendAPI.swift in Sources */, 3B482FA5299EAB8800BCF424 /* TabBarController.swift in Sources */, 6CF4705D29A68F5C008D145C /* NetworkLoggerPlugin.swift in Sources */, 09F6718A29CB4A3F00708725 /* FourthOnboardingViewController.swift in Sources */, - 09DCCD232A18EFB0003DCF8A /* MissionAPI.swift in Sources */, + 09DCCD232A18EFB0003DCF8A /* MissionService.swift in Sources */, 09582B4829BDA7F600EF3207 /* DetailStackView.swift in Sources */, 09F6718429CADB1100708725 /* OnboardingModel.swift in Sources */, 3B027A7A299C31B500BEB65C /* SceneDelegate.swift in Sources */, @@ -1485,9 +1483,9 @@ 6C16015C29C56DBA005AE3F5 /* MyInfoAccountViewController.swift in Sources */, 6CF4706129A69096008D145C /* NetworkConstant.swift in Sources */, 09F6718E29CB612B00708725 /* FifthOnboardingViewController.swift in Sources */, - 0987C8402B9DD4DC007EE8DE /* MissionService.swift in Sources */, + 0987C8402B9DD4DC007EE8DE /* MissionAPI.swift in Sources */, 6CD4F8C229AA5AF200CCC740 /* UIButton+.swift in Sources */, - 6CA208362A1957CA001C4247 /* AuthAPI.swift in Sources */, + 6CA208362A1957CA001C4247 /* AuthService.swift in Sources */, 6CF4706529A690E5008D145C /* NetworkBase.swift in Sources */, 099FC98129B3094F005B37E6 /* WeekMonthFSCalendar.swift in Sources */, 6C16016429C5E37D005AE3F5 /* MyInfoAccountStackView.swift in Sources */, @@ -1516,8 +1514,8 @@ 3B9532F42A284CC1006510F8 /* ModalProtocol.swift in Sources */, 3B5F8F8329BF90290063A7F8 /* SituationCollectionViewCell.swift in Sources */, 3B4E12F62A27C0BE001D1EC1 /* QuitModalView.swift in Sources */, - 6CA208232A18FE78001C4247 /* RecommendAPI.swift in Sources */, - 6CA208342A1956ED001C4247 /* AuthService.swift in Sources */, + 6CA208232A18FE78001C4247 /* RecommendService.swift in Sources */, + 6CA208342A1956ED001C4247 /* AuthAPI.swift in Sources */, 0921611B2A5727EF0019CC8C /* AnalyticsEventProtocol.swift in Sources */, 098904542B81CA47004AAD3C /* UpdateCoordinator.swift in Sources */, 0989044E2B81C216004AAD3C /* MypageCoordinatorImpl.swift in Sources */, diff --git a/iOS-NOTTODO/iOS-NOTTODO/Network/API/Auth/AuthAPI.swift b/iOS-NOTTODO/iOS-NOTTODO/Network/API/Auth/AuthAPI.swift deleted file mode 100644 index 3044e321..00000000 --- a/iOS-NOTTODO/iOS-NOTTODO/Network/API/Auth/AuthAPI.swift +++ /dev/null @@ -1,81 +0,0 @@ -// -// AuthAPI.swift -// iOS-NOTTODO -// -// Created by 김민서 on 2023/05/21. -// - -import Foundation - -import Moya - -typealias AuthData = GeneralResponse -typealias EmptyData = GeneralResponse - -protocol AuthAPIType { - func postKakaoAuth(social: LoginType, request: AuthRequest, completion: @escaping (AuthData?) -> Void) - func postAppleAuth(social: LoginType, request: AuthRequest, completion: @escaping (AuthData?) -> Void) - func deleteAuth(completion: @escaping (EmptyData?) -> Void) - func withdrawalAuth(completion: @escaping (EmptyData?) -> Void) -} - -final class AuthAPI: AuthAPIType { - - static let shared: AuthAPI = AuthAPI() - - private let authProvider = MoyaProvider(session: Session(interceptor: AuthInterceptor.shared), plugins: [MoyaLoggingPlugin()]) - - private init() { } - - // MARK: - POST - - func postKakaoAuth(social: LoginType, request: AuthRequest, completion: @escaping (AuthData?) -> Void) { - authProvider.request(.kakaoAuth(social: social, request: request)) { result in - switch result { - case .success(let response): - do { - let response = try response.map(AuthData?.self) - completion(response) - } catch let err { - print(err.localizedDescription, 500) - } - case .failure(let err): - print(err.localizedDescription) - completion(nil) - } - } - } - - func postAppleAuth(social: LoginType, request: AuthRequest, completion: @escaping (AuthData?) -> Void) { - authProvider.request(.appleAuth(social: social, request: request)) { result in - switch result { - case .success(let response): - do { - let response = try response.map(AuthData?.self) - completion(response) - } catch let err { - print(err.localizedDescription, 500) - } - case .failure(let err): - print(err.localizedDescription) - completion(nil) - } - } - } - - // MARK: - Delete - - func deleteAuth(completion: @escaping (EmptyData?) -> Void) { - authProvider.request(.logout) { _ in - completion(nil) - } - } - - // MARK: - Withdrawal - - func withdrawalAuth(completion: @escaping (EmptyData?) -> Void) { - authProvider.request(.withdrawal) { _ in - completion(nil) - } - } -} diff --git a/iOS-NOTTODO/iOS-NOTTODO/Network/API/AuthAPI/AuthAPI.swift b/iOS-NOTTODO/iOS-NOTTODO/Network/API/AuthAPI/AuthAPI.swift new file mode 100644 index 00000000..68555c54 --- /dev/null +++ b/iOS-NOTTODO/iOS-NOTTODO/Network/API/AuthAPI/AuthAPI.swift @@ -0,0 +1,78 @@ +// +// AuthAPI.swift +// iOS-NOTTODO +// +// Created by 김민서 on 2023/05/21. +// + +import Foundation + +import Moya + +struct AuthRequest: Codable { + let socialToken: String + let fcmToken: String + var name: String? +} + +enum AuthAPI { + case kakaoAuth(social: LoginType, request: AuthRequest) + case appleAuth(social: LoginType, request: AuthRequest) + case logout + case withdrawal +} + +extension AuthAPI: BaseAPI { + var domain: BaseDomain { + return .auth + } + + var urlPath: String { + switch self { + case .kakaoAuth(let social, _), .appleAuth(let social, _): + return URLConstant.auth + "/\(social.rawValue)" + case .logout: + return URLConstant.authLogout + case .withdrawal: + return URLConstant.authWithdrawal + } + } + + var headerType: HeaderType { + + switch self { + case .kakaoAuth, .appleAuth: + return .json + case .logout, .withdrawal: + return .jsonWithToken + } + } + + var method: Moya.Method { + switch self { + case .kakaoAuth, .appleAuth: + return .post + case .logout, .withdrawal: + return .delete + } + } + + var task: Moya.Task { + switch self { + case .kakaoAuth(_, let data): + return .requestJSONEncodable(data) + case .appleAuth(_, let data): + return .requestJSONEncodable(data) + case .logout, .withdrawal: + return .requestPlain + } + } +} + +extension Encodable { + var toDictionary: [String: Any] { + guard let object = try? JSONEncoder().encode(self) else { fatalError() } + guard let dictionary = try? JSONSerialization.jsonObject(with: object, options: []) as? [String: Any] else { fatalError() } + return dictionary + } +} diff --git a/iOS-NOTTODO/iOS-NOTTODO/Network/Service/MissionService.swift b/iOS-NOTTODO/iOS-NOTTODO/Network/API/MissionAPI.swift similarity index 97% rename from iOS-NOTTODO/iOS-NOTTODO/Network/Service/MissionService.swift rename to iOS-NOTTODO/iOS-NOTTODO/Network/API/MissionAPI.swift index fdb64650..e71bb15b 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Network/Service/MissionService.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Network/API/MissionAPI.swift @@ -1,5 +1,5 @@ // -// MissionService.swift +// MissionAPI.swift // iOS-NOTTODO // // Created by 강윤서 on 2023/06/07. @@ -25,7 +25,7 @@ struct UpdateMissionRequest: Codable { let goal: String? } -enum MissionService { +enum MissionAPI { case addMission(request: AddMissionRequest) case updateMission(request: UpdateMissionRequest) case recentMission @@ -39,7 +39,7 @@ enum MissionService { case achieveCalendar(month: String) } -extension MissionService: BaseService { +extension MissionAPI: BaseAPI { var domain: BaseDomain { return .mission } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Network/API/Recommend/RecommendAPI.swift b/iOS-NOTTODO/iOS-NOTTODO/Network/API/Recommend/RecommendAPI.swift index 37aa506d..08470c1f 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Network/API/Recommend/RecommendAPI.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Network/API/Recommend/RecommendAPI.swift @@ -9,75 +9,41 @@ import Foundation import Moya -typealias RecommendData = GeneralArrayResponse -typealias ActionData = GeneralResponse -typealias SituationData = GeneralArrayResponse - -protocol RecommendAPIType { - func getRecommend(completion: @escaping (RecommendData?) -> Void) - func getRecommendAction(index: Int, completion: @escaping (ActionData?) -> Void) - func getRecommendSituation(completion: @escaping (SituationData?) -> Void) +enum RecommendAPI { + case recommend + case action(id: Int) + case situdation } -final class RecommendAPI: RecommendAPIType { - - static let shared: RecommendAPI = RecommendAPI() +extension RecommendAPI: BaseAPI { + var domain: BaseDomain { + return .recommend + } - private let provider = MoyaProvider(session: Session(interceptor: AuthInterceptor.shared), plugins: [MoyaLoggingPlugin()]) + var urlPath: String { + switch self { + case .recommend: + return URLConstant.recommend + case .action(id: let id): + return URLConstant.recommendAction + "/\(id)" + "/action" + case .situdation: + return URLConstant.recommendSituation + } + } - private init() {} - - // MARK: - GET + var headerType: HeaderType { + return .jsonWithToken + } - func getRecommend(completion: @escaping (RecommendData?) -> Void) { - provider.request(.recommend) { result in - switch result { - case .success(let response): - do { - let response = try response.map(RecommendData?.self) - completion(response) - } catch let err { - print(err.localizedDescription, 500) - } - case .failure(let err): - print(err.localizedDescription) - completion(nil) - } - } + var method: Moya.Method { + return .get } - func getRecommendAction(index: Int, completion: @escaping (GeneralResponse?) -> Void) { - provider.request(.action(id: index)) { result in - switch result { - case .success(let response): - do { - let reponse = try response.map(ActionData?.self) - completion(reponse) - } catch let err { - print(err.localizedDescription, 500) - } - case .failure(let err): - print(err.localizedDescription) - completion(nil) - } - } + var validationType: ValidationType { + return .successCodes } - func getRecommendSituation(completion: @escaping (SituationData?) -> Void) { - provider.request(.situdation) { result in - switch result { - case .success(let response): - do { - let response = try - response.map(SituationData?.self) - completion(response) - } catch let err { - print(err.localizedDescription, 500) - } - case .failure(let err): - print(err.localizedDescription) - completion(nil) - } - } + var task: Moya.Task { + .requestPlain } } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Network/Service/Auth/AuthService.swift b/iOS-NOTTODO/iOS-NOTTODO/Network/Service/Auth/AuthService.swift index 999d074a..e4b22393 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Network/Service/Auth/AuthService.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Network/Service/Auth/AuthService.swift @@ -1,5 +1,5 @@ // -// AuthService.swift +// AuthAPI.swift // iOS-NOTTODO // // Created by 김민서 on 2023/05/21. @@ -9,70 +9,73 @@ import Foundation import Moya -struct AuthRequest: Codable { - let socialToken: String - let fcmToken: String - var name: String? -} +typealias AuthData = GeneralResponse +typealias EmptyData = GeneralResponse -enum AuthService { - case kakaoAuth(social: LoginType, request: AuthRequest) - case appleAuth(social: LoginType, request: AuthRequest) - case logout - case withdrawal +protocol AuthServiceType { + func postKakaoAuth(social: LoginType, request: AuthRequest, completion: @escaping (AuthData?) -> Void) + func postAppleAuth(social: LoginType, request: AuthRequest, completion: @escaping (AuthData?) -> Void) + func deleteAuth(completion: @escaping (EmptyData?) -> Void) + func withdrawalAuth(completion: @escaping (EmptyData?) -> Void) } -extension AuthService: BaseService { - var domain: BaseDomain { - return .auth - } +final class AuthService: AuthServiceType { + + static let shared: AuthService = AuthService() + + private let authProvider = MoyaProvider(session: Session(interceptor: AuthInterceptor.shared), plugins: [MoyaLoggingPlugin()]) + + private init() { } + + // MARK: - POST - var urlPath: String { - switch self { - case .kakaoAuth(let social, _), .appleAuth(let social, _): - return URLConstant.auth + "/\(social.rawValue)" - case .logout: - return URLConstant.authLogout - case .withdrawal: - return URLConstant.authWithdrawal + func postKakaoAuth(social: LoginType, request: AuthRequest, completion: @escaping (AuthData?) -> Void) { + authProvider.request(.kakaoAuth(social: social, request: request)) { result in + switch result { + case .success(let response): + do { + let response = try response.map(AuthData?.self) + completion(response) + } catch let err { + print(err.localizedDescription, 500) + } + case .failure(let err): + print(err.localizedDescription) + completion(nil) + } } } - var headerType: HeaderType { - - switch self { - case .kakaoAuth, .appleAuth: - return .json - case .logout, .withdrawal: - return .jsonWithToken + func postAppleAuth(social: LoginType, request: AuthRequest, completion: @escaping (AuthData?) -> Void) { + authProvider.request(.appleAuth(social: social, request: request)) { result in + switch result { + case .success(let response): + do { + let response = try response.map(AuthData?.self) + completion(response) + } catch let err { + print(err.localizedDescription, 500) + } + case .failure(let err): + print(err.localizedDescription) + completion(nil) + } } } - var method: Moya.Method { - switch self { - case .kakaoAuth, .appleAuth: - return .post - case .logout, .withdrawal: - return .delete + // MARK: - Delete + + func deleteAuth(completion: @escaping (EmptyData?) -> Void) { + authProvider.request(.logout) { _ in + completion(nil) } } - var task: Moya.Task { - switch self { - case .kakaoAuth(_, let data): - return .requestJSONEncodable(data) - case .appleAuth(_, let data): - return .requestJSONEncodable(data) - case .logout, .withdrawal: - return .requestPlain + // MARK: - Withdrawal + + func withdrawalAuth(completion: @escaping (EmptyData?) -> Void) { + authProvider.request(.withdrawal) { _ in + completion(nil) } } } - -extension Encodable { - var toDictionary: [String: Any] { - guard let object = try? JSONEncoder().encode(self) else { fatalError() } - guard let dictionary = try? JSONSerialization.jsonObject(with: object, options: []) as? [String: Any] else { fatalError() } - return dictionary - } -} diff --git a/iOS-NOTTODO/iOS-NOTTODO/Network/API/BaseAPI.swift b/iOS-NOTTODO/iOS-NOTTODO/Network/Service/BaseAPI.swift similarity index 95% rename from iOS-NOTTODO/iOS-NOTTODO/Network/API/BaseAPI.swift rename to iOS-NOTTODO/iOS-NOTTODO/Network/Service/BaseAPI.swift index 2e717c66..239fa320 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Network/API/BaseAPI.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Network/Service/BaseAPI.swift @@ -29,13 +29,13 @@ extension BaseDomain { } } -protocol BaseService: TargetType { +protocol BaseAPI: TargetType { var domain: BaseDomain { get } var urlPath: String { get } var headerType: HeaderType { get } } -extension BaseService { +extension BaseAPI { var baseURL: URL { return URL(string: Bundle.main.baseURL)! } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Network/API/Mission/MissionAPI.swift b/iOS-NOTTODO/iOS-NOTTODO/Network/Service/Mission/MissionService.swift similarity index 96% rename from iOS-NOTTODO/iOS-NOTTODO/Network/API/Mission/MissionAPI.swift rename to iOS-NOTTODO/iOS-NOTTODO/Network/Service/Mission/MissionService.swift index fe3bd41f..941f1c3b 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Network/API/Mission/MissionAPI.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Network/Service/Mission/MissionService.swift @@ -1,5 +1,5 @@ // -// MissionAPI.swift +// MissionService.swift // iOS-NOTTODO // // Created by JEONGEUN KIM on 2023/05/20. @@ -19,7 +19,7 @@ typealias AddMissionsData = GeneralResponse typealias AddAnotherDay = GeneralResponse typealias UpdateMissionStatus = GeneralResponse -protocol MissionAPIType { +protocol MissionServiceType { func getDailyMission(date: String, completion: @escaping (DailyMissionData?) -> Void) func getWeeklyMissoin(startDate: String, completion: @escaping (WeekMissionData?) -> Void) func getDetailMission(id: Int, completion: @escaping (DetailMissionData?) -> Void) @@ -33,11 +33,11 @@ protocol MissionAPIType { func putUpdateMission(request: UpdateMissionRequest, completion: @escaping(UpdateMissionData?) -> Void) } -final class MissionAPI: MissionAPIType { +final class MissionService: MissionServiceType { - static let shared: MissionAPI = MissionAPI() + static let shared: MissionService = MissionService() - var provider = MoyaProvider(session: Session(interceptor: AuthInterceptor.shared), plugins: [MoyaLoggingPlugin()]) + var provider = MoyaProvider(session: Session(interceptor: AuthInterceptor.shared), plugins: [MoyaLoggingPlugin()]) private init() {} diff --git a/iOS-NOTTODO/iOS-NOTTODO/Network/Service/Recommend/RecommendService.swift b/iOS-NOTTODO/iOS-NOTTODO/Network/Service/Recommend/RecommendService.swift index b92eab39..c98b7c92 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Network/Service/Recommend/RecommendService.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Network/Service/Recommend/RecommendService.swift @@ -9,41 +9,75 @@ import Foundation import Moya -enum RecommendService { - case recommend - case action(id: Int) - case situdation +typealias RecommendData = GeneralArrayResponse +typealias ActionData = GeneralResponse +typealias SituationData = GeneralArrayResponse + +protocol RecommendServiceType { + func getRecommend(completion: @escaping (RecommendData?) -> Void) + func getRecommendAction(index: Int, completion: @escaping (ActionData?) -> Void) + func getRecommendSituation(completion: @escaping (SituationData?) -> Void) } -extension RecommendService: BaseService { - var domain: BaseDomain { - return .recommend - } +final class RecommendService: RecommendServiceType { - var urlPath: String { - switch self { - case .recommend: - return URLConstant.recommend - case .action(id: let id): - return URLConstant.recommendAction + "/\(id)" + "/action" - case .situdation: - return URLConstant.recommendSituation - } - } + static let shared: RecommendService = RecommendService() - var headerType: HeaderType { - return .jsonWithToken - } + private let provider = MoyaProvider(session: Session(interceptor: AuthInterceptor.shared), plugins: [MoyaLoggingPlugin()]) - var method: Moya.Method { - return .get + private init() {} + + // MARK: - GET + + func getRecommend(completion: @escaping (RecommendData?) -> Void) { + provider.request(.recommend) { result in + switch result { + case .success(let response): + do { + let response = try response.map(RecommendData?.self) + completion(response) + } catch let err { + print(err.localizedDescription, 500) + } + case .failure(let err): + print(err.localizedDescription) + completion(nil) + } + } } - var validationType: ValidationType { - return .successCodes + func getRecommendAction(index: Int, completion: @escaping (GeneralResponse?) -> Void) { + provider.request(.action(id: index)) { result in + switch result { + case .success(let response): + do { + let reponse = try response.map(ActionData?.self) + completion(reponse) + } catch let err { + print(err.localizedDescription, 500) + } + case .failure(let err): + print(err.localizedDescription) + completion(nil) + } + } } - var task: Moya.Task { - .requestPlain + func getRecommendSituation(completion: @escaping (SituationData?) -> Void) { + provider.request(.situdation) { result in + switch result { + case .success(let response): + do { + let response = try + response.map(SituationData?.self) + completion(response) + } catch let err { + print(err.localizedDescription, 500) + } + case .failure(let err): + print(err.localizedDescription) + completion(nil) + } + } } } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Achievement/ViewControllers/AchievementViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Achievement/ViewControllers/AchievementViewController.swift index a3569f95..e222eab0 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Achievement/ViewControllers/AchievementViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Achievement/ViewControllers/AchievementViewController.swift @@ -176,7 +176,7 @@ extension AchievementViewController: FSCalendarDelegate, FSCalendarDataSource, F extension AchievementViewController { func requestMonthAPI(month: String) { - MissionAPI.shared.getAchieveCalendar(month: month) { [weak self] response in + MissionService.shared.getAchieveCalendar(month: month) { [weak self] response in guard let self, let response = response, let data = response.data else { return } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Achievement/ViewControllers/DetailAchievementViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Achievement/ViewControllers/DetailAchievementViewController.swift index 13523456..493ebb57 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Achievement/ViewControllers/DetailAchievementViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Achievement/ViewControllers/DetailAchievementViewController.swift @@ -177,7 +177,7 @@ extension DetailAchievementViewController { extension DetailAchievementViewController { private func requestDetailAPI(date: String) { - MissionAPI.shared.getDailyMission(date: date) { [weak self] response in + MissionService.shared.getDailyMission(date: date) { [weak self] response in guard let self else { return } guard let response = response else { return } guard let data = response.data else { return } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/AddMission/Cells/NottodoCollectionViewCell.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/AddMission/Cells/NottodoCollectionViewCell.swift index 7896a441..08888fb6 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/AddMission/Cells/NottodoCollectionViewCell.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/AddMission/Cells/NottodoCollectionViewCell.swift @@ -178,7 +178,7 @@ extension NottodoCollectionViewCell { } private func requestRecentMissionAPI() { - MissionAPI.shared.getRecentMission { [weak self] response in + MissionService.shared.getRecentMission { [weak self] response in guard self != nil else { return } guard let response = response else { return } guard let data = response.data else { return } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/AddMission/Cells/SituationCollectionViewCell.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/AddMission/Cells/SituationCollectionViewCell.swift index 2c14ff74..70a198b3 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/AddMission/Cells/SituationCollectionViewCell.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/AddMission/Cells/SituationCollectionViewCell.swift @@ -175,7 +175,7 @@ private extension SituationCollectionViewCell { } func requestRecommendSituationAPI() { - RecommendAPI.shared.getRecommendSituation { [weak self] response in + RecommendService.shared.getRecommendSituation { [weak self] response in guard self != nil else { return } guard let response = response else { return } guard let data = response.data else { return } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/AddMission/ViewControllers/AddMissionViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/AddMission/ViewControllers/AddMissionViewController.swift index d42a9bf7..04ac3be0 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/AddMission/ViewControllers/AddMissionViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/AddMission/ViewControllers/AddMissionViewController.swift @@ -280,7 +280,7 @@ extension AddMissionViewController { private func requestPostAddMission(title: String, situation: String, actions: [String]?, goal: String?, dates: [String]?) { let request = AddMissionRequest(title: title, situation: situation, actions: actions, goal: goal, dates: dates ?? [""]) - MissionAPI.shared.postAddMission(request: request) { response in + MissionService.shared.postAddMission(request: request) { response in guard let response = response else { return } switch response.status { case 200..<300: @@ -304,7 +304,7 @@ extension AddMissionViewController { private func requestPutUpdateMission(id: Int, title: String, situation: String, actions: [String]?, goal: String?) { let request = UpdateMissionRequest(id: id, title: title, situation: situation, actions: actions, goal: goal) - MissionAPI.shared.putUpdateMission(request: request) { response in + MissionService.shared.putUpdateMission(request: request) { response in guard let response = response else { return } print(response.status) switch response.status { @@ -327,7 +327,7 @@ extension AddMissionViewController { } private func requestGetMissionDates(id: Int) { - MissionAPI.shared.particularMissionDates(id: id) { [weak self] response in + MissionService.shared.particularMissionDates(id: id) { [weak self] response in guard let data = response.data else { return } for item in data { self?.dateList.append(item) @@ -337,7 +337,7 @@ extension AddMissionViewController { } private func requestDailyMissionAPI(id: Int) { - MissionAPI.shared.getDetailMission(id: id) { [weak self] response in + MissionService.shared.getDetailMission(id: id) { [weak self] response in guard let self = self, let response = response else { return } if let data = response.data { diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Auth/AuthViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Auth/AuthViewController.swift index 7cf0ef57..6247cb17 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Auth/AuthViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Auth/AuthViewController.swift @@ -246,7 +246,7 @@ extension AuthViewController { KeychainUtil.setBool(false, forKey: DefaultKeys.isAppleLogin) let request = AuthRequest(socialToken: KeychainUtil.getSocialToken(), fcmToken: KeychainUtil.getFcmToken()) - AuthAPI.shared.postKakaoAuth(social: .KAKAO, request: request) { [weak self] result in + AuthService.shared.postKakaoAuth(social: .KAKAO, request: request) { [weak self] result in guard self != nil else { return } guard result != nil else { return } @@ -335,7 +335,7 @@ extension AuthViewController: ASAuthorizationControllerDelegate, ASAuthorization KeychainUtil.setBool(true, forKey: DefaultKeys.isAppleLogin) let request = AuthRequest(socialToken: KeychainUtil.getSocialToken(), fcmToken: KeychainUtil.getFcmToken(), name: KeychainUtil.getAppleUsername()) - AuthAPI.shared.postAppleAuth(social: .APPLE, request: request) { [weak self] result in + AuthService.shared.postAppleAuth(social: .APPLE, request: request) { [weak self] result in guard self != nil else { return } guard result != nil else { return } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/Modal/NottodoModalViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/Modal/NottodoModalViewController.swift index b89d5214..6df688f8 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/Modal/NottodoModalViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/Modal/NottodoModalViewController.swift @@ -123,7 +123,7 @@ extension NottodoModalViewController { if !KeychainUtil.getBool(DefaultKeys.isAppleLogin) { kakaoWithdrawal() } - AuthAPI.shared.withdrawalAuth { _ in + AuthService.shared.withdrawalAuth { _ in AmplitudeAnalyticsService.shared.send(event: AnalyticsEvent.AccountInfo.completeWithdrawal) } } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/DetailCalendarViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/DetailCalendarViewController.swift index 03df3ae5..444b1fd8 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/DetailCalendarViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/DetailCalendarViewController.swift @@ -211,7 +211,7 @@ extension DetailCalendarViewController: FSCalendarDelegate, FSCalendarDataSource extension DetailCalendarViewController { private func requestAddAnotherDay(id: Int, dates: [String]) { - MissionAPI.shared.postAnotherDay(id: id, dates: dates) { response in + MissionService.shared.postAnotherDay(id: id, dates: dates) { response in guard response != nil else { return } guard let statusCode = response?.status else { return } switch statusCode { @@ -233,7 +233,7 @@ extension DetailCalendarViewController { } func requestParticualrDatesAPI(id: Int) { - MissionAPI.shared.particularMissionDates(id: id) { [weak self] response in + MissionService.shared.particularMissionDates(id: id) { [weak self] response in guard let dates = response.data else { return } self?.invalidDate = dates self?.monthCalendar.reloadCollectionView() diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/HomeViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/HomeViewController.swift index eef8f7b7..aa074e2a 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/HomeViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/HomeViewController.swift @@ -240,7 +240,7 @@ extension HomeViewController { func requestDailyMissionAPI(date: String) { - MissionAPI.shared.getDailyMission(date: date) { [weak self] response in + MissionService.shared.getDailyMission(date: date) { [weak self] response in guard let self, let response = response, let data = response.data else { return } self.missionList = data @@ -250,7 +250,7 @@ extension HomeViewController { private func requestWeeklyMissoinAPI(startDate: String) { - MissionAPI.shared.getWeeklyMissoin(startDate: startDate) { [weak self] response in + MissionService.shared.getWeeklyMissoin(startDate: startDate) { [weak self] response in guard let self, let response = response, let data = response.data else { return } let calendarData = data.compactMap { ($0.actionDate, $0.percentage) } @@ -262,7 +262,7 @@ extension HomeViewController { private func requestPatchUpdateMissionAPI(id: Int, status: CompletionStatus) { - MissionAPI.shared.patchUpdateMissionStatus(id: id, status: status.rawValue) { [weak self] response in + MissionService.shared.patchUpdateMissionStatus(id: id, status: status.rawValue) { [weak self] response in guard let self, let response = response, let data = response.data else { return } if let index = self.missionList.firstIndex(where: { $0.id == id }) { @@ -274,7 +274,7 @@ extension HomeViewController { } private func requestDeleteMission(index: Int, id: Int) { - MissionAPI.shared.deleteMission(id: id) { [weak self] _ in + MissionService.shared.deleteMission(id: id) { [weak self] _ in guard let self else { return } self.dailyLoadData() diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/MissionDetailViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/MissionDetailViewController.swift index 5e6baa7e..2c658f60 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/MissionDetailViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/MissionDetailViewController.swift @@ -227,7 +227,7 @@ extension MissionDetailViewController { extension MissionDetailViewController { func requestDailyMissionAPI(id: Int) { - MissionAPI.shared.getDetailMission(id: id) { [weak self] response in + MissionService.shared.getDetailMission(id: id) { [weak self] response in guard let self else { return } guard let response = response else { return } guard let data = response.data else { return } @@ -243,7 +243,7 @@ extension MissionDetailViewController { } private func requestDeleteMission(id: Int) { - MissionAPI.shared.deleteMission(id: id) { [weak self] _ in + MissionService.shared.deleteMission(id: id) { [weak self] _ in guard let self else { return } guard let data = self.detailModel else { return } if data.id == id { diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/MyInfoAccount/ViewControllers/MyInfoAccountViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/MyInfoAccount/ViewControllers/MyInfoAccountViewController.swift index c67018d0..d9be53a3 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/MyInfoAccount/ViewControllers/MyInfoAccountViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/MyInfoAccount/ViewControllers/MyInfoAccountViewController.swift @@ -184,7 +184,7 @@ extension MyInfoAccountViewController { kakaoLogout() } - AuthAPI.shared.deleteAuth { [weak self] _ in + AuthService.shared.deleteAuth { [weak self] _ in guard let self else { return } self.coordinator?.connectAuthCoordinator(type: .logout ) diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Recommend/ViewControllers/RecommendViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Recommend/ViewControllers/RecommendViewController.swift index 32abdf86..59439d11 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Recommend/ViewControllers/RecommendViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Recommend/ViewControllers/RecommendViewController.swift @@ -149,7 +149,7 @@ private extension RecommendViewController { } func requestRecommendAPI() { - RecommendAPI.shared.getRecommend { [weak self] response in + RecommendService.shared.getRecommend { [weak self] response in guard let self else { return } guard let response = response else { return } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/RecommendAction/ViewControllers/RecommendActionViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/RecommendAction/ViewControllers/RecommendActionViewController.swift index 42984144..d73e836d 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/RecommendAction/ViewControllers/RecommendActionViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/RecommendAction/ViewControllers/RecommendActionViewController.swift @@ -285,7 +285,7 @@ extension RecommendActionViewController: UICollectionViewDelegate { extension RecommendActionViewController { func requestRecommendActionAPI(index: Int) { - RecommendAPI.shared.getRecommendAction(index: index) { [weak self] response in + RecommendService.shared.getRecommendAction(index: index) { [weak self] response in guard let self = self, let response = response, let data = response.data,