import {ModelDefinition} from './BaseModels';
import {Country} from './Country';
import {Credential} from './Credential';
import {Asset} from './Asset';
import {Log} from './Log';
import {TimeZone} from './TimeZone';
import {Var} from './Var';
declare var Object: any;

export interface AdminInterface {
  name: string;
  surname?: string;
  phone?: string;
  address?: string;
  birthday?: Date;
  created?: Date;
  modified?: Date;
  deleted?: Date;
  otpEnabled?: boolean;
  disabledPasswordLogin?: boolean;
  username?: string;
  email: string;
  emailVerified?: boolean;
  id?: any;
  countryId?: any;
  timeZoneId?: any;
  varId?: any;
  password?: string;
  accessTokens?: any[];
  loginAttempts?: any[];
  country?: Country;
  container?: any;
  credentials?: Credential[];
  assets?: Asset[];
  activityLogs?: Log[];
  trackingLogs?: Log[];
  timeZone?: TimeZone;
  var?: Var;
}

export class Admin implements AdminInterface {
  name: string;
  surname: string;
  phone: string;
  address: string;
  birthday: Date;
  created: Date;
  modified: Date;
  deleted: Date;
  otpEnabled: boolean;
  disabledPasswordLogin: boolean;
  username: string;
  email: string;
  emailVerified: boolean;
  id: any;
  countryId: any;
  timeZoneId: any;
  varId: any;
  password: string;
  accessTokens?: any[];
  loginAttempts?: any[];
  country?: Country;
  container?: any;
  credentials?: Credential[];
  assets?: Asset[];
  activityLogs?: Log[];
  trackingLogs?: Log[];
  timeZone?: TimeZone;
  var?: Var;
  constructor(data?: AdminInterface) {
    Object.assign(this, data);
  }

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

  /**
   * @method factory
   * @author Jonathan Casarrubias
   * @license MIT
   * This method creates an instance of Admin for dynamic purposes.
   */
  public static factory(data: AdminInterface): Admin{
    return new Admin(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: 'Admin',
      plural: 'Admins',
      path: 'Admins',
      idName: 'id',
      properties: {
        name: {
          name: 'name',
          type: 'string'
        },
        surname: {
          name: 'surname',
          type: 'string'
        },
        phone: {
          name: 'phone',
          type: 'string'
        },
        address: {
          name: 'address',
          type: 'string'
        },
        birthday: {
          name: 'birthday',
          type: 'Date'
        },
        created: {
          name: 'created',
          type: 'Date'
        },
        modified: {
          name: 'modified',
          type: 'Date'
        },
        deleted: {
          name: 'deleted',
          type: 'Date',
          default: undefined
        },
        otpEnabled: {
          name: 'otpEnabled',
          type: 'boolean'
        },
        disabledPasswordLogin: {
          name: 'disabledPasswordLogin',
          type: 'boolean'
        },
        username: {
          name: 'username',
          type: 'string'
        },
        email: {
          name: 'email',
          type: 'string'
        },
        emailVerified: {
          name: 'emailVerified',
          type: 'boolean'
        },
        id: {
          name: 'id',
          type: 'any'
        },
        countryId: {
          name: 'countryId',
          type: 'any'
        },
        timeZoneId: {
          name: 'timeZoneId',
          type: 'any'
        },
        varId: {
          name: 'varId',
          type: 'any'
        },
        password: {
          name: 'password',
          type: 'string'
        },
      },
      relations: {
        accessTokens: {
          name: 'accessTokens',
          type: 'any[]',
          model: '',
          relationType: 'hasMany',
          keyFrom: 'id',
          keyTo: 'userId'
        },
        loginAttempts: {
          name: 'loginAttempts',
          type: 'any[]',
          model: '',
          relationType: 'hasMany',
          keyFrom: 'id',
          keyTo: 'userId'
        },
        country: {
          name: 'country',
          type: 'Country',
          model: 'Country',
          relationType: 'belongsTo',
          keyFrom: 'countryId',
          keyTo: 'id'
        },
        container: {
          name: 'container',
          type: 'any',
          model: '',
          relationType: 'hasOne',
          keyFrom: 'id',
          keyTo: 'adminId'
        },
        credentials: {
          name: 'credentials',
          type: 'Credential[]',
          model: 'Credential',
          relationType: 'hasMany',
          modelThrough: 'CredentialAdmin',
          keyThrough: 'credentialId',
          keyFrom: 'id',
          keyTo: 'adminId'
        },
        assets: {
          name: 'assets',
          type: 'Asset[]',
          model: 'Asset',
          relationType: 'hasMany',
          modelThrough: 'AdminAsset',
          keyThrough: 'assetId',
          keyFrom: 'id',
          keyTo: 'adminId'
        },
        activityLogs: {
          name: 'activityLogs',
          type: 'Log[]',
          model: 'Log',
          relationType: 'hasMany',
          keyFrom: 'id',
          keyTo: 'userId'
        },
        trackingLogs: {
          name: 'trackingLogs',
          type: 'Log[]',
          model: 'Log',
          relationType: 'hasMany',
          keyFrom: 'id',
          keyTo: 'trackingModelId'
        },
        timeZone: {
          name: 'timeZone',
          type: 'TimeZone',
          model: 'TimeZone',
          relationType: 'belongsTo',
          keyFrom: 'timeZoneId',
          keyTo: 'id'
        },
        var: {
          name: 'var',
          type: 'Var',
          model: 'Var',
          relationType: 'belongsTo',
          keyFrom: 'varId',
          keyTo: 'id'
        },
      }
    };
  }
}
