탐색 메인 페이지
This commit is contained in:
51
SodaLive/Sources/Explorer/ExplorerApi.swift
Normal file
51
SodaLive/Sources/Explorer/ExplorerApi.swift
Normal file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// ExplorerApi.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/10.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Moya
|
||||
|
||||
enum ExplorerApi {
|
||||
case getExplorer
|
||||
case searchChannel(channel: String)
|
||||
}
|
||||
|
||||
extension ExplorerApi: TargetType {
|
||||
var baseURL: URL {
|
||||
return URL(string: BASE_URL)!
|
||||
}
|
||||
|
||||
var path: String {
|
||||
switch self {
|
||||
case .getExplorer:
|
||||
return "/explorer"
|
||||
|
||||
case .searchChannel:
|
||||
return "/explorer/search/channel"
|
||||
}
|
||||
}
|
||||
|
||||
var method: Moya.Method {
|
||||
switch self {
|
||||
case .getExplorer, .searchChannel:
|
||||
return .get
|
||||
}
|
||||
}
|
||||
|
||||
var task: Task {
|
||||
switch self {
|
||||
case .getExplorer:
|
||||
return .requestPlain
|
||||
|
||||
case .searchChannel(let channel):
|
||||
return .requestParameters(parameters: ["channel" : channel], encoding: URLEncoding.queryString)
|
||||
}
|
||||
}
|
||||
|
||||
var headers: [String : String]? {
|
||||
return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user