const axios = require('axios')
 exports.verifyCaptcha = (recaptchaValue) =>
 {
  const verifyUrl = process.env.RECAPTCHA_VERIFY_URL;
  const ReCAPTCHASecret = process.env.RECAPTCHA_SECRET
    return axios.get(verifyUrl, {
        params: { secret: ReCAPTCHASecret, response: recaptchaValue }
      })
        
};

exports.setAuthorizationHeader = (token = null) => {
  if (token) {
    axios.defaults.headers.common.authorization = `Bearer ${token}`;
  } else {
    delete axios.defaults.headers.common.authorization;
  }
};


exports.setAuthorizationHeaderForIID = (token = null) => {
  if (token) {
    axios.defaults.headers.common.authorization = `key=${token}`;
  } else {
    delete axios.defaults.headers.common.authorization;
  }
};

//https://www.google.com/recaptcha/api/siteverify?secret=6LeNK3QUAAAAACR2Y6Rx98hBKTtomtjETRqffKPM&response=03AMGVjXjw6EQMFg9ZIqwT8OEXgupun-bYxZRZ6iC6SNpO2YRw1cfFBi6eMKelpTgE8l91__TCCowcUq4vhIr890XSs2WSTTx_hFNAW2YFFY6kxjIT9U2EIWp47F7GqQGwcJBtogIok7gDPS4qp1qqk37fUiIQnvtCJUCwCDnGkyr0_ecxixq4tR0pl9wu56zwCRi-WXFiZhvN7rCzZbbpL7TQfJvh5Mz3JqnV2WbtR4MP-YIJl226Ec7BZewqbSFYYl6alkR2JuXN5i8lWhRYxa6VQcDb_vPEPw