jsdw_ios/QuickLocation/API/OrderAPI.swift

66 lines
1.6 KiB
Swift

//
// OrderAPI.swift
// QuickLocation
//
// Created by on 2026/6/17.
//
import Moya
import SwiftyUserDefaults
internal import Alamofire
/// API
enum OrderAPI {
///
/// - Parameters:
/// - type: member
case rechargeInfo(type: String)
///
/// - Parameters:
/// - goodsId: ID
/// - payType: alipayweixin
/// - source: center
/// - extra:
case orderPayParams(goodsId: String, payType: String, source: String, extra: [String:Any]=[:])
}
extension OrderAPI: MultiTargetProtocol {
var path: String {
switch self {
case .rechargeInfo:
return "api/order/goods"
case .orderPayParams:
return "api/order"
}
}
var method: Moya.Method {
switch self {
case .rechargeInfo:
return .get
default:
return .post
}
}
var task: Moya.Task {
switch self {
case let .rechargeInfo(type):
var params = Parameters()
params["type"] = type
return .requestParameters(parameters: params, encoding: URLEncoding())
case let .orderPayParams(goodsId, payType, source, extra):
var params = Parameters()
params["goods_id"] = goodsId
params["pay_type"] = payType
params["source"] = source
params["pay_source"] = "app"
params["extra"] = extra
return .requestParameters(parameters: params, encoding: JSONEncoding())
}
}
}