n8n-nodes-emailverify
Version:
n8n node to verify emails using EmailVerify.io
49 lines (48 loc) • 1.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.emailVerifyIoApiRequest = void 0;
const n8n_workflow_1 = require("n8n-workflow");
async function emailVerifyIoApiRequest(method, endpoint, body = {}, qs = {}) {
const options = {
method,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
url: `https://app.emailverify.io/api/v1${endpoint}`,
qs,
};
if (Object.keys(body).length > 0) {
options.body = body;
}
try {
return await this.helpers.httpRequestWithAuthentication.call(this, 'emailVerifyApi', options);
}
catch (error) {
const statusCode = error?.statusCode ??
error?.httpCode;
if (statusCode === 401) {
throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
message: 'Invalid EmailVerify.io API key',
description: 'Check the API key configured in the EmailVerify.io credentials.',
httpCode: '401',
});
}
if (statusCode === 403) {
throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
message: 'Insufficient credits in your EmailVerify.io account',
description: 'Top up your EmailVerify.io account and try again.',
httpCode: '403',
});
}
if (statusCode === 429) {
throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
message: 'EmailVerify.io rate limit exceeded',
description: 'Slow down requests or upgrade your EmailVerify.io plan.',
httpCode: '429',
});
}
throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
}
}
exports.emailVerifyIoApiRequest = emailVerifyIoApiRequest;