jsdw_ios/QuickLocation/API/GroupAPI.swift

56 lines
1.3 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.

//
// GroupAPI.swift
// QuickLocation
//
// Created by on 2026/6/1.
//
import Moya
import SwiftyUserDefaults
internal import Alamofire
/// API
enum GroupAPI {
///
case groupInfo
///
/// - Parameters:
/// - opType: createdismisssetdefault
/// - requestData[String: Any]
case operate(opType: String, requestData: [String: Any])
}
extension GroupAPI: MultiTargetProtocol {
var path: String {
switch self {
case .groupInfo:
return "mapi/user/fullinfo"
case .operate:
return "mapi/group/operate"
}
}
var method: Moya.Method {
switch self {
case .groupInfo:
return .get
default:
return .post
}
}
var task: Moya.Task {
switch self {
case .groupInfo:
return .requestParameters(parameters: Parameters(), encoding: URLEncoding())
case let .operate(opType, requestData):
var params = Parameters()
params["op_type"] = opType
params.merge(requestData) { _, new in new }
return .requestParameters(parameters: params, encoding: JSONEncoding())
}
}
}