dymo-api 1.0.2 → 1.0.4

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/config.cjs ADDED
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ lib: {
3
+ name: "Dymo API",
4
+ dir: "dymo-api"
5
+ }
6
+ }
package/lib/dymo-api.cjs CHANGED
@@ -1,6 +1,5 @@
1
- const fs = require("fs");
2
1
  const axios = require("axios");
3
- const config = JSON.parse(fs.readFileSync('../config.json', 'utf8'));
2
+ const config = require("../config.cjs");
4
3
  const customError = (code, message) => Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
5
4
 
6
5
  /* INTERNALS */
@@ -1,6 +1,5 @@
1
- const fs = require("fs");
2
1
  const axios = require("axios");
3
- const config = JSON.parse(fs.readFileSync('../config.json', 'utf8'));
2
+ const config = require("../config.cjs");
4
3
  const customError = (code, message) => Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
5
4
 
6
5
  exports.isValidData = async (token, data) => {
@@ -15,24 +14,7 @@ exports.isValidData = async (token, data) => {
15
14
  if (!i) throw customError(1500, "You must provide at least one parameter.");
16
15
  try {
17
16
  const response = await axios.get(`https://api.tpeoficial.com/private/secure/verify`, { params: data, headers: { 'Authorization': token } });
18
- const dicc = {
19
- "0000": "email",
20
- "0001": "tel",
21
- "0002": "domain",
22
- "0003": "creditCard",
23
- "0004": "ip"
24
- }
25
- const result = {};
26
- response.data.forEach(obj => {
27
- Object.keys(dicc).forEach(code => {
28
- if (obj.hasOwnProperty('code') && obj.code === code) {
29
- const type = dicc[code];
30
- if (!result.hasOwnProperty(type)) result[type] = {};
31
- result[type] = { ...result[type], ...obj };
32
- }
33
- });
34
- });
35
- return result;
17
+ return response.data;
36
18
  } catch (error) {
37
19
  throw customError(5000, error.message);
38
20
  }
@@ -1,6 +1,5 @@
1
- const fs = require("fs");
2
1
  const axios = require("axios");
3
- const config = JSON.parse(fs.readFileSync('../config.json', 'utf8'));
2
+ const config = require("../config.cjs");
4
3
  const customError = (code, message) => Object.assign(new Error(), { code, message: `[${config.lib.name}] ${message}` });
5
4
 
6
5
  exports.getPrayerTimes = async (data) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dymo-api",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Flow system for Dymo API.",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/config.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "lib": {
3
- "name": "Dymo API",
4
- "dir": "dymo-api"
5
- }
6
- }