zerobounce
Version:
ZeroBounce Email Verification Library
200 lines (199 loc) • 8.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidateResponseSuccess = exports.ValidateResponseSuccessStatus = void 0;
const response_mapping_1 = require("./response-mapping");
var ValidateResponseSuccessStatus;
(function (ValidateResponseSuccessStatus) {
ValidateResponseSuccessStatus["Valid"] = "valid";
ValidateResponseSuccessStatus["Invalid"] = "invalid";
ValidateResponseSuccessStatus["CatchAll"] = "catch-all";
ValidateResponseSuccessStatus["Unknown"] = "unknown";
ValidateResponseSuccessStatus["Spamtrap"] = "spamtrap";
ValidateResponseSuccessStatus["Abuse"] = "abuse";
ValidateResponseSuccessStatus["DoNotMail"] = "do_not_mail";
})(ValidateResponseSuccessStatus = exports.ValidateResponseSuccessStatus || (exports.ValidateResponseSuccessStatus = {}));
class ValidateResponseSuccess {
constructor() {
// The email address you are validating.
this.address = '';
// [valid, invalid, catch-all, unknown, spamtrap, abuse, do_not_mail]
this.status = ValidateResponseSuccessStatus.Unknown;
// [antispam_system, greylisted, mail_server_temporary_error, forcible_disconnect, mail_server_did_not_respond, timeout_exceeded, failed_smtp_connection, mailbox_quota_exceeded, exception_occurred, possible_trap, role_based, global_suppression, mailbox_not_found, no_dns_entries, failed_syntax_check, possible_typo, unroutable_ip_address, leading_period_removed, does_not_accept_mail, alias_address, role_based_catch_all, disposable, toxic]
this.subStatus = '';
// [true/false] If the email comes from a free provider.
this.freeEmail = false;
// Suggestive Fix for an email typo
this.didYouMean = null;
// The portion of the email address before the "@" symbol or null.
this.account = null;
// The portion of the email address after the "@" symbol or null.
this.domain = null;
// Age of the email domain in days or [null].
this.domainAgeDays = null;
// The SMTP Provider of the email or [null] [BETA].
this.smtpProvider = null;
// The preferred MX record of the domain
this.mxRecord = null;
// [true/false] Does the domain have an MX record. [they return "bool" not bool, which makes it a string...]
this.mxFound = null;
// The first name of the owner of the email when available or [null].
this.firstName = null;
// The last name of the owner of the email when available or [null].
this.lastName = null;
// The gender of the owner of the email when available or [null].
this.gender = null;
// The country of the IP passed in or [null]
this.country = null;
// The region/state of the IP passed in or [null]
this.region = null;
// The city of the IP passed in or [null]
this.city = null;
// The zipcode of the IP passed in or [null]
this.zipcode = null;
// The UTC time the email was validated.
this.processedAt = '';
}
isValid() {
return this.status === ValidateResponseSuccessStatus.Valid;
}
isInvalid() {
return this.status === ValidateResponseSuccessStatus.Invalid;
}
isCatchAll() {
return this.status === ValidateResponseSuccessStatus.CatchAll;
}
isUnknown() {
return this.status === ValidateResponseSuccessStatus.Unknown;
}
isSpamtrap() {
return this.status === ValidateResponseSuccessStatus.Spamtrap;
}
isAbuse() {
return this.status === ValidateResponseSuccessStatus.Abuse;
}
isDoNotMail() {
return this.status === ValidateResponseSuccessStatus.DoNotMail;
}
static fromAny(object) {
return (0, response_mapping_1.fromAnyWithMapping)(object, new ValidateResponseSuccess(), [
{
field: 'address',
setter: (s, d) => {
var _a;
d.address = String((_a = s === null || s === void 0 ? void 0 : s.address) !== null && _a !== void 0 ? _a : '');
},
},
{
field: 'status',
setter: (s, d) => {
var _a;
d.status = ((_a = s === null || s === void 0 ? void 0 : s.status) !== null && _a !== void 0 ? _a : ValidateResponseSuccessStatus.Unknown);
},
},
{
field: 'sub_status',
setter: (s, d) => {
d.subStatus = String(s === null || s === void 0 ? void 0 : s.sub_status);
},
},
{
field: 'free_email',
setter: (s, d) => {
d.freeEmail = Boolean(s === null || s === void 0 ? void 0 : s.free_email);
},
},
{
field: 'did_you_mean',
setter: (s, d) => {
d.didYouMean = s === null || s === void 0 ? void 0 : s.did_you_mean;
},
},
{
field: 'account',
setter: (s, d) => {
d.account = s === null || s === void 0 ? void 0 : s.account;
},
},
{
field: 'domain',
setter: (s, d) => {
d.domain = s === null || s === void 0 ? void 0 : s.domain;
},
},
{
field: 'domain_age_days',
setter: (s, d) => {
d.domainAgeDays = s === null || s === void 0 ? void 0 : s.domain_age_days;
},
},
{
field: 'smtp_provider',
setter: (s, d) => {
d.smtpProvider = s === null || s === void 0 ? void 0 : s.smtp_provider;
},
},
{
field: 'mx_record',
setter: (s, d) => {
d.mxRecord = s === null || s === void 0 ? void 0 : s.mx_record;
},
},
{
field: 'mx_found',
setter: (s, d) => {
d.mxFound = s === null || s === void 0 ? void 0 : s.mx_found;
},
},
{
field: 'firstname',
setter: (s, d) => {
d.firstName = s === null || s === void 0 ? void 0 : s.firstname;
},
},
{
field: 'lastname',
setter: (s, d) => {
d.lastName = s === null || s === void 0 ? void 0 : s.lastname;
},
},
{
field: 'gender',
setter: (s, d) => {
d.gender = s === null || s === void 0 ? void 0 : s.gender;
},
},
{
field: 'country',
setter: (s, d) => {
d.country = s === null || s === void 0 ? void 0 : s.country;
},
},
{
field: 'region',
setter: (s, d) => {
d.region = s === null || s === void 0 ? void 0 : s.region;
},
},
{
field: 'city',
setter: (s, d) => {
d.city = s === null || s === void 0 ? void 0 : s.city;
},
},
{
field: 'zipcode',
setter: (s, d) => {
d.zipcode = s === null || s === void 0 ? void 0 : s.zipcode;
},
},
{
field: 'processed_at',
setter: (s, d) => {
var _a;
d.processedAt = String((_a = s === null || s === void 0 ? void 0 : s.processed_at) !== null && _a !== void 0 ? _a : '');
},
},
]);
}
}
exports.ValidateResponseSuccess = ValidateResponseSuccess;