2025-03-13 06:13:43 +08:00
|
|
|
import { z } from 'zod'
|
|
|
|
|
|
|
|
|
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
|
|
|
|
|
|
|
|
|
const subscribePlanSchema = z.object({
|
|
|
|
|
id: z.string(),
|
|
|
|
|
code: z.string(),
|
|
|
|
|
name: z.string(),
|
|
|
|
|
length: z.number(),
|
|
|
|
|
price: z.number(),
|
|
|
|
|
status: z.number(),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const subscribePlanResponseSchema = z.object({
|
|
|
|
|
data: z.array(subscribePlanSchema),
|
|
|
|
|
})
|
|
|
|
|
|
2025-03-13 07:01:53 +08:00
|
|
|
export type TSubscribePlanResponse = z.infer<typeof subscribePlanSchema>
|
2025-03-13 06:13:43 +08:00
|
|
|
|
|
|
|
|
export const getSubscribePlan = async (parameters?: THttpServer) => {
|
|
|
|
|
try {
|
|
|
|
|
const { data } = await HttpServer(parameters).get(`/api/subscribe-plan`)
|
|
|
|
|
return subscribePlanResponseSchema.parse(data)
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
|
|
|
|
|
return Promise.reject(error)
|
|
|
|
|
}
|
|
|
|
|
}
|