import {ModelDefinition} from './BaseModels';
import {Log} from './Log';
declare var Object: any;

export interface EventTypeInterface {
  type: string;
  name: string;
  description?: string;
  allowFiles?: boolean;
  created?: Date;
  modified?: Date;
  deleted?: Date;
  id?: any;
  trackingLogs?: Log[];
}

export class EventType implements EventTypeInterface {
  type: string;
  name: string;
  description: string;
  allowFiles: boolean;
  created: Date;
  modified: Date;
  deleted: Date;
  id: any;
  trackingLogs?: Log[];
  constructor(data?: EventTypeInterface) {
    Object.assign(this, data);
  }

  /**
   * The name of the model represented by this $resource,
   * i.e. `EventType`.
   */
  public static getModelName(): string {
    return 'EventType';
  }

  /**
   * @method factory
   * @author Jonathan Casarrubias
   * @license MIT
   * This method creates an instance of EventType for dynamic purposes.
   */
  public static factory(data: EventTypeInterface): EventType{
    return new EventType(data);
  }

  /**
   * @method getModelDefinition
   * @author Julien Ledun
   * @license MIT
   * This method returns an object that represents some of the model
   * definitions.
   */
  public static getModelDefinition(): ModelDefinition {
    return {
      name: 'EventType',
      plural: 'EventTypes',
      path: 'EventTypes',
      idName: 'id',
      properties: {
        type: {
          name: 'type',
          type: 'string'
        },
        name: {
          name: 'name',
          type: 'string'
        },
        description: {
          name: 'description',
          type: 'string'
        },
        allowFiles: {
          name: 'allowFiles',
          type: 'boolean'
        },
        created: {
          name: 'created',
          type: 'Date'
        },
        modified: {
          name: 'modified',
          type: 'Date'
        },
        deleted: {
          name: 'deleted',
          type: 'Date',
          default: undefined
        },
        id: {
          name: 'id',
          type: 'any'
        },
      },
      relations: {
        trackingLogs: {
          name: 'trackingLogs',
          type: 'Log[]',
          model: 'Log',
          relationType: 'hasMany',
          keyFrom: 'id',
          keyTo: 'trackingModelId'
        },
      }
    };
  }
}
