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 { StreamLimitsModel, StreamLimitsSchema, streamLimitsValidationSchema, } from '@verb/src/libs/stream/host-metadata/versioning/v1/stream-limits.model'; export class StreamLimitsTemplateModel implements SchemaModel { public clientId = ''; public campaignId = 1; public startDate: string | null = null; public endDate: string | null = null; public limits = new StreamLimitsModel(); public schemaVersion = 1; public constructor(streamLimitsTemplateSchema?: StreamLimitsTemplateSchema) { if (streamLimitsTemplateSchema) { this.fromSchema(streamLimitsTemplateSchema); } } public fromSchema(streamLimitsTemplateSchema: StreamLimitsTemplateSchema): void { this.clientId = streamLimitsTemplateSchema.client_id; this.campaignId = streamLimitsTemplateSchema.campaign_id; this.startDate = streamLimitsTemplateSchema.start_date; this.endDate = streamLimitsTemplateSchema.end_date; this.limits = new StreamLimitsModel(streamLimitsTemplateSchema.limits); this.schemaVersion = streamLimitsTemplateSchema.schema_version; } public toSchema(): StreamLimitsTemplateSchema { return { campaign_id: this.campaignId, client_id: this.clientId, end_date: this.endDate, limits: this.limits.toSchema(), schema_version: this.schemaVersion, start_date: this.startDate, }; } } export interface StreamLimitsTemplateSchema { client_id: string; campaign_id: number; start_date: string | null; end_date: string | null; limits: StreamLimitsSchema; schema_version: number; } export const streamLimitsTemplateValidationSchema: 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 Limits template', properties: { campaign_id: { description: 'Campaign id', type: 'number', }, client_id: { description: 'Client id', type: 'string', }, end_date: { description: 'End date', type: 'string', }, limits: streamLimitsValidationSchema, schema_version: { description: 'Schema version', type: 'number', }, start_date: { description: 'Start date', type: 'string', }, }, required: ['campaign_id', 'client_id', 'end_date', 'limits', 'schema_version', 'start_date'], title: 'Stream Limits Template Schema', type: 'object', };