import queryString from "query-string";
import { DEFAULT_USER_AGENT } from "../config";

export const genBaidu = async ({ texts, from, to }) => {
  const data = {
    from,
    to,
    query: texts.join(" "),
    source: "txt",
  };

  const input = "https://fanyi.baidu.com/transapi";
  const init = {
    headers: {
      // Origin: "https://fanyi.baidu.com",
      "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
      "User-Agent": DEFAULT_USER_AGENT,
    },
    method: "POST",
    body: queryString.stringify(data),
  };

  return [input, init];
};
