jsdw_ios/QuickLocation/API/UserAPI.swift

68 lines
1.5 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// UserAPI.swift
// QuickLocation
//
// Created by on 2026/5/28.
//
import Moya
import SwiftyUserDefaults
internal import Alamofire
/// API
enum UserAPI {
///
/// - Parameters:
/// - type: weixinphoneappleonekeydevicealipay
/// - bind1 2
case login(type: String,
bind: String,
data: [String: Any])
///
case userInfo
/// 退
case logout
}
extension UserAPI: MultiTargetProtocol {
var path: String {
switch self {
case .login:
return "api/user/login"
case .userInfo:
return "api/user"
case .logout:
return "api/user/logout"
}
}
var method: Moya.Method {
switch self {
case .userInfo:
return .get
default:
return .post
}
}
var task: Moya.Task {
switch self {
case let .login(type, bind, data):
var params = Parameters()
params["type"] = type
params["bind"] = bind
params["data"] = data
return .requestParameters(parameters: params, encoding: JSONEncoding())
case .userInfo:
return .requestParameters(parameters: Parameters(), encoding: URLEncoding())
case .logout:
return .requestParameters(parameters: Parameters(), encoding: JSONEncoding())
}
}
}