/**
 * This file is generated by the SwaggerTSGenerator.
 * Do not edit.
*/
/* tslint:disable */
{{#if generateClasses}}
import { BaseModel } from '{{type.pathToRoot}}{{baseModelFileName}}';
import { SubTypeFactory } from '{{type.pathToRoot}}{{subTypeFactoryFileName}}';
{{/if}}

{{#with type}}
    {{#if isSubType}}
import { I{{baseType.typeName}}, {{baseType.typeName}} } from '{{baseImportFile}}';
    {{/if}}
{{#templateImportTypes}}
import { I{{importType}}, {{importType}} } from '{{importFile}}';
{{/templateImportTypes}}
{{#templateImportEnumTypes}}
import { {{importEnumType}} } from '{{../../enumRef}}';
{{/templateImportEnumTypes}}

{{#if ../generateClasses}}
export interface I{{{typeName}}} {{#if isSubType}}extends I{{{baseType.typeName}}}{{/if}}{
{{else}}
export interface {{{typeName}}} {
{{/if}}
{{#properties}}
    {{name}}{{#unless validators.validation.required}}?{{/unless}}: {{{interfaceTypeName}}};
{{/properties}}
}

{{#if ../generateClasses}}

export class {{{typeName}}} extends {{#if isSubType}}{{{baseType.typeName}}}{{else}}BaseModel{{/if}} implements I{{{typeName}}}  {
{{#if hasSubTypeProperty}}
    static {{{../subTypePropertyConstantName}}} = '{{{fullTypeName}}}';
{{/if}}

{{#properties}}
    static {{staticFieldName}} = '{{name}}';
{{/properties}}

{{#properties}}
    {{#if description}}
    /** {{{description}}} */
    {{/if}}
    {{name}}: {{{typeName}}};
{{/properties}}

    /**
     * constructor
     * @param values Can be used to set a webapi response or formValues to this newly constructed model
    */
    constructor(values?: Partial<I{{{typeName}}}>) {
        super();
{{#if hasSubTypeProperty}}

        this.{{{../subTypePropertyName}}} = {{{typeName}}}.{{{../subTypePropertyConstantName}}};
{{/if}}
{{#properties}}
    {{#if isComplexType}}
        this.{{name}} = new {{{templateTypeNameForInstantiation}}}(); {{#if type.isBaseType}}// baseTypes should not be instantiated{{/if}}
    {{/if}}
{{/properties}}

        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<I{{{typeName}}}>): void {
        if (values) {
            {{#if isSubType}}super.setValues(values){{/if}}
            const rawValues = values
{{#properties}}
    {{#if isArray}}
            this.fillModelArray<{{arrayInterfaceTypeName}}>(this, {{../fullTypeName}}.{{staticFieldName}}, rawValues.{{name}}{{#if isArrayComplexType}}, {{templateTypeNameForComplexArray}}, SubTypeFactory.createSubTypeInstance{{/if}});
    {{else}}
        {{#if isComplexType}}
            {{#if templateUseInstantiateSubType}}
            if (rawValues.{{name}} && rawValues.{{name}}.{{{../../subTypePropertyName}}} &&
                this.{{name}}.{{{../../subTypePropertyName}}} !== rawValues.{{name}}.{{{../../subTypePropertyName}}}) {
                this.{{name}} = SubTypeFactory.createSubTypeInstance(rawValues.{{name}}) as {{typeName}};
            }
            {{/if}}
            this.{{name}}.setValues(rawValues.{{name}});
        {{else}}
            this.{{name}} = this.getValue<{{typeName}}>(rawValues, {{../fullTypeName}}.{{staticFieldName}});
        {{/if}}
    {{/if}}
{{/properties}}
        }
    }
}
{{/if}}
{{/with}}
