/* tslint:disable */
import { Action } from '@ngrx/store';
import { type } from '../util';
import { LoopBackFilter } from '../models/BaseModels';

/**
* @module BaseLoopbackActionTypesFactory
* @author João Ribeiro <@JonnyBGod> <github:JonnyBGod>
* @license MIT
* @description
* Factory function that will be implemented in every custom actions automatically built
* by the sdk builder.
* It provides the core action types for each model to interact with API
**/
export function BaseLoopbackActionTypesFactory(modelName: string): any {
  let types: any = {};

  types['CREATE'] = type('[' + modelName + '] Create');
  types['CREATE_SUCCESS'] = type('[' + modelName + '] Create Success');
  types['CREATE_FAIL'] = type('[' + modelName + '] Create Fail');

  types['CREATE_MANY'] = type('[' + modelName + '] CreateMany');
  types['CREATE_MANY_SUCCESS'] = type('[' + modelName + '] CreateMany Success');
  types['CREATE_MANY_FAIL'] = type('[' + modelName + '] CreateMany Fail');

  types['FIND_BY_ID'] = type('[' + modelName + '] FindById');
  types['FIND_BY_ID_SUCCESS'] = type('[' + modelName + '] FindById Success');
  types['FIND_BY_ID_FAIL'] = type('[' + modelName + '] FindById Fail');

  types['FIND'] = type('[' + modelName + '] Find');
  types['FIND_SUCCESS'] = type('[' + modelName + '] Find Success');
  types['FIND_FAIL'] = type('[' + modelName + '] Find Fail');

  types['FIND_ONE'] = type('[' + modelName + '] FindOne');
  types['FIND_ONE_SUCCESS'] = type('[' + modelName + '] FindOne Success');
  types['FIND_ONE_FAIL'] = type('[' + modelName + '] FindOne Fail');

  types['UPDATE_ALL'] = type('[' + modelName + '] UpdateAll');
  types['UPDATE_ALL_SUCCESS'] = type('[' + modelName + '] UpdateAll Success');
  types['UPDATE_ALL_FAIL'] = type('[' + modelName + '] UpdateAll Fail');

  types['DELETE_BY_ID'] = type('[' + modelName + '] DeleteById');
  types['DELETE_BY_ID_SUCCESS'] = type('[' + modelName + '] DeleteById Success');
  types['DELETE_BY_ID_FAIL'] = type('[' + modelName + '] DeleteById Fail');

  types['UPDATE_ATTRIBUTES'] = type('[' + modelName + '] UpdateAttributes');
  types['UPDATE_ATTRIBUTES_SUCCESS'] = type('[' + modelName + '] UpdateAttributes Success');
  types['UPDATE_ATTRIBUTES_FAIL'] = type('[' + modelName + '] UpdateAttributes Fail');

  types['UPSERT'] = type('[' + modelName + '] Upsert');
  types['UPSERT_SUCCESS'] = type('[' + modelName + '] Upsert Success');
  types['UPSERT_FAIL'] = type('[' + modelName + '] Upsert Fail');

  types['UPSERT_WITH_WHERE'] = type('[' + modelName + '] UpsertWithWhere');
  types['UPSERT_WITH_WHERE_SUCCESS'] = type('[' + modelName + '] UpsertWithWhere Success');
  types['UPSERT_WITH_WHERE_FAIL'] = type('[' + modelName + '] UpsertWithWhere Fail');

  types['REPLACE_OR_CREATE'] = type('[' + modelName + '] ReplaceOrCreate');
  types['REPLACE_OR_CREATE_SUCCESS'] = type('[' + modelName + '] ReplaceOrCreate Success');
  types['REPLACE_OR_CREATE_FAIL'] = type('[' + modelName + '] ReplaceOrCreate Fail');

  types['REPLACE_BY_ID'] = type('[' + modelName + '] ReplaceById');
  types['REPLACE_BY_ID_SUCCESS'] = type('[' + modelName + '] ReplaceById Success');
  types['REPLACE_BY_ID_FAIL'] = type('[' + modelName + '] ReplaceById Fail');

  types['PATCH_OR_CREATE'] = type('[' + modelName + '] PatchOrCreate');
  types['PATCH_OR_CREATE_SUCCESS'] = type('[' + modelName + '] PatchOrCreate Success');
  types['PATCH_OR_CREATE_FAIL'] = type('[' + modelName + '] PatchOrCreate Fail');

  types['PATCH_ATTRIBUTES'] = type('[' + modelName + '] PatchAttributes');
  types['PATCH_ATTRIBUTES_SUCCESS'] = type('[' + modelName + '] PatchAttributes Success');
  types['PATCH_ATTRIBUTES_FAIL'] = type('[' + modelName + '] PatchAttributes Fail');

  types['GUARD_FAIL'] = type('[' + modelName + '] Guard Fail');

  types['RESET_STATE'] = type('[' + modelName + '] Reset State');

  return types;
};

