All files rest.js

66.66% Statements 16/24
100% Branches 0/0
53.84% Functions 7/13
66.66% Lines 16/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64    2x 6x             2x 3x   3x     2x           2x 3x   3x     2x                 2x                 2x 1x   1x     2x           2x          
import axios from 'axios';
 
export const apiUpdateActiveDotbotAddress = async (address) => {
  return await axios.put(
    `${process.env.REACT_APP_DOTBOTS_BASE_URL}/controller/dotbot_address`,
    { address: address },
    { headers: { 'Content-Type': 'application/json' } }
  );
}
 
export const apiFetchDotbots = async () => {
  return await axios.get(
    `${process.env.REACT_APP_DOTBOTS_BASE_URL}/controller/dotbots`,
  ).then(res => res.data);
}
 
export const apiFetchDotbot = async (address) => {
    return await axios.get(
      `${process.env.REACT_APP_DOTBOTS_BASE_URL}/controller/dotbots/${address}`,
    ).then(res => res.data);
  }
 
export const apiFetchActiveDotbotAddress = async () => {
  return await axios.get(
    `${process.env.REACT_APP_DOTBOTS_BASE_URL}/controller/dotbot_address`,
  ).then(res => res.data.address);
}
 
export const apiUpdateMoveRaw = async (address, left, right) => {
  const command = { left_x: 0, left_y: left, right_x: 0, right_y: right };
  return await axios.put(
    `${process.env.REACT_APP_DOTBOTS_BASE_URL}/controller/dotbots/${address}/move_raw`,
    command,
    { headers: { 'Content-Type': 'application/json' } }
  );
}
 
export const apiUpdateRgbLed = async (address, red, green, blue) => {
  const command = { red: red, green: green, blue: blue };
  return await axios.put(
    `${process.env.REACT_APP_DOTBOTS_BASE_URL}/controller/dotbots/${address}/rgb_led`,
    command,
    { headers: { 'Content-Type': 'application/json' } }
  );
}
 
export const apiFetchLH2CalibrationState = async () => {
  return await axios.get(
    `${process.env.REACT_APP_DOTBOTS_BASE_URL}/controller/lh2/calibration`,
  ).then(res => res.data);
}
 
export const apiApplyLH2Calibration = async () => {
  return await axios.put(
    `${process.env.REACT_APP_DOTBOTS_BASE_URL}/controller/lh2/calibration`,
  );
}
 
export const apiAddLH2CalibrationPoint = async (index) => {
  return await axios.post(
    `${process.env.REACT_APP_DOTBOTS_BASE_URL}/controller/lh2/calibration/${index}`,
  );
}