import { Action } from '@ngrx/store';

import { RPCClientError } from '@loafer/ng-rpc';
import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth';

export enum ActionType {
  ReadAllByDomainID = '[noauth-probe.noauth-probe] ReadAllByDomainID',
  ReadAllByDomainIDSuccess = '[noauth-probe.noauth-probe] ReadAllByDomainIDSuccess',
  ReadAllByDomainIDFailure = '[noauth-probe.noauth-probe] ReadAllByDomainIDFailure',

  Accept = '[noauth-probe.noauth-probe] Accept',
  AcceptSuccess = '[noauth-probe.noauth-probe] AcceptSuccess',
  AcceptFailure = '[noauth-probe.noauth-probe] AcceptFailure',

  Deny = '[noauth-probe.noauth-probe] Deny',
  DenySuccess = '[noauth-probe.noauth-probe] DenySuccess',
  DenyFailure = '[noauth-probe.noauth-probe] DenyFailure',

  OnConnect = '[noauth-probe.noauth-probe] OnConnect',
  OnDisconnect = '[noauth-probe.noauth-probe] OnDisconnect',
}

export class ReadAllByDomainID implements Action {
  readonly type = ActionType.ReadAllByDomainID;

  constructor(public payload: number) {}
}

export class ReadAllByDomainIDSuccess implements Action {
  readonly type = ActionType.ReadAllByDomainIDSuccess;

  constructor(public payload: NoAuthProbe[]) {}
}

export class ReadAllByDomainIDFailure implements Action {
  readonly type = ActionType.ReadAllByDomainIDFailure;

  constructor(public payload: RPCClientError) {}
}

export class Accept implements Action {
  readonly type = ActionType.Accept;

  constructor(public payload: number) {}
}

export class AcceptSuccess implements Action {
  readonly type = ActionType.AcceptSuccess;

  constructor(public payload: NoAuthProbe[]) {}
}

export class AcceptFailure implements Action {
  readonly type = ActionType.AcceptFailure;

  constructor(public payload: RPCClientError) {}
}

export class Deny implements Action {
  readonly type = ActionType.Deny;

  constructor(public payload: number) {}
}

export class DenySuccess implements Action {
  readonly type = ActionType.DenySuccess;

  constructor(public payload: NoAuthProbe[]) {}
}

export class DenyFailure implements Action {
  readonly type = ActionType.DenyFailure;

  constructor(public payload: RPCClientError) {}
}

export class OnConnect implements Action {
  readonly type = ActionType.OnConnect;

  constructor(public payload: NoAuthProbe) {}
}

export class OnDisconnect implements Action {
  readonly type = ActionType.OnDisconnect;

  constructor(public payload: NoAuthProbe) {}
}


export type Actions =
  | ReadAllByDomainID
  | ReadAllByDomainIDSuccess
  | ReadAllByDomainIDFailure
  | Accept
  | AcceptSuccess
  | AcceptFailure
  | Deny
  | DenySuccess
  | DenyFailure
  | OnConnect
  | OnDisconnect
;
