-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] #466 -회원가입 API 연동 #469
Merged
+443
−2
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c0d5d46
[Feat] #466 - ChangeSocialEntity 구현 및 테스트
meltsplit 3c6345a
[Feat] #466 - Social API 연동
meltsplit 0d0b3a3
[Feat] #466 - PhoneVerify 관련 엔티티 구현
meltsplit b1c8305
[Feat] #466 - PhoneVerify 관련 API 구현
meltsplit 619b670
[Feat] #466 - PhoneVerify 관련 Service 구현
meltsplit 6b1e8e6
[Feat] #466 - Login 관련 Entity, API 구현
meltsplit b27a4f6
[Feat] #466 - Login Service 로직 구현
meltsplit a4f505f
[Chore] #466 - 코드리뷰 반영
meltsplit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
SOPT-iOS/Projects/Modules/Networks/Sources/API/CoreAuthAPI.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// CoreAuthAPI.swift | ||
// Networks | ||
// | ||
// Created by 장석우 on 12/30/24. | ||
// Copyright © 2024 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
import Moya | ||
|
||
public enum CoreAuthAPI { | ||
case sendVerifyCode(dto: SendVerificationCodeEntity) | ||
case verfiyCode(dto: VerifyCodeEntity) | ||
case signUp(dto: SignUpEntity) | ||
case login(dto: LoginEntity) | ||
} | ||
|
||
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: | ||
return "/phone" | ||
case .verfiyCode: | ||
return "/verify/phone" | ||
case .signUp: | ||
return "/signup" | ||
case .login: | ||
return "/login/app" | ||
} | ||
} | ||
|
||
// MARK: - Method | ||
public var method: Moya.Method { | ||
switch self { | ||
case .sendVerifyCode: | ||
return .post | ||
case .verfiyCode: | ||
return .post | ||
case .signUp: | ||
return .post | ||
case .login: | ||
return .post | ||
} | ||
} | ||
|
||
|
||
public var task: Task { | ||
switch self { | ||
case let .sendVerifyCode(dto): | ||
return .requestJSONEncodable(dto) | ||
case let .verfiyCode(dto): | ||
return .requestJSONEncodable(dto) | ||
case let .signUp(dto): | ||
return .requestJSONEncodable(dto) | ||
case let .login(dto): | ||
return .requestJSONEncodable(dto) | ||
} | ||
} | ||
|
||
public var validationType: ValidationType { | ||
return .none | ||
} | ||
} | ||
|
||
|
58 changes: 58 additions & 0 deletions
58
SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// SocialAPI.swift | ||
// Networks | ||
// | ||
// Created by 장석우 on 12/28/24. | ||
// Copyright © 2024 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
import Moya | ||
|
||
public enum SocialAPI { | ||
case getSocialAccount(phone: String) | ||
case changeSocialAccount(dto: 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) | ||
} | ||
} | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/ChangeSocialAccountEntity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// ChangeSocialAccountEntity.swift | ||
// Networks | ||
// | ||
// Created by 장석우 on 12/28/24. | ||
// Copyright © 2024 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct ChangeSocialAccountEntity: Encodable { | ||
let phone: String | ||
let authPlatform: PlatformType | ||
let code: String | ||
|
||
public init(phone: String, authPlatform: PlatformType, code: String) { | ||
self.phone = phone | ||
self.authPlatform = authPlatform | ||
self.code = code | ||
} | ||
} | ||
|
||
public extension ChangeSocialAccountEntity { | ||
static let stub: ChangeSocialAccountEntity = .init(phone: "01011111111", authPlatform: .apple, code: "code") | ||
} |
19 changes: 19 additions & 0 deletions
19
SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/CoreSignInEntity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/LoginEntity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/PlatformType.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
21 changes: 21 additions & 0 deletions
21
SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SendVerificationCodeEntity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.filter{ $0.isNumber } | ||
self.type = type | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SignUpEntity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/SocialAccountResultEntity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
23 changes: 23 additions & 0 deletions
23
SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyCodeEntity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyResultEntity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
SOPT-iOS/Projects/Modules/Networks/Sources/Entity/CoreAuth/VerifyType.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ public enum APIType { | |
case poke | ||
case s3 | ||
case fortune | ||
case coreAuth | ||
case social | ||
} | ||
|
||
public protocol BaseAPI: TargetType { | ||
|
@@ -35,7 +37,8 @@ extension BaseAPI { | |
public var baseURL: URL { | ||
var base = Config.Network.baseURL | ||
let operationBaseURL = Config.Network.operationBaseURL | ||
|
||
let coreAuthBaseURL = Config.Network.coreAuthBaseURL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오옹 baseURL이 다른가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네네 맞아용 |
||
|
||
switch Self.apiType { | ||
case .attendance: | ||
base = operationBaseURL | ||
|
@@ -63,6 +66,10 @@ extension BaseAPI { | |
base += "/s3" | ||
case .fortune: | ||
base += "/fortune" | ||
case .coreAuth: | ||
base = coreAuthBaseURL + "/auth" | ||
case .social: | ||
base = coreAuthBaseURL + "/social" | ||
} | ||
|
||
guard let url = URL(string: base) else { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
공백 한 개만 지워주세용. . ㅎ.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네네!