//
//  NoticeApi.swift
//  SodaLive
//
//  Created by klaus on 2023/08/10.
//

import Foundation
import Moya

enum NoticeApi {
    case getNotices
}

extension NoticeApi: TargetType {
    var baseURL: URL {
        return URL(string: BASE_URL)!
    }
    
    var path: String {
        switch self {
        case .getNotices:
            return "/notice"
        }
    }
    
    var method: Moya.Method {
        return .get
    }
    
    var task: Task {
        switch self {
        case .getNotices:
            let parameters = ["timezone": TimeZone.current.identifier] as [String: Any]
            return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
        }
    }
    
    var headers: [String : String]? {
        switch self {
        default:
            return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
        }
    }
}
