email-marker-client
Advanced tools
Comparing version 1.0.1 to 2.0.0
@@ -1,6 +0,6 @@ | ||
import { EmailMarkerResult } from './email-marker.types'; | ||
import { EmailMarkerResponse } from './email-marker.types'; | ||
export declare class EmailMarkerClient { | ||
private readonly apiKey; | ||
constructor(apiKey: string); | ||
verify(email: string): Promise<EmailMarkerResult>; | ||
verify(email: string): Promise<EmailMarkerResponse>; | ||
} |
@@ -13,4 +13,4 @@ "use strict"; | ||
exports.EmailMarkerClient = void 0; | ||
const axios_1 = require("axios"); | ||
const ALL_RESULTS = ['valid', 'invalid', 'unknown', 'processing_error']; | ||
const cross_fetch_1 = require("cross-fetch"); | ||
const _1 = require("."); | ||
class EmailMarkerClient { | ||
@@ -22,12 +22,9 @@ constructor(apiKey) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const url = `https://app.emailmarker.com/api/verify?apiKey=${this.apiKey}&email=${encodeURI(email)}`; | ||
let status; | ||
const res = yield axios_1.default.get(url); | ||
if (typeof res.data === 'string' || res.status !== 200 || res.statusText !== 'OK') { | ||
status = 'processing_error'; | ||
const res = yield cross_fetch_1.default(`https://app.emailmarker.com/api/verify?apiKey=${this.apiKey}&email=${encodeURI(email)}`); | ||
if (res.ok) { | ||
return (yield res.json()); | ||
} | ||
else { | ||
status = ALL_RESULTS.indexOf(res.data.result) > -1 ? res.data.result : 'processing_error'; | ||
throw new _1.EmailMarkerError(res); | ||
} | ||
return status; | ||
}); | ||
@@ -34,0 +31,0 @@ } |
@@ -1,1 +0,5 @@ | ||
export declare type EmailMarkerResult = 'valid' | 'invalid' | 'unknown' | 'processing_error'; | ||
export interface EmailMarkerResponse { | ||
success: boolean; | ||
result: 'valid' | 'invalid' | 'unknown'; | ||
message: string; | ||
} |
export * from './email-marker.client'; | ||
export * from './email-marker.types'; | ||
export * from './email-marker.error'; |
@@ -15,2 +15,3 @@ "use strict"; | ||
__exportStar(require("./email-marker.types"), exports); | ||
__exportStar(require("./email-marker.error"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "email-marker-client", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "Email Marker API client for Node.js and browser", | ||
@@ -32,3 +32,2 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@types/axios": "^0.14.0", | ||
"@typescript-eslint/eslint-plugin": "^3.7.1", | ||
@@ -54,4 +53,4 @@ "@typescript-eslint/parser": "^3.7.1", | ||
"dependencies": { | ||
"axios": "^0.19.2" | ||
"cross-fetch": "^3.0.5" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17707
12
16
76
+ Addedcross-fetch@^3.0.5
+ Addedcross-fetch@3.1.8(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedaxios@^0.19.2
- Removedaxios@0.19.2(transitive)
- Removedfollow-redirects@1.5.10(transitive)