콘텐츠 전체보기

- 카테고리 추가
This commit is contained in:
Yu Sung
2024-02-07 15:09:48 +09:00
parent 638d00ffc3
commit 62904d96b1
7 changed files with 196 additions and 10 deletions

View File

@@ -0,0 +1,45 @@
//
// CategoryApi.swift
// SodaLive
//
// Created by klaus on 2/7/24.
//
import Foundation
import Moya
enum CategoryApi {
case getCategoryList(creatorId: Int)
}
extension CategoryApi: TargetType {
var baseURL: URL {
return URL(string: BASE_URL)!
}
var path: String {
switch self {
case .getCategoryList:
return "/category"
}
}
var method: Moya.Method {
switch self {
case .getCategoryList:
return .get
}
}
var task: Moya.Task {
switch self {
case .getCategoryList(let creatorId):
let parameters = ["creatorId": creatorId] as [String : Any]
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
}
}
var headers: [String : String]? {
return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
}
}