//
//  CanTempApi.swift
//  SodaLive
//
//  Created by klaus on 5/20/24.
//

import Foundation
import Moya

enum CanTempApi {
    case chargeCan(request: CanChargeTempRequest)
    case verify(request: PgVerifyRequest)
}

extension CanTempApi: TargetType {
    var baseURL: URL {
        return URL(string: BASE_URL)!
    }
    
    var path: String {
        switch self {
        case .chargeCan:
            return "/charge/temp"
            
        case .verify:
            return "/charge/temp/verify"
        }
    }
    
    var method: Moya.Method {
        switch self {
        case .chargeCan, .verify:
            return .post
        }
    }
    
    var task: Task {
        switch self {
        case .chargeCan(let request):
            return .requestJSONEncodable(request)
            
        case .verify(let request):
            return .requestJSONEncodable(request)
            
        }
    }
    
    var headers: [String : String]? {
        switch self {
        default:
            return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
        }
    }
}
