-
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
Changes from 7 commits
c0d5d46
3c6345a
0d0b3a3
b1c8305
619b670
6b1e8e6
b27a4f6
a4f505f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// 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(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 | ||
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. 이 부분 없어도 validationType 기본값은 .none 아닌가용? 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. 지울게욥! |
||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// 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 | ||
} | ||
|
||
} | ||
|
||
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. 공백 한 개만 지워주세용. . ㅎ. 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. 네네! |
||
|
||
public extension ChangeSocialAccountEntity { | ||
static let stub: ChangeSocialAccountEntity = .init(phone: "01011111111", authPlatform: .apple, code: "code") | ||
} |
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 | ||
} | ||
} |
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 | ||
} | ||
} |
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" | ||
} |
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 | ||
} | ||
} |
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 | ||
} | ||
} |
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 | ||
} |
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 | ||
} | ||
} |
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 | ||
} | ||
} |
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" | ||
} |
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 { | ||
|
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.
CoreAuthAPI에는 dto로 명명되어 있던데 명칭 통일하시는 거 어떠실지요!
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.
entity 와 dto중에 무엇으로 통일할까요!
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.
어느 쪽이든 상관 없을 것 같아용