import { z } from "zod";

import {
  arrayOrEmpty,
  booleanOrFalse,
  numberOrZero,
  stringOrEmpty,
} from "../../nullable-defaults";
import { PrivateAlbumImageSchema } from "../private_album";

export const PrivateAlbumUnlockReasonSchema = z.enum([
  "ok",
  "already_unlocked",
  "insufficient_credits",
  "cost_changed",
  "unlock_in_progress",
  "deduct_failed",
  "persist_failed_refunded",
  "not_found",
]);

export const PrivateAlbumUnlockResponseSchema = z.object({
  albumId: stringOrEmpty,
  locked: booleanOrFalse,
  unlocked: booleanOrFalse,
  reason: PrivateAlbumUnlockReasonSchema.or(stringOrEmpty),
  unlockCost: numberOrZero,
  requiredCredits: numberOrZero,
  creditBalance: numberOrZero,
  shortfallCredits: numberOrZero,
  images: arrayOrEmpty(PrivateAlbumImageSchema),
});

export type PrivateAlbumUnlockReason = z.output<
  typeof PrivateAlbumUnlockReasonSchema
>;
export type PrivateAlbumUnlockResponseInput = z.input<
  typeof PrivateAlbumUnlockResponseSchema
>;
export type PrivateAlbumUnlockResponseData = z.output<
  typeof PrivateAlbumUnlockResponseSchema
>;
