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

export interface SummaryForAssetInterface {
  id?: string;
  type: string;
  from: Date;
  to: Date;
  length: number;
  detail: any;
  updated: boolean;
  created?: Date;
  modified?: Date;
  deleted?: Date;
  assetId?: any;
  summaryForProjectId?: string;
  trackingLogs?: Log[];
  asset?: Asset;
  summaries?: Summary[];
  summaryForProject?: SummaryForProject;
}

export class SummaryForAsset implements SummaryForAssetInterface {
  id: string;
  type: string;
  from: Date;
  to: Date;
  length: number;
  detail: any;
  updated: boolean;
  created: Date;
  modified: Date;
  deleted: Date;
  assetId: any;
  summaryForProjectId: string;
  trackingLogs?: Log[];
  asset?: Asset;
  summaries?: Summary[];
  summaryForProject?: SummaryForProject;
  constructor(data?: SummaryForAssetInterface) {
    Object.assign(this, data);
  }

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

  /**
   * @method factory
   * @author Jonathan Casarrubias
   * @license MIT
   * This method creates an instance of SummaryForAsset for dynamic purposes.
   */
  public static factory(data: SummaryForAssetInterface): SummaryForAsset{
    return new SummaryForAsset(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: 'SummaryForAsset',
      plural: 'SummaryForAssets',
      path: 'SummaryForAssets',
      idName: 'id',
      properties: {
        id: {
          name: 'id',
          type: 'string'
        },
        type: {
          name: 'type',
          type: 'string'
        },
        from: {
          name: 'from',
          type: 'Date'
        },
        to: {
          name: 'to',
          type: 'Date'
        },
        length: {
          name: 'length',
          type: 'number'
        },
        detail: {
          name: 'detail',
          type: 'any'
        },
        updated: {
          name: 'updated',
          type: 'boolean'
        },
        created: {
          name: 'created',
          type: 'Date'
        },
        modified: {
          name: 'modified',
          type: 'Date'
        },
        deleted: {
          name: 'deleted',
          type: 'Date',
          default: undefined
        },
        assetId: {
          name: 'assetId',
          type: 'any'
        },
        summaryForProjectId: {
          name: 'summaryForProjectId',
          type: 'string'
        },
      },
      relations: {
        trackingLogs: {
          name: 'trackingLogs',
          type: 'Log[]',
          model: 'Log',
          relationType: 'hasMany',
          keyFrom: 'id',
          keyTo: 'trackingModelId'
        },
        asset: {
          name: 'asset',
          type: 'Asset',
          model: 'Asset',
          relationType: 'belongsTo',
          keyFrom: 'assetId',
          keyTo: 'id'
        },
        summaries: {
          name: 'summaries',
          type: 'Summary[]',
          model: 'Summary',
          relationType: 'hasMany',
          keyFrom: 'id',
          keyTo: 'summaryForAssetId'
        },
        summaryForProject: {
          name: 'summaryForProject',
          type: 'SummaryForProject',
          model: 'SummaryForProject',
          relationType: 'belongsTo',
          keyFrom: 'summaryForProjectId',
          keyTo: 'id'
        },
      }
    };
  }
}
