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

import { RPCClientError } from '@loafer/ng-rpc/protocol';

import { Domain } from '@overflow/commons-typescript/model/domain';

import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth';

export enum ActionType {
  ReadAllByDomain = '[noauth-proboe.noauth-proboe] ReadAllByDomain',
  ReadAllByDomainSuccess = '[noauth-proboe.noauth-proboe] ReadAllByDomainSuccess',
  ReadAllByDomainFailure = '[noauth-proboe.noauth-proboe] ReadAllByDomainFailure',

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

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

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

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

  constructor(public payload: Domain) {}
}

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

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

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

  constructor(public payload: RPCClientError) {}
}

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

  constructor(public payload: NoAuthProbe) {}
}

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: NoAuthProbe) {}
}

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 =
  | ReadAllByDomain
  | ReadAllByDomainSuccess
  | ReadAllByDomainFailure
  | Accept
  | AcceptSuccess
  | AcceptFailure
  | Deny
  | DenySuccess
  | DenyFailure
  | OnConnect
  | OnDisconnect
;
