import { SchemaModel } from '@verb/src/libs/shared/base/base.model'; import { BASE_DEFINITIONS, BaseSchema, } from '@verb/src/libs/shared/json-schema-validator/schema-types'; import { HostSchema, streamConfigurationValidationSchema, } from '@verb/src/libs/stream/host-metadata'; import { CoreConfigurationModel, CoreConfigurationSchema, } from '@verb/src/libs/stream/host-metadata/versioning/v1/core-configuration.model'; import { HostBillingMetadataResponseModel, HostBillingMetadataResponseSchema, } from '@verb/src/libs/stream/host-metadata/versioning/v1/host-billing-metadata-response.model'; import { HostIdentificationResponseModel, HostIdentificationResponseSchema, } from '@verb/src/libs/stream/host-metadata/versioning/v1/host-identification-metadata-response.model'; import { StreamConfigurationResponseModel, StreamConfigurationResponseSchema, } from '@verb/src/libs/stream/host-metadata/versioning/v1/stream-configuration-response.model'; export class HostMetadataResponseModel implements SchemaModel { public billing = new HostBillingMetadataResponseModel(); public coreConfiguration = new CoreConfigurationModel(); public createdAt = new Date(); public identification = new HostIdentificationResponseModel(); public streamConfiguration = new StreamConfigurationResponseModel(); public constructor(hostSchema?: HostSchema) { if (hostSchema) { this.fromSchema(hostSchema); } } public toSchema(): HostMetadataResponseSchema { return { billing: this.billing.toSchema(), core_configuration: this.coreConfiguration.toSchema(), created_at: this.createdAt.toUTCString(), identification: this.identification.toSchema(), stream_configuration: this.streamConfiguration.toSchema(), }; } public fromSchema(schema: HostSchema): void { this.billing = new HostBillingMetadataResponseModel(schema.billing); this.coreConfiguration = new CoreConfigurationModel(schema.core_configuration); this.createdAt = new Date(schema.created_at); this.identification = new HostIdentificationResponseModel(schema.identification); this.streamConfiguration = new StreamConfigurationResponseModel(schema.stream_configuration); } } export interface HostMetadataResponseSchema { billing: HostBillingMetadataResponseSchema; core_configuration: CoreConfigurationSchema; created_at: string; identification: HostIdentificationResponseSchema; stream_configuration: StreamConfigurationResponseSchema; } export const hostMetadataResponseValidationSchema: BaseSchema = { $id: 'http://myverb.com/stream-metadata.schema.json', $schema: 'http://json-schema.org/draft-07/schema#', additionalProperties: false, definitions: BASE_DEFINITIONS, description: 'Validation Schema for Stream Configuration', properties: { stream_configuration: streamConfigurationValidationSchema, }, required: ['core_configuration', 'stream_configuration'], title: 'Stream Configuration Schema', type: 'object', };