import { DATA_URL, PROCEDURES } from 'config'
import { callApi, getResponseData } from 'helpers'

const proc = PROCEDURES.param_lexical

export type Translation = {
  id: string,
  lang: string,
  lexis_lang_id: string,
  text: string,
}

export type Translations = {[id: string]: Translation}

export const getLexics = (lang: string, lexicIds: Array<number>): Promise<Translations> => {
  const config = {
    body: {
      params: {
        _p_lang: lang,
        _p_param_arr: lexicIds,
      },
      proc,
    },
  }

  return callApi({
    config,
    url: DATA_URL,
  }).then(getResponseData(proc))
}
