/**
 * PushNotification Actions
 */

import { Action } from '@ngrx/store';
import { LastResult } from '../app-store.domain';
import { PushNotification, PushNotificationSend, PushNotificationTag } from './push-notifications.domain';

export namespace PushNotificationsActions {
  export enum Type {
    // Actions that alter the store in JavaScript Memory
    AddAll = 'PushNotifications/AddAll',
    AddMany = 'PushNotifications/AddAll',
    AddOne = 'PushNotifications/AddOne',
    ClearCurrentId = 'PushNotifications/ClearCurrentId',
    RemoveAll = 'PushNotifications/RemoveAll',
    RemoveMany = 'PushNotifications/RemoveMany',
    RemoveOne = 'PushNotifications/RemoveOne',
    ReportLastResult = 'PushNotifications/ReportLastResult',
    SetCurrentId = 'PushNotifications/SetCurrentId',
    TakeNoAction = 'PushNotifications/TakeNoAction',
    UpdateMany = 'PushNotifications/UpdateMany',
    UpdateOne = 'PushNotifications/UpdateOne',
    UpsertMany = 'PushNotifications/UpsertMany',
    UpsertOne = 'PushNotifications/UpsertOne',

    // Asynchronous Remote Actions
    CreateOneRemoteFailure = 'PushNotifications/CreateOneRemoteFailure',
    CreateOneRemoteRequest = 'PushNotifications/CreateOneRemoteRequest',
    CreateOneRemoteSuccess = 'PushNotifications/CreateOneRemoteSuccess',
    DeleteUserTagsFailure = 'PushNotifications/DeleteUserTagsFailure',
    DeleteUserTagsRequest = 'PushNotifications/DeleteUserTagsRequest',
    DeleteUserTagsSuccess = 'PushNotifications/DeleteUserTagsSuccess',
    FetchAllRemoteFailure = 'PushNotifications/FetchAllRemoteFailure',
    FetchAllRemoteRequest = 'PushNotifications/FetchAllRemoteRequest',
    FetchAllRemoteSuccess = 'PushNotifications/FetchAllRemoteSuccess',
    FetchOneRemoteFailure = 'PushNotifications/FetchOneRemoteFailure',
    FetchOneRemoteRequest = 'PushNotifications/FetchOneRemoteRequest',
    FetchOneRemoteSuccess = 'PushNotifications/FetchOneRemoteSuccess',
    InitFailure = 'PushNotifications/InitFailure',
    InitRequest = 'PushNotifications/InitRequest',
    InitSuccess = 'PushNotifications/InitSuccess',
    SendUserTagsFailure = 'PushNotifications/SendUserTagsFailure',
    SendUserTagsRequest = 'PushNotifications/SendUserTagsRequest',
    SendUserTagsSuccess = 'PushNotifications/SendUserTagsSuccess',
    SubscribeFailure = 'PushNotifications/SubscribeFailure',
    SubscribeRequest = 'PushNotifications/SubscribeRequest',
    SubscribeSuccess = 'PushNotifications/SubscribeSuccess',
    UnsubscribeFailure = 'PushNotifications/UnsubscribeFailure',
    UnsubscribeRequest = 'PushNotifications/UnsubscribeRequest',
    UnsubscribeSuccess = 'PushNotifications/UnsubscribeSuccess',
  }

  /**
   * Actions that alter the store in JavaScript Memory
   */
  export class AddAll implements Action {
    readonly type = Type.AddAll;

    constructor(readonly payload: PushNotification[]) {
    }
  }

  export class AddMany implements Action {
    readonly type = Type.AddMany;

    constructor(readonly payload: PushNotification[]) {
    }
  }

  export class AddOne implements Action {
    readonly type = Type.AddOne;

    constructor(readonly payload: PushNotification) {
    }
  }

  export class ClearCurrentId implements Action {
    readonly type = Type.ClearCurrentId;
  }

  export class RemoveAll implements Action {
    readonly type = Type.RemoveAll;
  }

  export class RemoveMany implements Action {
    readonly type = Type.RemoveMany;

    constructor(readonly payload: number[]) {
    }
  }

  export class RemoveOne implements Action {
    readonly type = Type.RemoveOne;

    constructor(readonly payload: number) {
    }
  }

  export class ReportLastResult implements Action {
    readonly type = Type.ReportLastResult;

    constructor(readonly payload: LastResult) {
    }
  }

  export class SetCurrentId implements Action {
    readonly type = Type.SetCurrentId;
    constructor(readonly payload: number) {}
  }

  export class TakeNoAction implements Action {
    readonly type = Type.TakeNoAction;
  }

  export class UpdateMany implements Action {
    readonly type = Type.UpdateMany;

    constructor(readonly payload: PushNotification[]) {
    }
  }

  export class UpdateOne implements Action {
    readonly type = Type.UpdateOne;

    constructor(readonly payload: PushNotification) {
    }
  }

  export class UpsertMany implements Action {
    readonly type = Type.UpsertMany;

    constructor(readonly payload: PushNotification[]) {
    }
  }

