dymo-api 1.0.19 → 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 +1 -0
- package/package.json +1 -1
- package/src/dymo-api.ts +4 -0
- package/src/lib/interfaces.ts +6 -0
- package/src/private-api.ts +14 -0
package/index.d.ts
CHANGED
|
@@ -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/package.json
CHANGED
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);
|
package/src/lib/interfaces.ts
CHANGED
|
@@ -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 };
|
package/src/private-api.ts
CHANGED
|
@@ -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
|
};
|