dymo-api 1.0.16 → 1.0.17

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/dymo-api.ts +15 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dymo-api",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Flow system for Dymo API.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/dymo-api.ts CHANGED
@@ -17,17 +17,29 @@ interface Tokens {
17
17
  api?: string;
18
18
  };
19
19
 
20
+ interface ServerEmailConfig {
21
+ host: string;
22
+ port: number;
23
+ secure: boolean;
24
+ auth: {
25
+ user: string;
26
+ pass: string;
27
+ };
28
+ };
29
+
20
30
  class DymoAPI {
21
31
  private rootApiKey: string | null;
22
32
  private apiKey: string | null;
23
33
  private tokensResponse: TokensResponse | null;
24
34
  private lastFetchTime: Date | null;
35
+ private serverEmailConfig?: ServerEmailConfig;
25
36
 
26
- constructor({ rootApiKey = null, apiKey = null }: { rootApiKey?: string | null; apiKey?: string | null }) {
37
+ constructor({ rootApiKey = null, apiKey = null, serverEmailConfig = undefined }: { rootApiKey?: string | null; apiKey?: string | null; serverEmailConfig?: ServerEmailConfig; }) {
27
38
  this.rootApiKey = rootApiKey;
28
39
  this.apiKey = apiKey;
29
40
  this.tokensResponse = null;
30
41
  this.lastFetchTime = null;
42
+ this.serverEmailConfig = serverEmailConfig;
31
43
  this.initializeTokens(); // Calls the function to obtain tokens when creating the object.
32
44
  }
33
45
 
@@ -70,7 +82,8 @@ class DymoAPI {
70
82
  }
71
83
 
72
84
  async sendEmail(data: any): Promise<any> {
73
- return await PrivateAPI.sendEmail(this.apiKey, data);
85
+ if (this.serverEmailConfig) throw customError(5000, `You must configure the email client settings.`);
86
+ return await PrivateAPI.sendEmail(this.apiKey, { serverEmailConfig: this.serverEmailConfig, ...data });
74
87
  }
75
88
 
76
89
  // FUNCTIONS / Public.