/**
* @module BaseLoopbackActionsFactory
* @author João Ribeiro <@JonnyBGod> <github:JonnyBGod>
* @license MIT
* @description
* Factory function that will be implemented in every custom actions automatically built
* by the sdk builder.
* It provides the core actions for each model to interact with API
**/
export function BaseLoopbackActionsFactory<T>(actionTypes: any): any {
  let actions: any = {};

  /**
   * @method create
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic create action
   */
  actions.create = class implements Action {
    public readonly type = actionTypes['CREATE'];

    constructor(public payload: any, public meta?: any) { }
  };

  /**
   * @method createSuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic createSuccess action
   */
  actions.createSuccess = class implements Action {
    public readonly type = actionTypes['CREATE_SUCCESS'];

    constructor(public payload: T, public meta?: any) { }
  }
  /**
   * @method createFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic createFail action
   */
  actions.createFail = class implements Action {
    public readonly type = actionTypes['CREATE_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method createMany
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic createMany action
   */
  actions.createMany = class implements Action {
    public readonly type = actionTypes['CREATE_MANY'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method createManySuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic createManySuccess action
   */
  actions.createManySuccess = class implements Action {
    public readonly type = actionTypes['CREATE_MANY_SUCCESS'];

    constructor(public payload: T[], public meta?: any) { }
  }
  /**
   * @method createManyFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic createManyFail action
   */
  actions.createManyFail = class implements Action {
    public readonly type = actionTypes['CREATE_MANY_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method findById
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic findById action
   */
  actions.findById = class implements Action {
    public readonly type = actionTypes['FIND_BY_ID'];
    public payload: {id: any, filter: LoopBackFilter};

    constructor(id: any, filter: LoopBackFilter, public meta?: any) {
      this.payload = {id, filter};
    }
  }
  /**
   * @method findByIdSuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic findByIdSuccess action
   */
  actions.findByIdSuccess = class implements Action {
    public readonly type = actionTypes['FIND_BY_ID_SUCCESS'];

    constructor(public payload: T, public meta?: any) { }
  }
  /**
   * @method findByIdFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic findByIdFail action
   */
  actions.findByIdFail = class implements Action {
    public readonly type = actionTypes['FIND_BY_ID_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method find
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic find action
   */
  actions.find = class implements Action {
    public readonly type = actionTypes['FIND'];

    constructor(public payload: LoopBackFilter = {}, public meta?: any) { }
  }
  /**
   * @method findSuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic findSuccess action
   */
  actions.findSuccess = class implements Action {
    public readonly type = actionTypes['FIND_SUCCESS'];

    constructor(public payload: T[], public meta?: any) { }
  }
  /**
   * @method findFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic findFail action
   */
  actions.findFail = class implements Action {
    public readonly type = actionTypes['FIND_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method findOne
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic findOne action
   */
  actions.findOne = class implements Action {
    public readonly type = actionTypes['FIND_ONE'];

    constructor(public payload: LoopBackFilter = {}, public meta?: any) { }
  }
  /**
   * @method findOneSuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic findOneSuccess action
   */
  actions.findOneSuccess = class implements Action {
    public readonly type = actionTypes['FIND_ONE_SUCCESS'];

    constructor(public payload: T, public meta?: any) { }
  }
  /**
   * @method findOneFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic findOneFail action
   */
  actions.findOneFail = class implements Action {
    public readonly type = actionTypes['FIND_ONE_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method updateAll
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic updateAll action
   */
  actions.updateAll = class implements Action {
    public readonly type = actionTypes['UPDATE_ALL'];
    public payload: {where: any, data: any};

    constructor(where: any = {}, data: any, public meta?: any) {
      this.payload = {where, data};
    }
  }
  /**
   * @method updateAllSuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic updateAllSuccess action
   */
  actions.updateAllSuccess = class implements Action {
    public readonly type = actionTypes['UPDATE_ALL_SUCCESS'];

    constructor(public where: any, public data: any, public meta?: any) { }
  }
  /**
   * @method updateAllFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic updateAllFail action
   */
  actions.updateAllFail = class implements Action {
    public readonly type = actionTypes['UPDATE_ALL_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method deleteById
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic deleteById action
   */
  actions.deleteById = class implements Action {
    public readonly type = actionTypes['DELETE_BY_ID'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method deleteByIdSuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic deleteByIdSuccess action
   */
  actions.deleteByIdSuccess = class implements Action {
    public readonly type = actionTypes['DELETE_BY_ID_SUCCESS'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method deleteByIdFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic deleteByIdFail action
   */
  actions.deleteByIdFail = class implements Action {
    public readonly type = actionTypes['DELETE_BY_ID_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method updateAttributes
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic updateAttributes action
   */
  actions.updateAttributes = class implements Action {
    public readonly type = actionTypes['UPDATE_ATTRIBUTES'];
    public payload: {id: any, data: T};

    constructor(id: any, data: T, public meta?: any) {
      this.payload = {id, data};
    }
  }
  /**
   * @method updateAttributesSuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic updateAttributesSuccess action
   */
  actions.updateAttributesSuccess = class implements Action {
    public readonly type = actionTypes['UPDATE_ATTRIBUTES_SUCCESS'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method updateAttributesFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic updateAttributesFail action
   */
  actions.updateAttributesFail = class implements Action {
    public readonly type = actionTypes['UPDATE_ATTRIBUTES_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method upsert
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic upsert action
   */
  actions.upsert = class implements Action {
    public readonly type = actionTypes['UPSERT'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method upsertSuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic upsertSuccess action
   */
  actions.upsertSuccess = class implements Action {
    public readonly type = actionTypes['UPSERT_SUCCESS'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method upsertFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic upsertFail action
   */
  actions.upsertFail = class implements Action {
    public readonly type = actionTypes['UPSERT_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method upsertWithWhere
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic upsertWithWhere action
   */
  actions.upsertWithWhere = class implements Action {
    public readonly type = actionTypes['UPSERT_WITH_WHERE'];
    public payload: {where: any, data: any};

    constructor(where: any = {}, data: any, public meta?: any) {
      this.payload = {where, data};
    }
  }
  /**
   * @method upsertWithWhereSuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic upsertWithWhereSuccess action
   */
  actions.upsertWithWhereSuccess = class implements Action {
    public readonly type = actionTypes['UPSERT_WITH_WHERE_SUCCESS'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method upsertWithWhereFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic upsertWithWhereFail action
   */
  actions.upsertWithWhereFail = class implements Action {
    public readonly type = actionTypes['UPSERT_WITH_WHERE_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method replaceOrCreate
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic replaceOrCreate action
   */
  actions.replaceOrCreate = class implements Action {
    public readonly type = actionTypes['REPLACE_OR_CREATE'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method replaceOrCreateSuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic replaceOrCreateSuccess action
   */
  actions.replaceOrCreateSuccess = class implements Action {
    public readonly type = actionTypes['REPLACE_OR_CREATE_SUCCESS'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method replaceOrCreateFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic replaceOrCreateFail action
   */
  actions.replaceOrCreateFail = class implements Action {
    public readonly type = actionTypes['REPLACE_OR_CREATE_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method replaceById
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic replaceById action
   */
  actions.replaceById = class implements Action {
    public readonly type = actionTypes['REPLACE_BY_ID'];
    public payload: {id: any, data: any};

    constructor(id: any, data: any = {}, public meta?: any) {
      this.payload = {id, data};
    }
  }
  /**
   * @method replaceByIdSuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic replaceByIdSuccess action
   */
  actions.replaceByIdSuccess = class implements Action {
    public readonly type = actionTypes['REPLACE_BY_ID_SUCCESS'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method replaceByIdFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic replaceByIdFail action
   */
  actions.replaceByIdFail = class implements Action {
    public readonly type = actionTypes['REPLACE_BY_ID_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method patchOrCreate
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic patchOrCreate action
   */
  actions.patchOrCreate = class implements Action {
    public readonly type = actionTypes['PATCH_OR_CREATE'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method patchOrCreateSuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic patchOrCreateSuccess action
   */
  actions.patchOrCreateSuccess = class implements Action {
    public readonly type = actionTypes['PATCH_OR_CREATE_SUCCESS'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method patchOrCreateFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic patchOrCreateFail action
   */
  actions.patchOrCreateFail = class implements Action {
    public readonly type = actionTypes['PATCH_OR_CREATE_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method patchAttributes
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic patchAttributes action
   */
  actions.patchAttributes = class implements Action {
    public readonly type = actionTypes['PATCH_ATTRIBUTES'];
    public payload: {id: any, data: any};

    constructor(id: any, data: any = {}, public meta?: any) {
      this.payload = {id, data};
    }
  }
  /**
   * @method patchAttributesSuccess
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic patchAttributesSuccess action
   */
  actions.patchAttributesSuccess = class implements Action {
    public readonly type = actionTypes['PATCH_ATTRIBUTES_SUCCESS'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method patchAttributesFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic patchAttributesFail action
   */
  actions.patchAttributesFail = class implements Action {
    public readonly type = actionTypes['PATCH_ATTRIBUTES_FAIL'];

    constructor(public payload: any, public meta?: any) { }
  }
  /**
   * @method guardFail
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic guardFail action
   */
  actions.guardFail = class implements Action {
    public readonly type = actionTypes['GUARD_FAIL'];
  }
  /**
   * @method resetState
   * @author João Ribeiro <t: JonnyBGod, gh: mean-expert-official>
   * @license MIT
   * @description
   * Generic resetState action
   */
  actions.resetState = class implements Action {
    public readonly type = actionTypes['RESET_STATE'];
  }

  return actions;
};
