27 lines
705 B
TypeScript
27 lines
705 B
TypeScript
import { z } from 'zod'
|
|
|
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
|
|
|
const subscriptionResponseSchema = z.object({
|
|
data: z.array(
|
|
z.object({
|
|
id: z.string(),
|
|
code: z.string(),
|
|
name: z.string(),
|
|
length: z.number().optional(),
|
|
price: z.number().optional(),
|
|
status: z.number().optional(),
|
|
}),
|
|
),
|
|
})
|
|
|
|
export const getSubscriptions = async (parameters?: THttpServer) => {
|
|
try {
|
|
const { data } = await HttpServer(parameters).get(`/api/subscribe-plan`)
|
|
return subscriptionResponseSchema.parse(data)
|
|
} catch (error) {
|
|
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
|
|
return Promise.reject(error)
|
|
}
|
|
}
|