/** * This file is generated by the SwaggerTSGenerator. * Do not edit. */ /* tslint:disable */ import { BaseModel } from './base-model'; import { SubTypeFactory } from './sub-type-factory'; import { IFlatLimitAmount, FlatLimitAmount } from './flat-limit-amount.model'; import { IRatedLimitAmount, RatedLimitAmount } from './rated-limit-amount.model'; export interface ILimit { amount?: IFlatLimitAmount | IRatedLimitAmount; id?: string; typeSelector?: string; } export class Limit extends BaseModel implements ILimit { static TYPE_SELECTOR = 'Limit'; static AMOUNT_FIELD_NAME = 'amount'; static ID_FIELD_NAME = 'id'; static TYPE_SELECTOR_FIELD_NAME = 'typeSelector'; amount: FlatLimitAmount | RatedLimitAmount; id: string; typeSelector: string; /** * constructor * @param values Can be used to set a webapi response or formValues to this newly constructed model */ constructor(values?: Partial) { super(); this.typeSelector = Limit.TYPE_SELECTOR; this.amount = new FlatLimitAmount(); if (values) { this.setValues(values); } } /** * set the values. * @param values Can be used to set a webapi response to this newly constructed model */ setValues(values: Partial): void { if (values) { const rawValues = values if (rawValues.amount && rawValues.amount.typeSelector && this.amount.typeSelector !== rawValues.amount.typeSelector) { this.amount = SubTypeFactory.createSubTypeInstance(rawValues.amount) as FlatLimitAmount | RatedLimitAmount; } this.amount.setValues(rawValues.amount); this.id = this.getValue(rawValues, Limit.ID_FIELD_NAME); this.typeSelector = this.getValue(rawValues, Limit.TYPE_SELECTOR_FIELD_NAME); } } }