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

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


export enum ActionType {
  ReadAllByCrawler = '[meta.sensor-display-item] ReadAllByCrawler',
  ReadAllByCrawlerSuccess = '[meta.sensor-display-item] ReadAllByCrawlerSuccess',
  ReadAllByCrawlerFailure = '[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

;
