

// tslint:disable-next-line:class-name
import {PeopleModel} from './people.model';
import {UserExtraModel} from './user-extra.model';

export class ApiV1LoginResponse {

  constructor(
    public login: boolean,
    public machineId: string,
    public session: string,
    public sessionExpire: number, // unix timestamp
    public role: string,
    public User: PeopleModel,
    public UserExtra?: UserExtraModel // extra user informaiton
  ) {
    this.login = login;
    this.machineId = machineId;
    this.session = session;
    this.sessionExpire = sessionExpire;
    this.role = role;
    this.User = User;
    this.UserExtra = UserExtra;
  }

  public static EmptyNew(): ApiV1LoginResponse{
    return new ApiV1LoginResponse(
      false, '', '', 0, '', PeopleModel.EmptyNew() );
  }

  public hasValidSession(): boolean {
    if (this.session === undefined  || this.session === '' || this.session === null) {
      return false;
    }else{
      return true;
    }
  }

  public hasValidMachineId(): boolean {
    if (this.machineId === undefined  || this.machineId === '') {
      return false;
    }else{
      return true;
    }
  }
}
