Files
cozsweet-frontend-nextjs/src/data/dto/payment/payment_order_status_response.ts
T

41 lines
1.1 KiB
TypeScript

/**
* 支付订单状态响应 DTO
*/
import {
PaymentOrderStatusResponseSchema,
type PaymentOrderStatus,
type PaymentOrderStatusResponseData,
type PaymentOrderStatusResponseInput,
} from "@/data/schemas/payment/payment_order_status_response";
export type { PaymentOrderStatus };
export class PaymentOrderStatusResponse {
declare readonly orderId: string;
declare readonly status: PaymentOrderStatus;
declare readonly orderType: string;
declare readonly planId: string;
private constructor(input: PaymentOrderStatusResponseInput) {
const data = PaymentOrderStatusResponseSchema.parse(input);
Object.assign(this, data);
Object.freeze(this);
}
static from(
input: PaymentOrderStatusResponseInput,
): PaymentOrderStatusResponse {
return new PaymentOrderStatusResponse(input);
}
static fromJson(json: unknown): PaymentOrderStatusResponse {
return PaymentOrderStatusResponse.from(
json as PaymentOrderStatusResponseInput,
);
}
toJson(): PaymentOrderStatusResponseData {
return PaymentOrderStatusResponseSchema.parse(this);
}
}