SynthReel/SynthReel/Base/API/SRUserApi.swift
2025-12-11 11:17:46 +08:00

141 lines
4.8 KiB
Swift

//
// SRUserApi.swift
// SynthReel
//
// Created by on 2025/11/13.
// Copyright © 2025 SR. All rights reserved.
//
import Foundation
import Alamofire
struct SRUserApi {
static func requestUserInfo() async -> SRUserInfo? {
await withCheckedContinuation { continuation in
var param = SRNetwork.Parameters(path: "/customer/info")
param.method = .get
SRNetwork.request(parameters: param) { (response: SRNetwork.Response<SRUserInfo>) in
continuation.resume(returning: response.data)
}
}
}
static func requestregister() async -> SRTokenModel? {
await withCheckedContinuation { continuation in
var param = SRNetwork.Parameters(path: "/customer/register")
param.method = .get
SRNetwork.request(parameters: param) { (response: SRNetwork.Response<SRTokenModel>) in
continuation.resume(returning: response.data)
}
}
}
static func requestLeave() async {
await withCheckedContinuation { continuation in
var param = SRNetwork.Parameters(path: "/customer/leaveApp")
param.method = .post
SRNetwork.request(parameters: param) { (_: SRNetwork.Response<String>) in
continuation.resume()
}
}
}
static func requestEnterApp() async {
await withCheckedContinuation { continuation in
var param = SRNetwork.Parameters(path: "/customer/enterTheApp")
param.method = .post
SRNetwork.request(parameters: param) { (_: SRNetwork.Response<String>) in
continuation.resume()
}
}
}
static func requestStatOnLine() async {
await withCheckedContinuation { continuation in
var param = SRNetwork.Parameters(path: "/customer/onLine")
param.method = .post
SRNetwork.request(parameters: param) { (_: SRNetwork.Response<String>) in
continuation.resume()
}
}
}
static func requestStatApnsClick(id: String, title: String) async {
await withCheckedContinuation { continuation in
var param = SRNetwork.Parameters(path: "/message/sendReport")
param.method = .post
param.parameters = [
"message_id" : id,
"title" : title
]
SRNetwork.request(parameters: param) { (_: SRNetwork.Response<String>) in
continuation.resume()
}
}
}
static func requestUploadApnsDeviceToken(token: String) async {
await withCheckedContinuation { continuation in
var param = SRNetwork.Parameters(path: "/customer/firebaseToken")
param.method = .post
param.parameters = [
"fcm_token": token
]
SRNetwork.request(parameters: param) { (_: SRNetwork.Response<String>) in
continuation.resume()
}
}
}
static func requestSignThirdLogin(model: SRThirdModel) async -> SRTokenModel? {
await withCheckedContinuation { continuation in
var param = SRNetwork.Parameters(path: "/customer/login")
param.method = .post
param.parameters = model.toDictionary()
SRNetwork.request(parameters: param) { (response: SRNetwork.Response<SRTokenModel>) in
continuation.resume(returning: response.data)
}
}
}
static func requestLogout() async -> SRTokenModel? {
await withCheckedContinuation { continuation in
var param = SRNetwork.Parameters(path: "/customer/signout")
param.method = .post
SRNetwork.request(parameters: param) { (response: SRNetwork.Response<SRTokenModel>) in
continuation.resume(returning: response.data)
}
}
}
static func requestUploadW2a(data: String) async {
await withCheckedContinuation { continuation in
var param = SRNetwork.Parameters(path: "/w2aSelfAttribution")
param.method = .post
param.parameters = [
"data": data
]
SRNetwork.request(parameters: param) { (_: SRNetwork.Response<String>) in
continuation.resume()
}
}
}
static func requestVersionUpdateData() async -> SRVersionUpdateModel?{
await withCheckedContinuation { continuation in
var param = SRNetwork.Parameters(path: "/customer/versionControl")
param.method = .get
SRNetwork.request(parameters: param) { (response: SRNetwork.Response<SRVersionUpdateModel>) in
continuation.resume(returning: response.data)
}
}
}
}