import Config from "@/config/index.js";

/**
 * 获得机器人token
 * @returns Promise
 */
export function getRobotToken() {
  return fetch(Config.robotBaseUrl + "/abc-robot/caas/oauth/token/v2", {
    method: "POST"
  }).then(res => {
    return res.json();
  });
}

/**
 * 获得机器人设备
 * @returns Promise
 */
export function getRobotClient(data) {
  return fetch(
    Config.robotBaseUrl +
      "/push/v1/app/device?clientId=" +
      data.clientId +
      "&token=" +
      data.token,
    {
      method: "GET"
    }
  ).then(res => {
    return res.json();
  });
}
