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

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

export enum ActionType {
  ReadAllByCrawler = '[meta.meta-sensor-display-item] ReadAllByCrawler',
  ReadAllByCrawlerSuccess = '[meta.meta-sensor-display-item] ReadAllByCrawlerSuccess',
  ReadAllByCrawlerFailure = '[meta.meta-sensor-display-item] ReadAllByCrawlerFailure',
}

export class ReadAllByCrawler implements Action {
  readonly type = ActionType.ReadAllByCrawler;
  constructor(public payload: MetaCrawler) {}
}

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

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

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

  constructor(public payload: RPCClientError) {}
}

export type Actions =
  | ReadAllByCrawler
  | ReadAllByCrawlerSuccess
  | ReadAllByCrawlerFailure
;
