jsdw_ios/QuickLocation/API/ItineraryAPI.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.

//
// ItineraryAPI.swift
// QuickLocation
//
// Created by 八条 on 2026/6/23.
//
import Moya
import SwiftyUserDefaults
internal import Alamofire
/// 行程API
enum ItineraryAPI {
/// 查询行程
/// - Parameters:
/// - follow: 只查看关注的行程
/// - own: 只查看自己创建的行程
/// - history: true查看历史行程,默认查看今天之后的行程
/// - group_key: 过滤圈子查询
case query(follow: Bool, own: Bool, history: Bool, group_key: String, page: Int)
}
extension ItineraryAPI: MultiTargetProtocol {
var path: String {
switch self {
case .query:
return "mapi/itinerary/route"
}
}
var method: Moya.Method {
switch self {
case .query:
return .get
default:
return .post
}
}
var task: Moya.Task {
switch self {
case let .query(follow, own, history, group_key, page):
var params = Parameters()
params["follow"] = follow
params["own"] = own
params["history"] = history
params["group_key"] = group_key
params["page"] = page
params["limit"] = 20
return .requestParameters(parameters: params, encoding: URLEncoding())
}
}
}