import { SchemaModel } from '@verb/src/libs/shared/base/base.model'; import { SubSchema } from '@verb/src/libs/shared/json-schema-validator/schema-types'; export class HostPaymentModel implements SchemaModel { public vendor: Vendor = 'stripe'; public transactionId = ''; public amount = 0; public currency = 'usd'; public createdAt = new Date(); public constructor(schema?: HostPaymentSchema) { if (schema) { this.fromSchema(schema); } } public fromSchema(schema: HostPaymentSchema) { this.vendor = schema.vendor; this.transactionId = schema.transaction_id; this.amount = schema.amount; this.currency = schema.currency; this.createdAt = new Date(schema.created_at); } public toSchema(): HostPaymentSchema { return { amount: this.amount, created_at: this.createdAt.toUTCString(), currency: this.currency, transaction_id: this.transactionId, vendor: this.vendor, }; } } export type Vendor = 'stripe' | 'verb'; export interface HostPaymentSchema { amount: number; created_at: string; currency: string; transaction_id: string; vendor: Vendor; } export const hostPaymentValidationSchema: SubSchema = { additionalProperties: false, description: 'Host Payment Validation Schema', properties: { amount: { description: 'Host payment amount', type: 'number', }, created_at: { description: 'Date of transaction', type: 'string', }, currency: { description: 'Host payment currency type', minLength: 1, type: 'string', }, transaction_id: { description: 'Transaction ID from vendor', minLength: 1, type: 'string', }, vendor: { description: 'Host payment vendor name', enum: ['stripe', 'verb'], type: 'string', }, }, required: ['vendor', 'transaction_id', 'amount', 'currency', 'created_at'], type: 'object', };