  export class UpsertOne implements Action {
    readonly type = Type.UpsertOne;

    constructor(readonly payload: PushNotification) {
    }
  }

  /**
   * Asynchronous Remote Actions
   */
  export class CreateOneRemoteFailure implements Action {
    readonly type = Type.CreateOneRemoteFailure;

    constructor(readonly payload: any, readonly token?: string) {
    }
  }

  export class CreateOneRemoteRequest implements Action {
    readonly type = Type.CreateOneRemoteRequest;

    constructor(readonly payload: PushNotificationSend, readonly token?: string) {
    }
  }

  export class CreateOneRemoteSuccess implements Action {
    readonly type = Type.CreateOneRemoteSuccess;

    constructor(readonly payload: PushNotification, readonly token?: string) {
    } // TODO: Check
  }

  export class DeleteUserTagsFailure implements Action {
    readonly type = Type.DeleteUserTagsFailure;

    constructor(readonly payload: any) {
    }
  }

  export class DeleteUserTagsRequest implements Action {
    readonly type = Type.DeleteUserTagsRequest;
  }

  export class DeleteUserTagsSuccess implements Action {
    readonly type = Type.DeleteUserTagsSuccess;
  }

  export class FetchAllRemoteFailure implements Action {
    readonly type = Type.FetchAllRemoteFailure;

    constructor(readonly payload: any, readonly token?: string) {
    }
  }

  export class FetchAllRemoteRequest implements Action {
    readonly type = Type.FetchAllRemoteRequest;

    constructor(readonly token?: string) {
    }
  }

  export class FetchAllRemoteSuccess implements Action {
    readonly type = Type.FetchAllRemoteSuccess;

    constructor(readonly payload: PushNotification[], readonly token?: string) {
    }
  }

  export class FetchOneRemoteFailure implements Action {
    readonly type = Type.FetchOneRemoteFailure;

    constructor(readonly payload: any, readonly token?: string) {
    }
  }

  export class FetchOneRemoteRequest implements Action {
    readonly type = Type.FetchOneRemoteRequest;

    constructor(readonly payload: PushNotification, readonly token?: string) {
    }
  }

  export class FetchOneRemoteSuccess implements Action {
    readonly type = Type.FetchOneRemoteSuccess;

    constructor(readonly payload: PushNotification, readonly token?: string) {
    }
  }

  export class InitFailure implements Action {
    readonly type = Type.InitFailure;

    constructor(readonly payload: any) {
    }
  }

  export class InitRequest implements Action {
    readonly type = Type.InitRequest;
  }

  export class InitSuccess implements Action {
    readonly type = Type.InitSuccess;
  }

  export class SendUserTagsFailure implements Action {
    readonly type = Type.SendUserTagsFailure;

    constructor(readonly payload: any) {
    }
  }

  export class SendUserTagsRequest implements Action {
    readonly type = Type.SendUserTagsRequest;

    constructor(readonly payload: PushNotificationTag[]) {
    }
  }

  export class SendUserTagsSuccess implements Action {
    readonly type = Type.SendUserTagsSuccess;

    constructor(readonly payload: PushNotificationTag[]) {
    }
  }

  export class SubscribeFailure implements Action {
    readonly type = Type.SubscribeFailure;

    constructor(readonly payload: any) {
    }
  }

  export class SubscribeRequest implements Action {
    readonly type = Type.SubscribeRequest;
  }

  export class SubscribeSuccess implements Action {
    readonly type = Type.SubscribeSuccess;
  }

  export class UnsubscribeFailure implements Action {
    readonly type = Type.UnsubscribeFailure;

    constructor(readonly payload: any) {
    }
  }

  export class UnsubscribeRequest implements Action {
    readonly type = Type.UnsubscribeRequest;
  }

  export class UnsubscribeSuccess implements Action {
    readonly type = Type.UnsubscribeSuccess;
  }

  export type Union
    // Actions that alter the store in JavaScript Memory
    = AddAll
    | AddMany
    | AddOne
    | ClearCurrentId
    | RemoveAll
    | RemoveMany
    | RemoveOne
    | ReportLastResult
    | SetCurrentId
    | TakeNoAction
    | UpdateMany
    | UpdateOne
    | UpsertMany
    | UpsertOne

    // Asynchronous Remote Actions
    | CreateOneRemoteFailure
    | CreateOneRemoteRequest
    | CreateOneRemoteSuccess
    | DeleteUserTagsFailure
    | DeleteUserTagsRequest
    | DeleteUserTagsSuccess
    | FetchAllRemoteFailure
    | FetchAllRemoteRequest
    | FetchAllRemoteSuccess
    | FetchOneRemoteFailure
    | FetchOneRemoteRequest
    | FetchOneRemoteSuccess
    | InitFailure
    | InitRequest
    | InitSuccess
    | SendUserTagsFailure
    | SendUserTagsRequest
    | SendUserTagsSuccess
    | SubscribeFailure
    | SubscribeRequest
    | SubscribeSuccess
    | UnsubscribeFailure
    | UnsubscribeRequest
    | UnsubscribeSuccess;
}

