From 67a0d5b0ba698849664311c8f1c33ec641d7428d Mon Sep 17 00:00:00 2001 From: FreeDeveloper97 Date: Tue, 1 Oct 2024 18:27:15 +0900 Subject: [PATCH] =?UTF-8?q?feat=20#166:=20VerifyAuthCodeAPI=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project_Timer.xcodeproj/project.pbxproj | 12 ++++++++++ Project_Timer/Data/API/AuthV2API.swift | 10 ++++++-- .../Data/Repository/AuthV2Repository.swift | 7 ++++++ .../Data/Request/VerifyAuthCodeRequest.swift | 14 +++++++++++ .../Response/VerifyAuthCodeResponse.swift | 24 +++++++++++++++++++ .../Domain/Entity/VerifyAuthCodeInfo.swift | 14 +++++++++++ 6 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 Project_Timer/Data/Request/VerifyAuthCodeRequest.swift create mode 100644 Project_Timer/Data/Response/VerifyAuthCodeResponse.swift create mode 100644 Project_Timer/Domain/Entity/VerifyAuthCodeInfo.swift diff --git a/Project_Timer.xcodeproj/project.pbxproj b/Project_Timer.xcodeproj/project.pbxproj index 9fcf86de..0eff7e16 100644 --- a/Project_Timer.xcodeproj/project.pbxproj +++ b/Project_Timer.xcodeproj/project.pbxproj @@ -155,6 +155,9 @@ 874B9D1B25CAB233006FCD04 /* HGGGOTHICSSI_PRO_80G.otf in Resources */ = {isa = PBXBuildFile; fileRef = 874B9D1525CAB233006FCD04 /* HGGGOTHICSSI_PRO_80G.otf */; }; 874B9D1C25CAB233006FCD04 /* HGGGOTHICSSI_PRO_99G.otf in Resources */ = {isa = PBXBuildFile; fileRef = 874B9D1625CAB233006FCD04 /* HGGGOTHICSSI_PRO_99G.otf */; }; 874B9D1E25CAB233006FCD04 /* HGGGOTHICSSI_PRO_40G.otf in Resources */ = {isa = PBXBuildFile; fileRef = 874B9D1825CAB233006FCD04 /* HGGGOTHICSSI_PRO_40G.otf */; }; + 874DCBE72CABEFB500CF9435 /* VerifyAuthCodeRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 874DCBE62CABEFB500CF9435 /* VerifyAuthCodeRequest.swift */; }; + 874DCBE92CABF09100CF9435 /* VerifyAuthCodeInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 874DCBE82CABF09100CF9435 /* VerifyAuthCodeInfo.swift */; }; + 874DCBEB2CABF0B700CF9435 /* VerifyAuthCodeResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 874DCBEA2CABF0B700CF9435 /* VerifyAuthCodeResponse.swift */; }; 874F9C2B2ABFF51700675A86 /* SigninSelectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 874F9C2A2ABFF51700675A86 /* SigninSelectView.swift */; }; 874F9C2D2ABFF73400675A86 /* AppleSigninButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 874F9C2C2ABFF73400675A86 /* AppleSigninButton.swift */; }; 874F9C2F2ABFF7CF00675A86 /* GoogleSigninButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 874F9C2E2ABFF7CF00675A86 /* GoogleSigninButton.swift */; }; @@ -588,6 +591,9 @@ 874B9D1525CAB233006FCD04 /* HGGGOTHICSSI_PRO_80G.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = HGGGOTHICSSI_PRO_80G.otf; sourceTree = ""; }; 874B9D1625CAB233006FCD04 /* HGGGOTHICSSI_PRO_99G.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = HGGGOTHICSSI_PRO_99G.otf; sourceTree = ""; }; 874B9D1825CAB233006FCD04 /* HGGGOTHICSSI_PRO_40G.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = HGGGOTHICSSI_PRO_40G.otf; sourceTree = ""; }; + 874DCBE62CABEFB500CF9435 /* VerifyAuthCodeRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerifyAuthCodeRequest.swift; sourceTree = ""; }; + 874DCBE82CABF09100CF9435 /* VerifyAuthCodeInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerifyAuthCodeInfo.swift; sourceTree = ""; }; + 874DCBEA2CABF0B700CF9435 /* VerifyAuthCodeResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerifyAuthCodeResponse.swift; sourceTree = ""; }; 874F9C2A2ABFF51700675A86 /* SigninSelectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SigninSelectView.swift; sourceTree = ""; }; 874F9C2C2ABFF73400675A86 /* AppleSigninButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleSigninButton.swift; sourceTree = ""; }; 874F9C2E2ABFF7CF00675A86 /* GoogleSigninButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoogleSigninButton.swift; sourceTree = ""; }; @@ -1247,6 +1253,7 @@ 871BC8D02C84701B0092DFA7 /* TTResponseDetailInfo.swift */, 871BC8D22C84703C0092DFA7 /* CheckUsernameInfo.swift */, 8736B74C2CA950D4006BD389 /* PostAuthCodeInfo.swift */, + 874DCBE82CABF09100CF9435 /* VerifyAuthCodeInfo.swift */, ); path = Entity; sourceTree = ""; @@ -1715,6 +1722,7 @@ 87D7ED162952B69200121DE6 /* TestUserSigninRequest.swift */, 871616902C39956E00C4EF25 /* CheckUsernameRequest.swift */, 8736B7482CA94EBE006BD389 /* PostAuthCodeRequest.swift */, + 874DCBE62CABEFB500CF9435 /* VerifyAuthCodeRequest.swift */, ); path = Request; sourceTree = ""; @@ -1739,6 +1747,7 @@ 8722104C2C2FFA66003B97AD /* TTResponse.swift */, 871BC8CE2C846EC00092DFA7 /* CheckUsernameResponse.swift */, 8736B74A2CA94FC9006BD389 /* PostAuthCodeResponse.swift */, + 874DCBEA2CABF0B700CF9435 /* VerifyAuthCodeResponse.swift */, ); path = Response; sourceTree = ""; @@ -2329,6 +2338,7 @@ 87F10936284C47A1002E31EA /* SettingTiTiLabVM.swift in Sources */, 87B7A53C2AC02202002AFDFE /* SigninSelectRoute.swift in Sources */, 873731DD2B2E9AA900D7BD9F /* FirebaseStringArrayValue.swift in Sources */, + 874DCBE72CABEFB500CF9435 /* VerifyAuthCodeRequest.swift in Sources */, 8760FB0C2A1DBB490068CEF5 /* Widget+Extentions.swift in Sources */, 874B542E2C1595A00062D0AC /* RecordTimesRepository.swift in Sources */, 879BE32C2AC68EC7007AAC46 /* PortraitVC.swift in Sources */, @@ -2364,6 +2374,7 @@ 04573A9B2877FDDA008F8D44 /* CountdownTimeLabelVM.swift in Sources */, 87306D5D2B26CB5C001B7C14 /* Typographys.swift in Sources */, 8716169E2C3A604C00C4EF25 /* PostDailysUseCase.swift in Sources */, + 874DCBEB2CABF0B700CF9435 /* VerifyAuthCodeResponse.swift in Sources */, 87306D612B26CBBC001B7C14 /* Icons.swift in Sources */, 87199F4B2883C6D80017D01A /* StandardDailyTaskCell.swift in Sources */, 871616A42C3A607700C4EF25 /* GetSyncLogUseCase.swift in Sources */, @@ -2573,6 +2584,7 @@ 87789E44288BC1FC00759C01 /* TimeView.swift in Sources */, 87A7624726493BB500174401 /* LogHomeVC.swift in Sources */, 8751C6FA28472A8D007FAFC4 /* Collection+Extension.swift in Sources */, + 874DCBE92CABF09100CF9435 /* VerifyAuthCodeInfo.swift in Sources */, 04FA75D6286F263300BAE2B2 /* Colors.swift in Sources */, 04E0DFC728A9191A004DABBE /* HistoryCell.swift in Sources */, 870C70712AD4ECB700024CAC /* SigninRoute.swift in Sources */, diff --git a/Project_Timer/Data/API/AuthV2API.swift b/Project_Timer/Data/API/AuthV2API.swift index 9b8f4700..e0fae255 100644 --- a/Project_Timer/Data/API/AuthV2API.swift +++ b/Project_Timer/Data/API/AuthV2API.swift @@ -12,6 +12,8 @@ import Moya enum AuthV2API { /// 인증 코드를 생성하여 대상에게 전송해요. case postAuthcode(request: PostAuthCodeRequest) + /// 인증 코드를 검증해요. + case verifyAuthcode(request: VerifyAuthCodeRequest) } extension AuthV2API: TargetType { @@ -23,12 +25,14 @@ extension AuthV2API: TargetType { switch self { case .postAuthcode: return "/code" + case .verifyAuthcode: + return "/code/verify" } } var method: Moya.Method { switch self { - case .postAuthcode: + case .postAuthcode, .verifyAuthcode: return .post } } @@ -37,12 +41,14 @@ extension AuthV2API: TargetType { switch self { case .postAuthcode(let request): return .requestJSONEncodable(request) + case .verifyAuthcode(let request): + return .requestJSONEncodable(request) } } var headers: [String : String]? { switch self { - case .postAuthcode: + case .postAuthcode, .verifyAuthcode: return nil } } diff --git a/Project_Timer/Data/Repository/AuthV2Repository.swift b/Project_Timer/Data/Repository/AuthV2Repository.swift index ed87a5f8..d19b5786 100644 --- a/Project_Timer/Data/Repository/AuthV2Repository.swift +++ b/Project_Timer/Data/Repository/AuthV2Repository.swift @@ -24,4 +24,11 @@ final class AuthV2Repository { .map { $0.toDomain() } .catchDecodeError() } + + func verifyAuthCode(request: VerifyAuthCodeRequest) -> AnyPublisher { + return self.api.request(.verifyAuthcode(request: request)) + .map(VerifyAuthCodeResponse.self) + .map { $0.toDomain() } + .catchDecodeError() + } } diff --git a/Project_Timer/Data/Request/VerifyAuthCodeRequest.swift b/Project_Timer/Data/Request/VerifyAuthCodeRequest.swift new file mode 100644 index 00000000..aca8646e --- /dev/null +++ b/Project_Timer/Data/Request/VerifyAuthCodeRequest.swift @@ -0,0 +1,14 @@ +// +// VerifyAuthCodeRequest.swift +// Project_Timer +// +// Created by Kang Minsang on 2024/10/01. +// Copyright © 2024 FDEE. All rights reserved. +// + +import Foundation + +struct VerifyAuthCodeRequest: Encodable { + let authKey: String + let authCode: String +} diff --git a/Project_Timer/Data/Response/VerifyAuthCodeResponse.swift b/Project_Timer/Data/Response/VerifyAuthCodeResponse.swift new file mode 100644 index 00000000..ce9843d8 --- /dev/null +++ b/Project_Timer/Data/Response/VerifyAuthCodeResponse.swift @@ -0,0 +1,24 @@ +// +// VerifyAuthCodeResponse.swift +// Project_Timer +// +// Created by Kang Minsang on 2024/10/01. +// Copyright © 2024 FDEE. All rights reserved. +// + +import Foundation + +struct VerifyAuthCodeResponse: Decodable { + let code: String + let message: String + let authToken: String +} + +extension VerifyAuthCodeResponse { + func toDomain() -> VerifyAuthCodeInfo { + return .init( + detailInfo: .init(code: self.code, message: self.message), + authToken: self.authToken + ) + } +} diff --git a/Project_Timer/Domain/Entity/VerifyAuthCodeInfo.swift b/Project_Timer/Domain/Entity/VerifyAuthCodeInfo.swift new file mode 100644 index 00000000..fde5b701 --- /dev/null +++ b/Project_Timer/Domain/Entity/VerifyAuthCodeInfo.swift @@ -0,0 +1,14 @@ +// +// VerifyAuthCodeInfo.swift +// Project_Timer +// +// Created by Kang Minsang on 2024/10/01. +// Copyright © 2024 FDEE. All rights reserved. +// + +import Foundation + +struct VerifyAuthCodeInfo { + let detailInfo: TTResponseDetailInfo + let authToken: String +}