46 lines
		
	
	
		
			962 B
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			962 B
		
	
	
	
		
			Swift
		
	
	
	
	
	
//
 | 
						|
//  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))"]
 | 
						|
    }
 | 
						|
}
 |