103 lines
3.7 KiB
Swift
103 lines
3.7 KiB
Swift
//
|
|
// SRStoreAPI.swift
|
|
// SynthReel
|
|
//
|
|
// Created by CSGY on 2025/12/2.
|
|
// Copyright © 2025 SR. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import SmartCodable
|
|
|
|
|
|
class SRStoreAPI: NSObject {
|
|
enum BuyType: String, SmartCaseDefaultable {
|
|
case coins = "coins"
|
|
case subVip = "sub_vip"
|
|
case subCoins = "sub_coins"
|
|
case vip = "vip"
|
|
}
|
|
|
|
|
|
static func requestPayTemplate() async -> SRPayDateModel? {
|
|
await withCheckedContinuation { continuation in
|
|
var param = SRNetwork.Parameters(path: "/paySettingsV4")
|
|
param.method = .post
|
|
param.parameters = [
|
|
"discount" : "1",
|
|
"purchases_token" : SRPayManger.manager.getAppStoreReceipt() ?? "",
|
|
]
|
|
SRNetwork.request(parameters: param) { (response: SRNetwork.Response<SRPayDateModel>) in
|
|
continuation.resume(returning: response.data)
|
|
}
|
|
}
|
|
}
|
|
|
|
static func requestCreateOrder(payId: String, shortPlayId: String, videoId: String, isDiscount: Bool = false, identifierDiscount: String? = nil) async -> SRIapOrderModel? {
|
|
await withCheckedContinuation { continuation in
|
|
var param = SRNetwork.Parameters(path: "/createOrder")
|
|
param.method = .post
|
|
param.parameters = [
|
|
"payment_channel" : "apple",
|
|
"short_play_id" : shortPlayId,
|
|
"video_id" : videoId,
|
|
"pay_setting_id" : payId,
|
|
"is_discount" : isDiscount ? 1 : 0,
|
|
"product_discount" : identifierDiscount ?? "",
|
|
]
|
|
SRNetwork.request(parameters: param) { (response: SRNetwork.Response<SRIapOrderModel>) in
|
|
continuation.resume(returning: response.data)
|
|
}
|
|
}
|
|
}
|
|
|
|
static func requestVerifyOrder(parameters: [String : Any]) async -> SRIapVerifyModel? {
|
|
await withCheckedContinuation { continuation in
|
|
var param = SRNetwork.Parameters(path: "/applePaid")
|
|
param.method = .post
|
|
param.parameters = parameters
|
|
SRNetwork.request(parameters: param) { (response: SRNetwork.Response<SRIapVerifyModel>) in
|
|
continuation.resume(returning: response.data)
|
|
}
|
|
}
|
|
}
|
|
|
|
static func requestCoinsPackData() async -> SRCoinsPackModel? {
|
|
await withCheckedContinuation { continuation in
|
|
var param = SRNetwork.Parameters(path: "/getReceiveDayCoinInfo")
|
|
param.method = .get
|
|
SRNetwork.request(parameters: param) { (response: SRNetwork.Response<SRCoinsPackModel>) in
|
|
continuation.resume(returning: response.data)
|
|
}
|
|
}
|
|
}
|
|
|
|
static func requestReceiveCoinsPackCoins(id: String?) async -> Bool {
|
|
await withCheckedContinuation { continuation in
|
|
var param = SRNetwork.Parameters(path: "/getReceiveDayCoinInfo")
|
|
param.method = .post
|
|
param.parameters = [
|
|
"id" : id ?? ""
|
|
]
|
|
SRNetwork.request(parameters: param) { (response: SRNetwork.Response<String>) in
|
|
if response.isSuccess {
|
|
continuation.resume(returning: true)
|
|
}else{
|
|
continuation.resume(returning: false)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
static func requestVipRetainPayInfo() async -> SRPayAlertModel? {
|
|
await withCheckedContinuation { continuation in
|
|
var param = SRNetwork.Parameters(path: "/getRetainVipPaySetting")
|
|
param.method = .get
|
|
SRNetwork.request(parameters: param) { (response: SRNetwork.Response<SRPayAlertModel>) in
|
|
continuation.resume(returning: response.data)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|