dymo-api 1.0.18 → 1.0.20

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.
package/index.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- declare module "dymo-api" {
2
- interface ConfigurationOptions {
3
- rootApiKey?: string;
4
- apiKey?: string;
5
- local?: boolean;
6
- serverEmailConfig?: {
7
- host: string;
8
- port: number;
9
- secure: boolean;
10
- auth: {
11
- user: string;
12
- pass: string;
13
- };
1
+ export interface ConfigurationOptions {
2
+ rootApiKey?: string;
3
+ apiKey?: string;
4
+ local?: boolean;
5
+ serverEmailConfig?: {
6
+ host: string;
7
+ port: number;
8
+ secure: boolean;
9
+ auth: {
10
+ user: string;
11
+ pass: string;
14
12
  };
15
- }
13
+ };
14
+ }
16
15
 
16
+ declare module "dymo-api" {
17
17
  class DymoAPI {
18
18
  private rootApiKey: string | null;
19
19
  private apiKey: string | null;
@@ -32,6 +32,7 @@ declare module "dymo-api" {
32
32
  constructor(configuration?: ConfigurationOptions);
33
33
  initializeTokens(): Promise<void>;
34
34
  isValidData(data: any): Promise<any>;
35
+ getRandom(data: any): Promise<any>;
35
36
  getPrayerTimes(data: any): Promise<any>;
36
37
  inputSatinizer(data: any): Promise<any>;
37
38
  isValidPwd(data: any): Promise<any>;
package/index.ts CHANGED
@@ -1,35 +1,3 @@
1
- import { ConfigurationOptions } from "dymo-api";
2
-
3
- class DymoAPI {
4
- private configuration: ConfigurationOptions;
5
-
6
- constructor(configuration: ConfigurationOptions = {}) {
7
- this.configuration = configuration;
8
- }
9
-
10
- async initializeTokens(): Promise<void> {
11
- // Implementación aquí
12
- }
13
-
14
- async isValidData(data: any): Promise<any> {
15
- // Implementación aquí
16
- }
17
-
18
- async getPrayerTimes(data: any): Promise<any> {
19
- // Implementación aquí
20
- }
21
-
22
- async inputSatinizer(data: any): Promise<any> {
23
- // Implementación aquí
24
- }
25
-
26
- async isValidPwd(data: any): Promise<any> {
27
- // Implementación aquí
28
- }
29
-
30
- async newURLEncrypt(data: any): Promise<any> {
31
- // Implementación aquí
32
- }
33
- }
1
+ import { DymoAPI } from "./src/dymo-api";
34
2
 
35
3
  export { DymoAPI };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dymo-api",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "Flow system for Dymo API.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/dymo-api.ts CHANGED
@@ -93,6 +93,10 @@ class DymoAPI {
93
93
  return await PrivateAPI.sendEmail(this.apiKey, { serverEmailConfig: this.serverEmailConfig, ...data });
94
94
  }
95
95
 
96
+ async getRandom(data: any): Promise<any> {
97
+ return await PrivateAPI.getRandom(this.apiKey, data);
98
+ }
99
+
96
100
  // FUNCTIONS / Public.
97
101
  async getPrayerTimes(data: any): Promise<any> {
98
102
  return await PublicAPI.getPrayerTimes(data);
@@ -20,4 +20,10 @@ export interface Validator {
20
20
  ip?: string;
21
21
  };
22
22
 
23
+ export interface SRNG {
24
+ min: number;
25
+ max: number;
26
+ quantity?: number;
27
+ }
28
+
23
29
  export type SendEmail = | { from: string; to: string; subject: string; html: string; react?: never } | { from: string; to: string; subject: string; html?: never; react: React.ReactNode };
@@ -45,4 +45,18 @@ export const sendEmail = async (token: string | null, data: Interfaces.SendEmail
45
45
  } catch (error: any) {
46
46
  throw customError(5000, error.message);
47
47
  }
48
+ };
49
+
50
+ export const getRandom = async (token: string | null, data: Interfaces.SRNG): Promise<any> => {
51
+ if (token === null) throw customError(3000, "Invalid private token.");
52
+ if (!data.min || !data.max) throw customError(1500, "Both 'min' and 'max' parameters must be defined.");
53
+ if (data.min >= data.max) throw customError(1500, "❌ 'min' must be less than 'max'.");
54
+ if (data.min < -1000000000 || data.min > 1000000000) throw customError(1500, "❌ 'min' must be an integer in the interval [-1000000000}, 1000000000].");
55
+ if (data.max < -1000000000 || data.max > 1000000000) throw customError(1500, "❌ 'max' must be an integer in the interval [-1000000000}, 1000000000].");
56
+ try {
57
+ const response = await axios.post(`${BASE_URL}/v1/private/srng`, data, { headers: { "Authorization": token } });
58
+ return response.data;
59
+ } catch (error: any) {
60
+ throw customError(5000, error.message);
61
+ }
48
62
  };