feat(data): add paywall payment APIs
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 支付套餐 DTO
|
||||
*/
|
||||
import {
|
||||
PaymentPlanSchema,
|
||||
type PaymentPlanData,
|
||||
type PaymentPlanInput,
|
||||
} from "@/data/schemas/payment/payment_plan";
|
||||
|
||||
export class PaymentPlan {
|
||||
declare readonly planId: string;
|
||||
declare readonly planName: string;
|
||||
declare readonly orderType: string;
|
||||
declare readonly amountCents: number;
|
||||
declare readonly currency: string;
|
||||
declare readonly vipDays: number | null;
|
||||
declare readonly dolAmount: number | null;
|
||||
|
||||
private constructor(input: PaymentPlanInput) {
|
||||
const data = PaymentPlanSchema.parse(input);
|
||||
Object.assign(this, data);
|
||||
Object.freeze(this);
|
||||
}
|
||||
|
||||
static from(input: PaymentPlanInput): PaymentPlan {
|
||||
return new PaymentPlan(input);
|
||||
}
|
||||
|
||||
static fromJson(json: unknown): PaymentPlan {
|
||||
return PaymentPlan.from(json as PaymentPlanInput);
|
||||
}
|
||||
|
||||
toJson(): PaymentPlanData {
|
||||
return PaymentPlanSchema.parse(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user