sodalive-ios/SodaLive/Sources/Settings/Event/EventApi.swift

49 lines
889 B
Swift

//
// EventApi.swift
// SodaLive
//
// Created by klaus on 2023/08/09.
//
import Foundation
import Moya
enum EventApi {
case getEvents
case getEventPopup
}
extension EventApi: TargetType {
var baseURL: URL {
return URL(string: BASE_URL)!
}
var path: String {
switch self {
case .getEvents:
return "/event"
case .getEventPopup:
return "/event/popup"
}
}
var method: Moya.Method {
switch self {
case .getEvents, .getEventPopup:
return .get
}
}
var task: Task {
switch self {
case .getEvents, .getEventPopup:
return .requestPlain
}
}
var headers: [String : String]? {
return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
}
}