//
//  FaqApi.swift
//  SodaLive
//
//  Created by klaus on 2023/08/11.
//

import Foundation
import Moya

enum FaqApi {
    case faqs(category: String)
    case faqCategories
}

extension FaqApi: TargetType {
    var baseURL: URL {
        return URL(string: BASE_URL)!
    }
    
    var path: String {
        switch self {
        case .faqs:
            return "/faq"
            
        case .faqCategories:
            return "/faq/category"
        }
    }
    
    var method: Moya.Method {
        return .get
    }
    
    var task: Task {
        switch self {
        case .faqCategories:
            return .requestPlain
            
        case .faqs(let category):
            return .requestParameters(parameters: ["category" : category] as [String : Any], encoding: URLEncoding.queryString)
        }
    }
    
    var headers: [String : String]? {
        return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
    }
}
