//
//  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))"]
        }
    }
}
