dymo-api 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -98,11 +98,7 @@ exports.isValidData = isValidData;
98
98
  * @example
99
99
  * const valid = await isValidEmail(apiToken, "user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
100
100
  */
101
- const isValidEmail = async (token, email, rules = {
102
- deny: [
103
- "FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"
104
- ]
105
- }) => {
101
+ const isValidEmail = async (token, email, rules) => {
106
102
  if (token === null)
107
103
  throw customError(3000, "Invalid private token.");
108
104
  if (rules.deny.length === 0)
@@ -57,10 +57,17 @@ class DymoAPI {
57
57
  * apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
58
58
  * });
59
59
  */
60
- constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined } = {}) {
60
+ constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined, rules = {
61
+ email: {
62
+ deny: [
63
+ "FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"
64
+ ]
65
+ }
66
+ } } = {}) {
61
67
  this.rootApiKey = rootApiKey;
62
68
  this.apiKey = apiKey;
63
69
  this.serverEmailConfig = serverEmailConfig;
70
+ this.rules = rules;
64
71
  this.baseUrl = baseUrl;
65
72
  (0, config_1.setBaseUrl)(baseUrl);
66
73
  }
@@ -109,7 +116,7 @@ class DymoAPI {
109
116
  *
110
117
  * @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier)
111
118
  */
112
- async isValidEmail(email, rules) {
119
+ async isValidEmail(email, rules = this.rules.email) {
113
120
  return await PrivateAPI.isValidEmail(this.rootApiKey || this.apiKey, email, rules);
114
121
  }
115
122
  ;
@@ -19,4 +19,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  ;
20
20
  ;
21
21
  ;
22
+ __exportStar(require("./rules.cjs"), exports);
22
23
  __exportStar(require("./data-verifier.cjs"), exports);
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
@@ -58,11 +58,7 @@ export const isValidData = async (token, data) => {
58
58
  * @example
59
59
  * const valid = await isValidEmail(apiToken, "user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
60
60
  */
61
- export const isValidEmail = async (token, email, rules = {
62
- deny: [
63
- "FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"
64
- ]
65
- }) => {
61
+ export const isValidEmail = async (token, email, rules) => {
66
62
  if (token === null)
67
63
  throw customError(3000, "Invalid private token.");
68
64
  if (rules.deny.length === 0)
@@ -22,10 +22,17 @@ class DymoAPI {
22
22
  * apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
23
23
  * });
24
24
  */
25
- constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined } = {}) {
25
+ constructor({ rootApiKey = null, apiKey = null, baseUrl = "https://api.tpeoficial.com", serverEmailConfig = undefined, rules = {
26
+ email: {
27
+ deny: [
28
+ "FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"
29
+ ]
30
+ }
31
+ } } = {}) {
26
32
  this.rootApiKey = rootApiKey;
27
33
  this.apiKey = apiKey;
28
34
  this.serverEmailConfig = serverEmailConfig;
35
+ this.rules = rules;
29
36
  this.baseUrl = baseUrl;
30
37
  setBaseUrl(baseUrl);
31
38
  }
@@ -74,7 +81,7 @@ class DymoAPI {
74
81
  *
75
82
  * @see [Documentation](https://docs.tpeoficial.com/docs/dymo-api/private/data-verifier)
76
83
  */
77
- async isValidEmail(email, rules) {
84
+ async isValidEmail(email, rules = this.rules.email) {
78
85
  return await PrivateAPI.isValidEmail(this.rootApiKey || this.apiKey, email, rules);
79
86
  }
80
87
  ;
@@ -3,4 +3,5 @@
3
3
  ;
4
4
  ;
5
5
  ;
6
+ export * from "./rules";
6
7
  export * from "./data-verifier";
@@ -0,0 +1,2 @@
1
+ ;
2
+ export {};
@@ -29,7 +29,7 @@ export declare const isValidData: (token: string | null, data: Interfaces.Valida
29
29
  * @example
30
30
  * const valid = await isValidEmail(apiToken, "user@example.com", { deny: ["FRAUD", "NO_MX_RECORDS"] });
31
31
  */
32
- export declare const isValidEmail: (token: string | null, email: Interfaces.EmailValidator, rules?: Interfaces.EmailValidatorRules) => Promise<any>;
32
+ export declare const isValidEmail: (token: string | null, email: Interfaces.EmailValidator, rules: Interfaces.EmailValidatorRules) => Promise<any>;
33
33
  /**
34
34
  * Sends an email using a secure sending endpoint.
35
35
  *
@@ -3,6 +3,7 @@ declare class DymoAPI {
3
3
  private rootApiKey;
4
4
  private apiKey;
5
5
  private serverEmailConfig?;
6
+ private rules;
6
7
  private baseUrl;
7
8
  /**
8
9
  * @param {Object} options - Options to create the DymoAPI instance.
@@ -21,11 +22,12 @@ declare class DymoAPI {
21
22
  * apiKey: "4c8b7675-6b69-4f8d-9f43-5a6f7f02c6c5"
22
23
  * });
23
24
  */
24
- constructor({ rootApiKey, apiKey, baseUrl, serverEmailConfig }?: {
25
+ constructor({ rootApiKey, apiKey, baseUrl, serverEmailConfig, rules }?: {
25
26
  rootApiKey?: string | null;
26
27
  apiKey?: string | null;
27
28
  baseUrl?: string;
28
29
  serverEmailConfig?: Interfaces.ServerEmailConfig;
30
+ rules?: Interfaces.Rules;
29
31
  });
30
32
  /**
31
33
  * Validates the given data against the configured validation settings.
@@ -165,4 +165,5 @@ export interface ExtractWithTextly {
165
165
  [key: string]: JsonSchemaProperty;
166
166
  };
167
167
  }
168
+ export * from "./rules";
168
169
  export * from "./data-verifier";
@@ -0,0 +1,6 @@
1
+ import { NegativeEmailRules } from "./data-verifier";
2
+ export interface Rules {
3
+ email: {
4
+ deny: NegativeEmailRules[];
5
+ };
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dymo-api",
3
- "version": "1.1.06",
3
+ "version": "1.1.07",
4
4
  "description": "Flow system for Dymo API.",
5
5
  "main": "dist/cjs/dymo-api.js",
6
6
  "module": "dist/esm/dymo-api.js",