feat(data): add paywall payment APIs
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 支付订单状态响应 DTO
|
||||
*/
|
||||
import {
|
||||
PaymentOrderStatusResponseSchema,
|
||||
type PaymentOrderStatus,
|
||||
type PaymentOrderStatusResponseData,
|
||||
type PaymentOrderStatusResponseInput,
|
||||
} from "@/data/schemas/payment/payment_order_status_response";
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user