All files / src/controllers/components zeroBounceIntegration.ts

85.71% Statements 12/14
70% Branches 7/10
100% Functions 1/1
84.61% Lines 11/13

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 211x 1x   1x 1x   1x 3x 3x 3x 3x 3x     3x            
import axios from 'axios'
import errorMessages from '../../utils/errorMessages'
 
const zeroBounceAPIKey = process.env.ZERO_BOUNCE_API_KEY ?? "1f8af73bb88048d8a67fbf3bb7446b7e"
const baseZeroBounnceURL = `https://api.zerobounce.net/v2/validate?api_key=${zeroBounceAPIKey}`
 
export const validateEmailAddressZeroBounce = async (email: string) => {
  let methodName = "validateEmailAddressZeroBounce"
  let response = await axios.get(baseZeroBounnceURL + "&email=" + email)
  Eif (response && response.status === 200) {
    let resultObj = response.data
    Iif (resultObj.status === "invalid") {
      throw {message: errorMessages.invalidEmail, methodName}
    } else {
      return true
    }
  } else {
    throw {message: response, methodName}
  }
}