import { getKeyValue } from '../../../helpers/get-key-value';
import { getErrorObject } from '../../../helpers/get-error-object'; 

import { transformSection } from './items/section';
import { transformText } from './items/text';
import { transformImage } from './items/image';
import { transformOptions } from './items/select';

const methods: { [key: string]: Function } = {
  section: transformSection,
  text: transformText,
  image: transformImage,
  button: transformOptions,
  select: transformOptions,
  radio: transformOptions,
  checkbox: transformOptions
};

export const getMethods = (type: string): Function => {
  return getKeyValue(methods)(type) || getErrorObject({ type, message: 'Generic to Salesforce' });
};

export { methods };
