import { z } from 'zod'

export const cardStatusSchema = z.enum(['unused', 'used', 'expired', 'banned'])

export const cardSchema = z.object({
  id: z.union([z.string(), z.number()]),
  card_key: z.string(),
  application_id: z.union([z.string(), z.number()]),
  card_type_id: z.union([z.string(), z.number()]),
  status: cardStatusSchema,
  used_at: z.string().optional().nullable(),
  expire_at: z.string().optional().nullable(),
  created_at: z.string(),
  updated_at: z.string().optional(),
  application: z.object({
    id: z.union([z.string(), z.number()]),
    name: z.string(),
  }).optional(),
  card_type: z.object({
    id: z.union([z.string(), z.number()]),
    name: z.string(),
    price: z.number(),
    value: z.number(),
    billing_type: z.string(),
  }).optional(),
  creator: z.object({
    id: z.union([z.string(), z.number()]),
    username: z.string(),
  }).optional(),
  app_user: z.object({
    id: z.union([z.string(), z.number()]),
    username: z.string(),
  }).optional().nullable(),
})

export type Card = z.infer<typeof cardSchema>
