마이페이지 추가
This commit is contained in:
44
SodaLive/Sources/MyPage/Auth/AuthApi.swift
Normal file
44
SodaLive/Sources/MyPage/Auth/AuthApi.swift
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// AuthApi.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/10.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Moya
|
||||
|
||||
enum AuthApi {
|
||||
case auth(request: AuthVerifyRequest)
|
||||
}
|
||||
|
||||
extension AuthApi: TargetType {
|
||||
var baseURL: URL {
|
||||
return URL(string: BASE_URL)!
|
||||
}
|
||||
|
||||
var path: String {
|
||||
switch self {
|
||||
case .auth:
|
||||
return "/auth"
|
||||
}
|
||||
}
|
||||
|
||||
var method: Moya.Method {
|
||||
return .post
|
||||
}
|
||||
|
||||
var task: Task {
|
||||
switch self {
|
||||
case .auth(let request):
|
||||
return .requestJSONEncodable(request)
|
||||
}
|
||||
}
|
||||
|
||||
var headers: [String : String]? {
|
||||
switch self {
|
||||
default:
|
||||
return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
|
||||
}
|
||||
}
|
||||
}
|
27
SodaLive/Sources/MyPage/Auth/AuthButtonView.swift
Normal file
27
SodaLive/Sources/MyPage/Auth/AuthButtonView.swift
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// AuthButtonView.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/10.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct AuthButtonView: View {
|
||||
var body: some View {
|
||||
Text("본인인증")
|
||||
.font(.custom(Font.bold.rawValue, size: 15.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
.padding(.horizontal, 13.3)
|
||||
.padding(.vertical, 20)
|
||||
.frame(width: screenSize().width - 26.7, alignment: .leading)
|
||||
.background(Color(hex: "664aab"))
|
||||
.cornerRadius(6.7)
|
||||
}
|
||||
}
|
||||
|
||||
struct AuthButtonView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
AuthButtonView()
|
||||
}
|
||||
}
|
20
SodaLive/Sources/MyPage/Auth/AuthRepository.swift
Normal file
20
SodaLive/Sources/MyPage/Auth/AuthRepository.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// AuthRepository.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/10.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CombineMoya
|
||||
import Combine
|
||||
import Moya
|
||||
|
||||
final class AuthRepository {
|
||||
private let api = MoyaProvider<AuthApi>()
|
||||
|
||||
func authCertificate(receiptId: String) -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.auth(request: AuthVerifyRequest(receiptId: receiptId)))
|
||||
}
|
||||
}
|
||||
|
16
SodaLive/Sources/MyPage/Auth/AuthVerifyRequest.swift
Normal file
16
SodaLive/Sources/MyPage/Auth/AuthVerifyRequest.swift
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// AuthVerifyRequest.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/10.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct AuthVerifyRequest: Encodable {
|
||||
let receiptId: String
|
||||
|
||||
enum CodingKeys : String, CodingKey {
|
||||
case receiptId = "receipt_id"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user