import BaseNormalizer from '~/services/serializer/normalizer/baseNormalizer'
import {DataPersisterArgs} from '~/types/interfaces'
import { QUERY_TYPE } from '~/types/enums'

/**
 * @category Services/serializer/normalizer
 * @class Default
 * Classe assurant la normalization par défaut
 */
class Default extends BaseNormalizer {
  static support (type: QUERY_TYPE): boolean {
    return type === QUERY_TYPE.DEFAULT
  }

  /**
   * On renvoi les datas a persister
   * @param {DataPersisterArgs} args
   * @return {any} réponse
   */
  public static normalize (args: DataPersisterArgs): any {
    if (!args.data) {
      throw new Error('*args* has no data attribute')
    }

    return args.data
  }
}
export default Default
