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

export interface AssetTagInterface {
  name: string;
  normalized: string;
  created?: Date;
  modified?: Date;
  deleted?: Date;
  id?: any;
  customerId?: any;
  customer?: Customer;
  trackingLogs?: Log[];
}

export class AssetTag implements AssetTagInterface {
  name: string;
  normalized: string;
  created: Date;
  modified: Date;
  deleted: Date;
  id: any;
  customerId: any;
  customer?: Customer;
  trackingLogs?: Log[];
  constructor(data?: AssetTagInterface) {
    Object.assign(this, data);
  }

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

  /**
   * @method factory
   * @author Jonathan Casarrubias
   * @license MIT
   * This method creates an instance of AssetTag for dynamic purposes.
   */
  public static factory(data: AssetTagInterface): AssetTag{
    return new AssetTag(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: 'AssetTag',
      plural: 'AssetTags',
      path: 'AssetTags',
      idName: 'id',
      properties: {
        name: {
          name: 'name',
          type: 'string'
        },
        normalized: {
          name: 'normalized',
          type: 'string'
        },
        created: {
          name: 'created',
          type: 'Date'
        },
        modified: {
          name: 'modified',
          type: 'Date'
        },
        deleted: {
          name: 'deleted',
          type: 'Date',
          default: undefined
        },
        id: {
          name: 'id',
          type: 'any'
        },
        customerId: {
          name: 'customerId',
          type: 'any'
        },
      },
      relations: {
        customer: {
          name: 'customer',
          type: 'Customer',
          model: 'Customer',
          relationType: 'belongsTo',
          keyFrom: 'customerId',
          keyTo: 'id'
        },
        trackingLogs: {
          name: 'trackingLogs',
          type: 'Log[]',
          model: 'Log',
          relationType: 'hasMany',
          keyFrom: 'id',
          keyTo: 'trackingModelId'
        },
      }
    };
  }
}
