From c0d5d466030a125eb2f40f0c836fa9958689cdf0 Mon Sep 17 00:00:00 2001 From: Melt Date: Sat, 28 Dec 2024 01:25:44 +0900 Subject: [PATCH 1/8] =?UTF-8?q?[Feat]=20#466=20-=20ChangeSocialEntity=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Networks/Sources/API/SocialAPI.swift | 9 +++++ .../Entity/ChangeSocialAccountEntity.swift | 35 ++++++++++++++++++ .../Tests/Sources/SocialEntityTests.swift | 36 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/Entity/ChangeSocialAccountEntity.swift create mode 100644 SOPT-iOS/Projects/Modules/Networks/Tests/Sources/SocialEntityTests.swift diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift new file mode 100644 index 000000000..db1b47442 --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift @@ -0,0 +1,9 @@ +// +// SocialAPI.swift +// Networks +// +// Created by 장석우 on 12/28/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/ChangeSocialAccountEntity.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/ChangeSocialAccountEntity.swift new file mode 100644 index 000000000..b446bb03e --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/ChangeSocialAccountEntity.swift @@ -0,0 +1,35 @@ +// +// ChangeSocialAccountEntity.swift +// Networks +// +// Created by 장석우 on 12/28/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + +struct ChangeSocialAccountEntity: Encodable { + let phone: String + let authPlatform: SocialAccountType + let code: String + + + enum CodingKeys: CodingKey { + case phone + case authPlatform + case code + } + + func encode(to encoder: any Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(self.phone, forKey: .phone) + try container.encode(self.authPlatform.rawValue, forKey: .authPlatform) + try container.encode(self.code, forKey: .code) + } + +} + +enum SocialAccountType: String, Encodable { + case google = "GOOGLE" + case apple = "APPLE" +} diff --git a/SOPT-iOS/Projects/Modules/Networks/Tests/Sources/SocialEntityTests.swift b/SOPT-iOS/Projects/Modules/Networks/Tests/Sources/SocialEntityTests.swift new file mode 100644 index 000000000..77c9ac533 --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Tests/Sources/SocialEntityTests.swift @@ -0,0 +1,36 @@ +// +// SocialEntityTests.swift +// NetworksTests +// +// Created by 장석우 on 12/28/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import XCTest +@testable import Networks + +final class SocialEntityTests: XCTestCase { + + override func setUp() { + } + + override func tearDown() { + } + + func test_changeSocialEntity의_authPlatform가_enum의_RAW값으로_encode되는가() throws { + + // given + let encoder = JSONEncoder() + let entity = ChangeSocialAccountEntity(phone: "", authPlatform: .apple, code: "") + + // when + let data = try encoder.encode(entity) + let jsonString = String(data: data, encoding: .utf8) + + //then + XCTAssertTrue(jsonString!.contains("\"authPlatform\":\"APPLE\""), "authPlatform 값이 올바르게 인코딩되지 않았습니다.") + + } + + +} From 3c6345a307d6cc942963b842140898b6d9938cf3 Mon Sep 17 00:00:00 2001 From: Melt Date: Sat, 28 Dec 2024 02:53:14 +0900 Subject: [PATCH 2/8] =?UTF-8?q?[Feat]=20#466=20-=20Social=20API=20?= =?UTF-8?q?=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Networks/Sources/API/SocialAPI.swift | 57 +++++++++++++++++++ .../Entity/ChangeSocialAccountEntity.swift | 26 +++------ .../Sources/Entity/PlatformType.swift | 14 +++++ .../Entity/SocialAccountResultEntity.swift | 13 +++++ .../Networks/Sources/Foundation/BaseAPI.swift | 6 +- .../Sources/Service/SocialService.swift | 29 ++++++++++ 6 files changed, 127 insertions(+), 18 deletions(-) create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/Entity/PlatformType.swift create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/Entity/SocialAccountResultEntity.swift create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/Service/SocialService.swift diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift index db1b47442..48057f3c6 100644 --- a/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift @@ -7,3 +7,60 @@ // import Foundation + +import Alamofire +import Moya +import Core + +public enum SocialAPI { + case getSocialAccount(phone: String) + case changeSocialAccount(entity: ChangeSocialAccountEntity) +} + +extension SocialAPI: BaseAPI { + + public static var apiType: APIType = .social + + // MARK: - Header + public var headers: [String: String]? { + switch self { + default: + return HeaderType.json.value + } + } + + // MARK: - Path + public var path: String { + switch self { + case .getSocialAccount: + return "/accounts/platform" + case .changeSocialAccount: + return "/accounts" + } + } + + // MARK: - Method + public var method: Moya.Method { + switch self { + case .getSocialAccount: + return .get + case .changeSocialAccount: + return .patch + } + } + + + public var task: Task { + switch self { + case let .getSocialAccount(phone): + return .requestParameters(parameters: ["phone": phone], encoding: URLEncoding.queryString) + case let .changeSocialAccount(entity): + return .requestJSONEncodable(entity) + } + } + + public var validationType: ValidationType { + return .none + } +} + diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/ChangeSocialAccountEntity.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/ChangeSocialAccountEntity.swift index b446bb03e..5e5536338 100644 --- a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/ChangeSocialAccountEntity.swift +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/ChangeSocialAccountEntity.swift @@ -8,28 +8,20 @@ import Foundation -struct ChangeSocialAccountEntity: Encodable { +public struct ChangeSocialAccountEntity: Encodable { let phone: String - let authPlatform: SocialAccountType + let authPlatform: PlatformType let code: String - - enum CodingKeys: CodingKey { - case phone - case authPlatform - case code - } - - func encode(to encoder: any Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(self.phone, forKey: .phone) - try container.encode(self.authPlatform.rawValue, forKey: .authPlatform) - try container.encode(self.code, forKey: .code) + public init(phone: String, authPlatform: PlatformType, code: String) { + self.phone = phone + self.authPlatform = authPlatform + self.code = code } } -enum SocialAccountType: String, Encodable { - case google = "GOOGLE" - case apple = "APPLE" + +public extension ChangeSocialAccountEntity { + static let stub: ChangeSocialAccountEntity = .init(phone: "01011111111", authPlatform: .apple, code: "code") } diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/PlatformType.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/PlatformType.swift new file mode 100644 index 000000000..20956b321 --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/PlatformType.swift @@ -0,0 +1,14 @@ +// +// PlatformType.swift +// Networks +// +// Created by 장석우 on 12/28/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + +public enum PlatformType: String, Codable { + case google = "GOOGLE" + case apple = "APPLE" +} diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/SocialAccountResultEntity.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/SocialAccountResultEntity.swift new file mode 100644 index 000000000..a699f79b6 --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/SocialAccountResultEntity.swift @@ -0,0 +1,13 @@ +// +// ChangeSocialResultEntity.swift +// Networks +// +// Created by 장석우 on 12/28/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + +public struct SocialAccountResultEntity: Decodable { + let platform: PlatformType +} diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Foundation/BaseAPI.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Foundation/BaseAPI.swift index 9e743bb92..6ac1079b3 100644 --- a/SOPT-iOS/Projects/Modules/Networks/Sources/Foundation/BaseAPI.swift +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Foundation/BaseAPI.swift @@ -25,6 +25,7 @@ public enum APIType { case poke case s3 case fortune + case social } public protocol BaseAPI: TargetType { @@ -35,7 +36,8 @@ extension BaseAPI { public var baseURL: URL { var base = Config.Network.baseURL let operationBaseURL = Config.Network.operationBaseURL - + let coreAuthBaseURL = Config.Network.coreAuthBaseURL + switch Self.apiType { case .attendance: base = operationBaseURL @@ -63,6 +65,8 @@ extension BaseAPI { base += "/s3" case .fortune: base += "/fortune" + case .social: + base = coreAuthBaseURL + "/social" } guard let url = URL(string: base) else { diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Service/SocialService.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Service/SocialService.swift new file mode 100644 index 000000000..7bba9435c --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Service/SocialService.swift @@ -0,0 +1,29 @@ +// +// SocialService.swift +// Networks +// +// Created by 장석우 on 12/28/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation +import Combine + +import Moya + +public typealias DefaultSocialService = BaseService + +public protocol SocialService { + func getSocialAccount(for phoneNumber: String) -> AnyPublisher + func changeSocialAccount(with entity: ChangeSocialAccountEntity) -> AnyPublisher +} + +extension DefaultSocialService: SocialService { + public func getSocialAccount(for phoneNumber: String) -> AnyPublisher { + requestObjectInCombine(.getSocialAccount(phone: phoneNumber)) + } + + public func changeSocialAccount(with entity: ChangeSocialAccountEntity) -> AnyPublisher { + return requestObjectInCombineNoResult(.changeSocialAccount(entity: entity)) + } +} From 0d0b3a35ea968c8ea12f982b9fad9b2a1b4838bb Mon Sep 17 00:00:00 2001 From: Melt Date: Mon, 30 Dec 2024 19:07:04 +0900 Subject: [PATCH 3/8] =?UTF-8?q?[Feat]=20#466=20-=20PhoneVerify=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Networks/Sources/API/CoreAuthAPI.swift | 70 +++++++++++++++++++ .../CoreAuth/SendVerificationCodeEntity.swift | 21 ++++++ .../Entity/CoreAuth/VerifyCodeEntity.swift | 23 ++++++ .../Entity/CoreAuth/VerifyResultEntity.swift | 21 ++++++ .../Sources/Entity/CoreAuth/VerifyType.swift | 16 +++++ .../Networks/Sources/Foundation/BaseAPI.swift | 3 + 6 files changed, 154 insertions(+) create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/API/CoreAuthAPI.swift create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SendVerificationCodeEntity.swift create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyCodeEntity.swift create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyResultEntity.swift create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyType.swift diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/API/CoreAuthAPI.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/API/CoreAuthAPI.swift new file mode 100644 index 000000000..7b2083d64 --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/API/CoreAuthAPI.swift @@ -0,0 +1,70 @@ +// +// CoreAuthAPI.swift +// Networks +// +// Created by 장석우 on 12/30/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Moya +import Core + +public enum CoreAuthAPI { + case sendVerifyCode(phone: ) + case verfiyCode(entity: ) + case signUp + case signIn +} + +extension CoreAuthAPI: BaseAPI { + + public static var apiType: APIType = .coreAuth + + // MARK: - Header + public var headers: [String: String]? { + switch self { + default: + return HeaderType.json.value + } + } + + // MARK: - Path + public var path: String { + switch self { + case .sendVerifyCode(phone: let phone): + <#code#> + case .verfiyCode(entity: let entity): + <#code#> + case .signUp: + <#code#> + case .signIn: + <#code#> + } + } + + // MARK: - Method + public var method: Moya.Method { + switch self { + case .getSocialAccount: + return .get + case .changeSocialAccount: + return .patch + } + } + + + public var task: Task { + switch self { + case let .getSocialAccount(phone): + return .requestParameters(parameters: ["phone": phone], encoding: URLEncoding.queryString) + case let .changeSocialAccount(entity): + return .requestJSONEncodable(entity) + } + } + + public var validationType: ValidationType { + return .none + } +} + + diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SendVerificationCodeEntity.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SendVerificationCodeEntity.swift new file mode 100644 index 000000000..95b08eb8b --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SendVerificationCodeEntity.swift @@ -0,0 +1,21 @@ +// +// SendVerificationCodeEntity.swift +// Networks +// +// Created by 장석우 on 12/30/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + +public struct SendVerificationCodeEntity: Encodable { + let name: String + let phone: String + let type: VerifyType + + public init(name: String, phone: String, type: VerifyType) { + self.name = name + self.phone = phone + self.type = type + } +} diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyCodeEntity.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyCodeEntity.swift new file mode 100644 index 000000000..bd753e4a8 --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyCodeEntity.swift @@ -0,0 +1,23 @@ +// +// VerifyCodeEntity.swift +// Networks +// +// Created by 장석우 on 12/30/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + +public struct VerifyCodeEntity: Encodable { + let name: String + let phone: String + let type: VerifyType + let code: String + + public init(name: String, phone: String, type: VerifyType, code: String) { + self.name = name + self.phone = phone + self.type = type + self.code = code + } +} diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyResultEntity.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyResultEntity.swift new file mode 100644 index 000000000..bf3ef88b7 --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyResultEntity.swift @@ -0,0 +1,21 @@ +// +// VerifyResultEntity.swift +// Networks +// +// Created by 장석우 on 12/30/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + +public struct VerifyResultEntity: Decodable { + let isVerified: Bool + let name: String + let phone: String + + public init(isVerified: Bool, name: String, phone: String) { + self.isVerified = isVerified + self.name = name + self.phone = phone + } +} diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyType.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyType.swift new file mode 100644 index 000000000..32149cb4e --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyType.swift @@ -0,0 +1,16 @@ +// +// VerifyType.swift +// Networks +// +// Created by 장석우 on 12/30/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + + +public enum VerifyType: String, Encodable { + case register = "REGISTER" + case change = "CHANGE" + case search = "SEARCH" +} diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Foundation/BaseAPI.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Foundation/BaseAPI.swift index 6ac1079b3..ea1e5b755 100644 --- a/SOPT-iOS/Projects/Modules/Networks/Sources/Foundation/BaseAPI.swift +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Foundation/BaseAPI.swift @@ -25,6 +25,7 @@ public enum APIType { case poke case s3 case fortune + case coreAuth case social } @@ -65,6 +66,8 @@ extension BaseAPI { base += "/s3" case .fortune: base += "/fortune" + case .coreAuth: + base = coreAuthBaseURL + "/auth" case .social: base = coreAuthBaseURL + "/social" } From b1c8305de48985ff8a28a21aad5ad6d1763707aa Mon Sep 17 00:00:00 2001 From: Melt Date: Mon, 30 Dec 2024 19:13:42 +0900 Subject: [PATCH 4/8] =?UTF-8?q?[Feat]=20#466=20-=20PhoneVerify=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Networks/Sources/API/CoreAuthAPI.swift | 41 +++++++++++-------- .../Networks/Sources/API/SocialAPI.swift | 4 -- .../Networks/Tests/Sources/UnitTest.swift | 1 - 3 files changed, 24 insertions(+), 22 deletions(-) delete mode 100644 SOPT-iOS/Projects/Modules/Networks/Tests/Sources/UnitTest.swift diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/API/CoreAuthAPI.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/API/CoreAuthAPI.swift index 7b2083d64..ed9e81a70 100644 --- a/SOPT-iOS/Projects/Modules/Networks/Sources/API/CoreAuthAPI.swift +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/API/CoreAuthAPI.swift @@ -7,11 +7,10 @@ // import Moya -import Core public enum CoreAuthAPI { - case sendVerifyCode(phone: ) - case verfiyCode(entity: ) + case sendVerifyCode(dto: SendVerificationCodeEntity) + case verfiyCode(dto: VerifyCodeEntity) case signUp case signIn } @@ -31,34 +30,42 @@ extension CoreAuthAPI: BaseAPI { // MARK: - Path public var path: String { switch self { - case .sendVerifyCode(phone: let phone): - <#code#> - case .verfiyCode(entity: let entity): - <#code#> + case .sendVerifyCode: + return "/phone" + case .verfiyCode: + return "/verify/phone" case .signUp: - <#code#> + return "signup" case .signIn: - <#code#> + return "/login/app" } } // MARK: - Method public var method: Moya.Method { switch self { - case .getSocialAccount: - return .get - case .changeSocialAccount: - return .patch + case .sendVerifyCode: + return .post + case .verfiyCode: + return .post + case .signUp: + return .post + case .signIn: + return .post } } public var task: Task { switch self { - case let .getSocialAccount(phone): - return .requestParameters(parameters: ["phone": phone], encoding: URLEncoding.queryString) - case let .changeSocialAccount(entity): - return .requestJSONEncodable(entity) + case let .sendVerifyCode(dto): + return .requestJSONEncodable(dto) + case let .verfiyCode(dto): + return .requestJSONEncodable(dto) + case .signUp: + return .requestPlain + case .signIn: + return .requestPlain } } diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift index 48057f3c6..0203901a0 100644 --- a/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift @@ -6,11 +6,7 @@ // Copyright © 2024 SOPT-iOS. All rights reserved. // -import Foundation - -import Alamofire import Moya -import Core public enum SocialAPI { case getSocialAccount(phone: String) diff --git a/SOPT-iOS/Projects/Modules/Networks/Tests/Sources/UnitTest.swift b/SOPT-iOS/Projects/Modules/Networks/Tests/Sources/UnitTest.swift deleted file mode 100644 index 8b1378917..000000000 --- a/SOPT-iOS/Projects/Modules/Networks/Tests/Sources/UnitTest.swift +++ /dev/null @@ -1 +0,0 @@ - From 619b670a3a4630ce8d6be8d9f1a1ae65a42f922a Mon Sep 17 00:00:00 2001 From: Melt Date: Mon, 30 Dec 2024 20:15:09 +0900 Subject: [PATCH 5/8] =?UTF-8?q?[Feat]=20#466=20-=20PhoneVerify=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20Service=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CoreAuth/SendVerificationCodeEntity.swift | 2 +- .../Networks/Sources/Foundation/BaseAPI.swift | 2 +- .../Sources/Service/CoreAuthService.swift | 31 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/Service/CoreAuthService.swift diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SendVerificationCodeEntity.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SendVerificationCodeEntity.swift index 95b08eb8b..73de1c036 100644 --- a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SendVerificationCodeEntity.swift +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SendVerificationCodeEntity.swift @@ -15,7 +15,7 @@ public struct SendVerificationCodeEntity: Encodable { public init(name: String, phone: String, type: VerifyType) { self.name = name - self.phone = phone + self.phone = phone.filter{ $0.isNumber } self.type = type } } diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Foundation/BaseAPI.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Foundation/BaseAPI.swift index ea1e5b755..c56b053ae 100644 --- a/SOPT-iOS/Projects/Modules/Networks/Sources/Foundation/BaseAPI.swift +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Foundation/BaseAPI.swift @@ -67,7 +67,7 @@ extension BaseAPI { case .fortune: base += "/fortune" case .coreAuth: - base = coreAuthBaseURL + "/auth" + base = coreAuthBaseURL + "/auth" case .social: base = coreAuthBaseURL + "/social" } diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Service/CoreAuthService.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Service/CoreAuthService.swift new file mode 100644 index 000000000..f2e251877 --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Service/CoreAuthService.swift @@ -0,0 +1,31 @@ +// +// CoreAuthService.swift +// Networks +// +// Created by 장석우 on 12/30/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation +import Combine + +import Moya +import Core + +public typealias DefaultCoreAuthService = BaseService + +public protocol CoreAuthService { + func sendVerifyCode(_ dto: SendVerificationCodeEntity) -> AnyPublisher + func verifyCode(_ dto: VerifyCodeEntity) -> AnyPublisher, Error> +} + +extension DefaultCoreAuthService: CoreAuthService { + public func sendVerifyCode(_ dto: SendVerificationCodeEntity) -> AnyPublisher { + requestObjectInCombineNoResult(.sendVerifyCode(dto: dto)) + } + + public func verifyCode(_ dto: VerifyCodeEntity) -> AnyPublisher, Error> { + requestObjectInCombine(.verfiyCode(dto: dto)) + } +} + From 6b1e8e6c111a52fdb349904ac9cc841a65c53328 Mon Sep 17 00:00:00 2001 From: Melt Date: Mon, 30 Dec 2024 20:23:20 +0900 Subject: [PATCH 6/8] =?UTF-8?q?[Feat]=20#466=20-=20Login=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20Entity,=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Networks/Sources/API/CoreAuthAPI.swift | 18 ++++++------- .../ChangeSocialAccountEntity.swift | 0 .../Sources/Entity/CoreAuth/LoginEntity.swift | 19 ++++++++++++++ .../Entity/{ => CoreAuth}/PlatformType.swift | 0 .../Entity/CoreAuth/SignUpEntity.swift | 25 +++++++++++++++++++ .../SocialAccountResultEntity.swift | 0 6 files changed, 53 insertions(+), 9 deletions(-) rename SOPT-iOS/Projects/Modules/Networks/Sources/Entity/{ => CoreAuth}/ChangeSocialAccountEntity.swift (100%) create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/LoginEntity.swift rename SOPT-iOS/Projects/Modules/Networks/Sources/Entity/{ => CoreAuth}/PlatformType.swift (100%) create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SignUpEntity.swift rename SOPT-iOS/Projects/Modules/Networks/Sources/Entity/{ => CoreAuth}/SocialAccountResultEntity.swift (100%) diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/API/CoreAuthAPI.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/API/CoreAuthAPI.swift index ed9e81a70..2764cd3ec 100644 --- a/SOPT-iOS/Projects/Modules/Networks/Sources/API/CoreAuthAPI.swift +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/API/CoreAuthAPI.swift @@ -11,8 +11,8 @@ import Moya public enum CoreAuthAPI { case sendVerifyCode(dto: SendVerificationCodeEntity) case verfiyCode(dto: VerifyCodeEntity) - case signUp - case signIn + case signUp(dto: SignUpEntity) + case login(dto: LoginEntity) } extension CoreAuthAPI: BaseAPI { @@ -35,8 +35,8 @@ extension CoreAuthAPI: BaseAPI { case .verfiyCode: return "/verify/phone" case .signUp: - return "signup" - case .signIn: + return "/signup" + case .login: return "/login/app" } } @@ -50,7 +50,7 @@ extension CoreAuthAPI: BaseAPI { return .post case .signUp: return .post - case .signIn: + case .login: return .post } } @@ -62,10 +62,10 @@ extension CoreAuthAPI: BaseAPI { return .requestJSONEncodable(dto) case let .verfiyCode(dto): return .requestJSONEncodable(dto) - case .signUp: - return .requestPlain - case .signIn: - return .requestPlain + case let .signUp(dto): + return .requestJSONEncodable(dto) + case let .login(dto): + return .requestJSONEncodable(dto) } } diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/ChangeSocialAccountEntity.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/ChangeSocialAccountEntity.swift similarity index 100% rename from SOPT-iOS/Projects/Modules/Networks/Sources/Entity/ChangeSocialAccountEntity.swift rename to SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/ChangeSocialAccountEntity.swift diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/LoginEntity.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/LoginEntity.swift new file mode 100644 index 000000000..6c87cbf31 --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/LoginEntity.swift @@ -0,0 +1,19 @@ +// +// LoginEntity.swift +// Networks +// +// Created by 장석우 on 12/30/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + +public struct LoginEntity: Encodable { + let code: String + let authPlatform: PlatformType + + public init(code: String, authPlatform: PlatformType) { + self.code = code + self.authPlatform = authPlatform + } +} diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/PlatformType.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/PlatformType.swift similarity index 100% rename from SOPT-iOS/Projects/Modules/Networks/Sources/Entity/PlatformType.swift rename to SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/PlatformType.swift diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SignUpEntity.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SignUpEntity.swift new file mode 100644 index 000000000..2145e8884 --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SignUpEntity.swift @@ -0,0 +1,25 @@ +// +// SignUpEntity.swift +// Networks +// +// Created by 장석우 on 12/30/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + +public struct SignUpEntity: Encodable { + let name: String + let phone: String + let type: VerifyType + let code: String + let authPlatform: PlatformType + + public init(name: String, phone: String, type: VerifyType, code: String, authPlatform: PlatformType) { + self.name = name + self.phone = phone + self.type = type + self.code = code + self.authPlatform = authPlatform + } +} diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/SocialAccountResultEntity.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SocialAccountResultEntity.swift similarity index 100% rename from SOPT-iOS/Projects/Modules/Networks/Sources/Entity/SocialAccountResultEntity.swift rename to SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SocialAccountResultEntity.swift From b27a4f6fecc028f13f632b9288a1733205348c0a Mon Sep 17 00:00:00 2001 From: Melt Date: Mon, 30 Dec 2024 20:59:05 +0900 Subject: [PATCH 7/8] =?UTF-8?q?[Feat]=20#466=20-=20Login=20Service=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/CoreAuth/CoreSignInEntity.swift | 19 +++++++++++++++++++ .../Sources/Service/CoreAuthService.swift | 8 +++++++- .../Sources/Service/SocialService.swift | 6 ++++-- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/CoreSignInEntity.swift diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/CoreSignInEntity.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/CoreSignInEntity.swift new file mode 100644 index 000000000..0f401d5eb --- /dev/null +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/CoreSignInEntity.swift @@ -0,0 +1,19 @@ +// +// CoreSignInEntity.swift +// Networks +// +// Created by 장석우 on 12/30/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + +public struct CoreSignInEntity: Decodable { + let accessToken: String + let refreshToken: String + + public init(accessToken: String, refreshToken: String) { + self.accessToken = accessToken + self.refreshToken = refreshToken + } +} diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Service/CoreAuthService.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Service/CoreAuthService.swift index f2e251877..8a1a9cf6e 100644 --- a/SOPT-iOS/Projects/Modules/Networks/Sources/Service/CoreAuthService.swift +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Service/CoreAuthService.swift @@ -9,14 +9,16 @@ import Foundation import Combine -import Moya import Core +import Moya + public typealias DefaultCoreAuthService = BaseService public protocol CoreAuthService { func sendVerifyCode(_ dto: SendVerificationCodeEntity) -> AnyPublisher func verifyCode(_ dto: VerifyCodeEntity) -> AnyPublisher, Error> + func login(_ dto: LoginEntity) -> AnyPublisher, Error> } extension DefaultCoreAuthService: CoreAuthService { @@ -27,5 +29,9 @@ extension DefaultCoreAuthService: CoreAuthService { public func verifyCode(_ dto: VerifyCodeEntity) -> AnyPublisher, Error> { requestObjectInCombine(.verfiyCode(dto: dto)) } + + public func login(_ dto: LoginEntity) -> AnyPublisher, Error> { + requestObjectInCombine(.login(dto: dto)) + } } diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Service/SocialService.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Service/SocialService.swift index 7bba9435c..90ab1f970 100644 --- a/SOPT-iOS/Projects/Modules/Networks/Sources/Service/SocialService.swift +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Service/SocialService.swift @@ -9,17 +9,19 @@ import Foundation import Combine +import Core import Moya + public typealias DefaultSocialService = BaseService public protocol SocialService { - func getSocialAccount(for phoneNumber: String) -> AnyPublisher + func getSocialAccount(for phoneNumber: String) -> AnyPublisher, Error> func changeSocialAccount(with entity: ChangeSocialAccountEntity) -> AnyPublisher } extension DefaultSocialService: SocialService { - public func getSocialAccount(for phoneNumber: String) -> AnyPublisher { + public func getSocialAccount(for phoneNumber: String) -> AnyPublisher, Error> { requestObjectInCombine(.getSocialAccount(phone: phoneNumber)) } From a4f505f4b083e051e9c4af708c6a958f3ea4a013 Mon Sep 17 00:00:00 2001 From: Melt Date: Sun, 5 Jan 2025 15:31:10 +0900 Subject: [PATCH 8/8] =?UTF-8?q?[Chore]=20#466=20-=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Projects/Modules/Networks/Sources/API/SocialAPI.swift | 6 +----- .../Sources/Entity/CoreAuth/ChangeSocialAccountEntity.swift | 2 -- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift index 0203901a0..a224616d3 100644 --- a/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift @@ -10,7 +10,7 @@ import Moya public enum SocialAPI { case getSocialAccount(phone: String) - case changeSocialAccount(entity: ChangeSocialAccountEntity) + case changeSocialAccount(dto: ChangeSocialAccountEntity) } extension SocialAPI: BaseAPI { @@ -54,9 +54,5 @@ extension SocialAPI: BaseAPI { return .requestJSONEncodable(entity) } } - - public var validationType: ValidationType { - return .none - } } diff --git a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/ChangeSocialAccountEntity.swift b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/ChangeSocialAccountEntity.swift index 5e5536338..8126dacbc 100644 --- a/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/ChangeSocialAccountEntity.swift +++ b/SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/ChangeSocialAccountEntity.swift @@ -18,10 +18,8 @@ public struct ChangeSocialAccountEntity: Encodable { self.authPlatform = authPlatform self.code = code } - } - public extension ChangeSocialAccountEntity { static let stub: ChangeSocialAccountEntity = .init(phone: "01011111111", authPlatform: .apple, code: "code") }