import { SchemaModel } from '@verb/src/libs/shared/base/base.model'; export class StreamAttendeeJoinRequestModel implements SchemaModel { public email = ''; public familyName = ''; public givenName = ''; public constructor(streamAttendeeJoinRequestSchema?: StreamAttendeeJoinRequestSchema) { if (streamAttendeeJoinRequestSchema) { this.fromSchema(streamAttendeeJoinRequestSchema); } } public fromSchema(streamAttendeeJoinRequestSchema: StreamAttendeeJoinRequestSchema) { this.email = streamAttendeeJoinRequestSchema.email.trim().toLowerCase(); this.familyName = streamAttendeeJoinRequestSchema.family_name; this.givenName = streamAttendeeJoinRequestSchema.given_name; } public toSchema(): StreamAttendeeJoinRequestSchema { return { email: this.email, family_name: this.familyName, given_name: this.givenName, }; } public validate(): string[] | null { const invalidFields = []; if (!this.givenName || this.givenName.trim().length === 0) { invalidFields.push('given_name'); } if (!this.familyName || this.familyName.trim().length === 0) { invalidFields.push('family_name'); } if (!this.email || this.email.trim().length === 0) { invalidFields.push('email'); } return invalidFields.length ? invalidFields : null; } } export interface StreamAttendeeJoinRequestSchema { email: string; family_name: string; given_name: string; }