poe-api-manager 0.2.2 → 0.2.8

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 (69) hide show
  1. package/Changelog.md +17 -14
  2. package/README.md +31 -18
  3. package/lib/NinjaAPI.js +26 -4
  4. package/lib/WatchAPI.js +45 -1
  5. package/lib/config/poeNinja/url.js +9 -0
  6. package/lib/config/poeWatch/url.js +9 -0
  7. package/lib/modules/mainfunctions/filter/propertyFilter.js +18 -0
  8. package/lib/modules/poe.ninja/currency/CurrencyWievModule.js +39 -2
  9. package/lib/modules/poe.ninja/currency/currencyFetch/fetchCurrency.js +11 -3
  10. package/lib/modules/poe.ninja/currency/currencyFetch/merge/mergeData.js +7 -0
  11. package/lib/modules/poe.ninja/currency/currencySubmodules/functions/getData.js +23 -0
  12. package/lib/modules/poe.ninja/currency/currencySubmodules/subModules/CurrencyModule.js +45 -2
  13. package/lib/modules/poe.ninja/currency/currencySubmodules/subModules/FragmentModule.js +45 -2
  14. package/lib/modules/poe.ninja/item/ItemWievModule.js +135 -2
  15. package/lib/modules/poe.ninja/item/itemFetch/fetchItem.js +23 -2
  16. package/lib/modules/poe.ninja/item/itemSubmodules/functions/getData.js +19 -0
  17. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BaseTypeModule.js +41 -2
  18. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BeastModule.js +41 -2
  19. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BlightRavagedMapModule.js +46 -2
  20. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BlightedMapModule.js +43 -2
  21. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ClusterJewelModule.js +46 -2
  22. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/DeliriumOrbsModule.js +46 -2
  23. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/DivinationCardModule.js +46 -2
  24. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/EssenceModule.js +46 -2
  25. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/FossilModule.js +46 -2
  26. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/HelmetEnchantModule.js +46 -2
  27. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/IncubatorModule.js +46 -2
  28. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/InvitationModule.js +46 -2
  29. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/MapModule.js +46 -2
  30. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/MemoryModule.js +46 -2
  31. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/OilModule.js +46 -2
  32. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/OmenModule.js +46 -2
  33. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ResonatorModule.js +46 -2
  34. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ScarabModule.js +46 -2
  35. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/SkillGemModule.js +46 -2
  36. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueAccessoryModule.js +46 -2
  37. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueArmourModule.js +46 -2
  38. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueFlaskModule.js +46 -2
  39. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueJewelModule.js +46 -2
  40. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueMapModule.js +46 -2
  41. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueRelicModule.js +46 -2
  42. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueWeaponModule.js +46 -2
  43. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/VialsModule.js +46 -2
  44. package/lib/modules/poe.watch/WatchWievModule.js +106 -4
  45. package/lib/modules/poe.watch/allModules/fetch/fetch.js +11 -2
  46. package/lib/modules/poe.watch/allModules/functions/getCategory.js +55 -0
  47. package/lib/modules/poe.watch/allModules/functions/getData.js +20 -1
  48. package/lib/modules/poe.watch/allModules/submodules/AccessoryModule.js +77 -1
  49. package/lib/modules/poe.watch/allModules/submodules/ArmourModule.js +75 -1
  50. package/lib/modules/poe.watch/allModules/submodules/BaseModule.js +75 -1
  51. package/lib/modules/poe.watch/allModules/submodules/BeastModule.js +47 -1
  52. package/lib/modules/poe.watch/allModules/submodules/CurrencyModule.js +49 -2
  53. package/lib/modules/poe.watch/allModules/submodules/DeliriumOrbModule.js +47 -1
  54. package/lib/modules/poe.watch/allModules/submodules/DivsModule.js +47 -1
  55. package/lib/modules/poe.watch/allModules/submodules/EssenceModule.js +47 -1
  56. package/lib/modules/poe.watch/allModules/submodules/FlaskModule.js +47 -1
  57. package/lib/modules/poe.watch/allModules/submodules/FossilModule.js +47 -1
  58. package/lib/modules/poe.watch/allModules/submodules/FragmentModule.js +47 -1
  59. package/lib/modules/poe.watch/allModules/submodules/GemModule.js +76 -1
  60. package/lib/modules/poe.watch/allModules/submodules/InscribedModule.js +49 -1
  61. package/lib/modules/poe.watch/allModules/submodules/InvitationModule.js +47 -1
  62. package/lib/modules/poe.watch/allModules/submodules/JewelModule.js +47 -1
  63. package/lib/modules/poe.watch/allModules/submodules/MapModule.js +47 -1
  64. package/lib/modules/poe.watch/allModules/submodules/OilModule.js +47 -1
  65. package/lib/modules/poe.watch/allModules/submodules/ScarabModule.js +47 -1
  66. package/lib/modules/poe.watch/allModules/submodules/SextantModule.js +47 -1
  67. package/lib/modules/poe.watch/allModules/submodules/UniqueMapsModule.js +47 -1
  68. package/lib/modules/poe.watch/allModules/submodules/WeaponModule.js +75 -1
  69. package/package.json +1 -1
@@ -1,9 +1,15 @@
1
1
  const axios = require("axios");
2
2
  const baseUrl = require("../../../../config/poeWatch/url").baseurl;
3
-
3
+ /**
4
+ * Fetches data from the POE Watch API based on the provided query URL.
5
+ * @param {string} queryUrl - The query URL to be appended to the base URL.
6
+ * @returns {Promise<Object>} - A Promise that resolves to the fetched data.
7
+ * @throws {Error} - Throws an error if there is an issue with the API response or fetching data.
8
+ */
4
9
  async function fetchData(queryUrl) {
5
10
  try {
6
11
  const url = `${baseUrl}${queryUrl}`;
12
+
7
13
  const response = await axios.get(url);
8
14
 
9
15
  if (response.data) {
@@ -12,7 +18,10 @@ async function fetchData(queryUrl) {
12
18
  throw new Error("Invalid response format from POE Watch API");
13
19
  }
14
20
  } catch (error) {
15
- throw new Error(`Error fetching data: ${error.message}`);
21
+ /**
22
+ * @throws {Error} - Throws an error with a specific message if there is an issue with fetching data.
23
+ */
24
+ throw new Error(`Error fetching data from poe.watch: ${error.message}`);
16
25
  }
17
26
  }
18
27
 
@@ -0,0 +1,55 @@
1
+ const fetchData = require("../fetch/fetch");
2
+
3
+ /**
4
+ * Fetches data based on the provided query URL and filters it by category name.
5
+ *
6
+ * @async
7
+ * @function
8
+ * @param {string} queryUrl - The URL to fetch the data from.
9
+ * @param {string} categoryName - The name of the category to filter the data by.
10
+ * @returns {Promise<Array<Object>|Object>} - A promise that resolves to an array of filtered data items.
11
+ * @throws {Error} Throws an error if category name is not provided or if there is an issue fetching or filtering the data.
12
+ */
13
+ const getCategory = async (queryUrl, categoryName) => {
14
+ try {
15
+ /**
16
+ * @type {Array<Object>} fetchedData - The fetched data.
17
+ */
18
+ const fetchedData = await fetchData(queryUrl);
19
+
20
+ // Validate category name
21
+ if (!categoryName && categoryName !== 0) {
22
+ /**
23
+ * Throws an error if the category name is not provided.
24
+ * @throws {Error}
25
+ */
26
+ throw new Error("Category name is required.");
27
+ }
28
+
29
+ // Filter data by category name
30
+ const filteredData = fetchedData.filter(
31
+ (item) => item.group === categoryName
32
+ );
33
+
34
+ // Check if filtered data is empty
35
+ if (filteredData.length === 0) {
36
+ /**
37
+ * Throws an error if no data is found for the specified category.
38
+ * @throws {Error}
39
+ */
40
+ throw new Error(`No data found for category: ${categoryName}`);
41
+ }
42
+
43
+ return filteredData;
44
+ } catch (error) {
45
+ /**
46
+ * Throws an error if there's an issue fetching or filtering data for the category.
47
+ * @throws {Error}
48
+ */
49
+ throw new Error(
50
+ `Error fetching or filtering data for category: ${error.message}`
51
+ );
52
+ }
53
+ };
54
+
55
+ module.exports = getCategory;
@@ -1,11 +1,26 @@
1
1
  const fetchData = require("../fetch/fetch");
2
2
  const filterProperties = require("../../../mainfunctions/filter/propertyFilter");
3
3
 
4
+ /**
5
+ * Retrieves data from the specified URL, optionally filtering based on requested properties.
6
+ *
7
+ * @param {string} queryUrl - The URL to fetch data from.
8
+ * @param {Array<string>} [requestedProperties] - An optional array of property names to filter the data.
9
+ * @returns {Promise<Array<Object>|Object>} - A promise that resolves to the fetched or filtered data.
10
+ * @throws {Error} - Throws an error if there is an issue fetching or filtering the data.
11
+ */
4
12
  async function getData(queryUrl, requestedProperties) {
5
13
  try {
14
+ /**
15
+ * @type {Array<Object>|Object} fetchedData - The fetched data.
16
+ */
6
17
  const fetchedData = await fetchData(queryUrl);
18
+
7
19
  // If requestedProperties are specified, filter the data based on those properties
8
20
  if (requestedProperties) {
21
+ /**
22
+ * @type {Array<Object>|Object} result - The filtered data based on requested properties.
23
+ */
9
24
  const result = filterProperties(fetchedData, requestedProperties);
10
25
  return result;
11
26
  } else {
@@ -13,7 +28,11 @@ async function getData(queryUrl, requestedProperties) {
13
28
  return fetchedData;
14
29
  }
15
30
  } catch (error) {
16
- throw new Error(`Error fetching data poe.watch: ${error.message}`);
31
+ /**
32
+ * Throws an error if there's an issue fetching or filtering the data.
33
+ * @throws {Error}
34
+ */
35
+ throw new Error(`Error fetching data: ${error.message}`);
17
36
  }
18
37
  }
19
38
 
@@ -1,13 +1,89 @@
1
1
  const getData = require("../functions/getData");
2
+ const getCategory = require("../functions/getCategory");
2
3
 
4
+ /**
5
+ * Represents a module for fetching data related to Accessories.
6
+ *
7
+ * @class
8
+ */
3
9
  class AccessoryModule {
10
+ /**
11
+ * The query URL for fetching accessory data.
12
+ *
13
+ * @private
14
+ * @type {string}
15
+ */
4
16
  #queryUrl;
17
+
18
+ /**
19
+ * Creates an instance of AccessoryModule.
20
+ *
21
+ * @param {string} leagueUrl - The league URL to fetch data from.
22
+ */
5
23
  constructor(leagueUrl) {
24
+ /**
25
+ * The constructed query URL for fetching accessory data.
26
+ *
27
+ * @private
28
+ * @type {string}
29
+ */
6
30
  this.#queryUrl = `accessory${leagueUrl}`;
7
31
  }
32
+
33
+ /**
34
+ * Asynchronously retrieves accessory data based on the specified properties.
35
+ *
36
+ * @async
37
+ * @param {Array<string>} requestedProperties - An array of properties to retrieve.
38
+ * @returns {Promise<Object>} A promise that resolves to the retrieved data.
39
+ */
8
40
  async getData(requestedProperties) {
9
- return getData(this.#queryUrl, requestedProperties);
41
+ try {
42
+ /**
43
+ * Calls the getData function to fetch accessory data.
44
+ *
45
+ * @type {Promise<Array<Object>>}
46
+ */
47
+ return getData(this.#queryUrl, requestedProperties);
48
+ } catch (error) {
49
+ /**
50
+ * Throws an error if there's an issue fetching or processing the accessory data.
51
+ *
52
+ * @throws {Error}
53
+ */
54
+ throw new Error(`Error fetching accessory data: ${error.message}`);
55
+ }
56
+ }
57
+ /**
58
+ * Asynchronously retrieves accessory data based on the specified category name.
59
+ *
60
+ * @async
61
+ * @param {string} categoryName - The name of the category to retrieve.
62
+ * * Possible values: "amulets", "rings", "belts", "quivers".
63
+ * @returns {Promise<Array<Object>>} - A promise that resolves to the retrieved data.
64
+ * @throws {Error} - Throws an error if there is an issue fetching or processing the accessory data for the specified category.
65
+ *
66
+ */
67
+ async getCategory(categoryName) {
68
+ try {
69
+ /**
70
+ * Calls the getCategory function to fetch accessory data based on category name.
71
+ *
72
+ * @type {Promise<Array<Object>>}
73
+ */
74
+ return getCategory(this.#queryUrl, categoryName);
75
+ } catch (error) {
76
+ /**
77
+ * Throws an error if there's an issue fetching or processing the accessory data for the specified category.
78
+ *
79
+ * @throws {Error}
80
+ */
81
+ throw new Error(
82
+ `Error fetching data Accessory Category: ${error.message}`
83
+ );
84
+ }
10
85
  }
11
86
  }
12
87
 
88
+ // Export the AccessoryModule class
13
89
  module.exports = AccessoryModule;
@@ -1,13 +1,87 @@
1
1
  const getData = require("../functions/getData");
2
+ const getCategory = require("../functions/getCategory");
2
3
 
4
+ /**
5
+ * Represents a module for fetching data related to Armour.
6
+ *
7
+ * @class
8
+ */
3
9
  class ArmourModule {
10
+ /**
11
+ * The query URL for fetching armour data.
12
+ *
13
+ * @private
14
+ * @type {string}
15
+ */
4
16
  #queryUrl;
17
+
18
+ /**
19
+ * Creates an instance of ArmourModule.
20
+ *
21
+ * @param {string} leagueUrl - The league URL to fetch data from.
22
+ */
5
23
  constructor(leagueUrl) {
24
+ /**
25
+ * The constructed query URL for fetching armour data.
26
+ *
27
+ * @private
28
+ * @type {string}
29
+ */
6
30
  this.#queryUrl = `armour${leagueUrl}`;
7
31
  }
32
+
33
+ /**
34
+ * Asynchronously retrieves armour data based on the specified properties.
35
+ *
36
+ * @async
37
+ * @param {Array<string>} requestedProperties - An array of properties to retrieve.
38
+ * @returns {Promise<Object>} A promise that resolves to the retrieved data.
39
+ */
8
40
  async getData(requestedProperties) {
9
- return getData(this.#queryUrl, requestedProperties);
41
+ try {
42
+ /**
43
+ * Calls the getData function to fetch armour data.
44
+ *
45
+ * @type {Promise<Array<Object>>}
46
+ */
47
+ return getData(this.#queryUrl, requestedProperties);
48
+ } catch (error) {
49
+ /**
50
+ * Throws an error if there's an issue fetching or processing the armour data.
51
+ *
52
+ * @throws {Error}
53
+ */
54
+ throw new Error(`Error fetching armour data: ${error.message}`);
55
+ }
56
+ }
57
+ /**
58
+ * Asynchronously retrieves armour data based on the specified category name.
59
+ *
60
+ * @async
61
+ * @param {string} categoryName - The name of the category to retrieve.
62
+ * * Possible values: "chest", "bodyarmours", "shield", "boots", "gloves", "shields", "helmets", "quiver".
63
+ * @returns {Promise<Array<Object>>} - A promise that resolves to the retrieved data.
64
+ * @throws {Error} - Throws an error if there is an issue fetching or processing the armour data for the specified category.
65
+ *
66
+ */
67
+ async getCategory(categoryName) {
68
+ try {
69
+ /**
70
+ * Calls the getCategory function to fetch armour data based on category name.
71
+ *
72
+ * @type {Promise<Array<Object>>}
73
+ */
74
+ return getCategory(this.#queryUrl, categoryName);
75
+ } catch (error) {
76
+ /**
77
+ * Throws an error if there's an issue fetching or processing the armour data for the specified category.
78
+ *
79
+ * @throws {Error}
80
+ */
81
+ throw new Error(`Error fetching data Armour Category: ${error.message}`);
82
+ }
10
83
  }
11
84
  }
12
85
 
86
+ // Export the ArmourModule class
13
87
  module.exports = ArmourModule;
@@ -1,13 +1,87 @@
1
1
  const getData = require("../functions/getData");
2
+ const getCategory = require("../functions/getCategory");
2
3
 
4
+ /**
5
+ * Represents a module for fetching data related to Bases.
6
+ *
7
+ * @class
8
+ */
3
9
  class BaseModule {
10
+ /**
11
+ * The query URL for fetching base data.
12
+ *
13
+ * @private
14
+ * @type {string}
15
+ */
4
16
  #queryUrl;
17
+
18
+ /**
19
+ * Creates an instance of BaseModule.
20
+ *
21
+ * @param {string} leagueUrl - The league URL to fetch data from.
22
+ */
5
23
  constructor(leagueUrl) {
24
+ /**
25
+ * The constructed query URL for fetching base data.
26
+ *
27
+ * @private
28
+ * @type {string}
29
+ */
6
30
  this.#queryUrl = `bases${leagueUrl}`;
7
31
  }
32
+
33
+ /**
34
+ * Asynchronously retrieves base data based on the specified properties.
35
+ *
36
+ * @async
37
+ * @param {Array<string>} requestedProperties - An array of properties to retrieve.
38
+ * @returns {Promise<Object>} A promise that resolves to the retrieved data.
39
+ */
8
40
  async getData(requestedProperties) {
9
- return getData(this.#queryUrl, requestedProperties);
41
+ try {
42
+ /**
43
+ * Calls the getData function to fetch base data.
44
+ *
45
+ * @type {Promise<Array<Object>>}
46
+ */
47
+ return getData(this.#queryUrl, requestedProperties);
48
+ } catch (error) {
49
+ /**
50
+ * Throws an error if there's an issue fetching or processing the base data.
51
+ *
52
+ * @throws {Error}
53
+ */
54
+ throw new Error(`Error fetching base data: ${error.message}`);
55
+ }
56
+ }
57
+ /**
58
+ * Asynchronously retrieves base data based on the specified category name.
59
+ *
60
+ * @async
61
+ * @param {string} categoryName - The name of the category to retrieve.
62
+ * * Possible values: "armour", "weapons", "accessories".
63
+ * @returns {Promise<Array<Object>>} - A promise that resolves to the retrieved data.
64
+ * @throws {Error} - Throws an error if there is an issue fetching or processing the base data for the specified category.
65
+ *
66
+ */
67
+ async getCategory(categoryName) {
68
+ try {
69
+ /**
70
+ * Calls the getCategory function to fetch base data based on category name.
71
+ *
72
+ * @type {Promise<Array<Object>>}
73
+ */
74
+ return getCategory(this.#queryUrl, categoryName);
75
+ } catch (error) {
76
+ /**
77
+ * Throws an error if there's an issue fetching or processing the base data for the specified category.
78
+ *
79
+ * @throws {Error}
80
+ */
81
+ throw new Error(`Error fetching data Base Category: ${error.message}`);
82
+ }
10
83
  }
11
84
  }
12
85
 
86
+ // Export the BaseModule class
13
87
  module.exports = BaseModule;
@@ -1,13 +1,59 @@
1
1
  const getData = require("../functions/getData");
2
2
 
3
+ /**
4
+ * Represents a module for fetching data related to Beasts.
5
+ *
6
+ * @class
7
+ */
3
8
  class BeastModule {
9
+ /**
10
+ * The query URL for fetching beast data.
11
+ *
12
+ * @private
13
+ * @type {string}
14
+ */
4
15
  #queryUrl;
16
+
17
+ /**
18
+ * Creates an instance of BeastModule.
19
+ *
20
+ * @param {string} leagueUrl - The league URL to fetch data from.
21
+ */
5
22
  constructor(leagueUrl) {
23
+ /**
24
+ * The constructed query URL for fetching beast data.
25
+ *
26
+ * @private
27
+ * @type {string}
28
+ */
6
29
  this.#queryUrl = `beast${leagueUrl}`;
7
30
  }
31
+
32
+ /**
33
+ * Asynchronously retrieves beast data based on the specified properties.
34
+ *
35
+ * @async
36
+ * @param {Array<string>} requestedProperties - An array of properties to retrieve.
37
+ * @returns {Promise<Object>} A promise that resolves to the retrieved data.
38
+ */
8
39
  async getData(requestedProperties) {
9
- return getData(this.#queryUrl, requestedProperties);
40
+ try {
41
+ /**
42
+ * Calls the getData function to fetch beast data.
43
+ *
44
+ * @type {Promise<Array<Object>>}
45
+ */
46
+ return getData(this.#queryUrl, requestedProperties);
47
+ } catch (error) {
48
+ /**
49
+ * Throws an error if there's an issue fetching or processing the beast data.
50
+ *
51
+ * @throws {Error}
52
+ */
53
+ throw new Error(`Error fetching beast data: ${error.message}`);
54
+ }
10
55
  }
11
56
  }
12
57
 
58
+ // Export the BeastModule class
13
59
  module.exports = BeastModule;
@@ -1,13 +1,60 @@
1
1
  const getData = require("../functions/getData");
2
2
 
3
+ /**
4
+ * Represents a module for fetching data related to Currency.
5
+ *
6
+ * @class
7
+ */
3
8
  class CurrencyModule {
9
+ /**
10
+ * The query URL for fetching currency data.
11
+ *
12
+ * @private
13
+ * @type {string}
14
+ */
4
15
  #queryUrl;
16
+
17
+ /**
18
+ * Creates an instance of CurrencyModule.
19
+ *
20
+ * @param {string} leagueUrl - The league URL to fetch data from.
21
+ */
5
22
  constructor(leagueUrl) {
23
+ /**
24
+ * The constructed query URL for fetching currency data.
25
+ *
26
+ * @private
27
+ * @type {string}
28
+ */
6
29
  this.#queryUrl = `currency${leagueUrl}`;
7
30
  }
31
+
32
+ /**
33
+ * Asynchronously retrieves currency data based on the specified properties.
34
+ *
35
+ * @async
36
+ * @param {Array<string>} requestedProperties - An array of properties to retrieve.
37
+ * @returns {Promise<Object>} A promise that resolves to the retrieved data.
38
+ */
8
39
  async getData(requestedProperties) {
9
- return getData(this.#queryUrl, requestedProperties);
40
+ try {
41
+ /**
42
+ * Calls the getData function to fetch currency data.
43
+ *
44
+ * @type {Promise<Array<Object>>}
45
+ */
46
+ return getData(this.#queryUrl, requestedProperties);
47
+ } catch (error) {
48
+ /**
49
+ * Throws an error if there's an issue fetching or processing the currency data.
50
+ *
51
+ * @throws {Error}
52
+ */
53
+ throw new Error(`Error fetching currency data: ${error.message}`);
54
+ }
10
55
  }
11
56
  }
12
- // export CurrencyModule;
57
+
58
+ // Uncomment the line below if you want to export the CurrencyModule class
59
+ // module.exports = CurrencyModule;
13
60
  module.exports = CurrencyModule;
@@ -1,13 +1,59 @@
1
1
  const getData = require("../functions/getData");
2
2
 
3
+ /**
4
+ * Represents a module for fetching data related to Delirium Orbs.
5
+ *
6
+ * @class
7
+ */
3
8
  class DeliriumOrbModule {
9
+ /**
10
+ * The query URL for fetching Delirium Orb data.
11
+ *
12
+ * @private
13
+ * @type {string}
14
+ */
4
15
  #queryUrl;
16
+
17
+ /**
18
+ * Creates an instance of DeliriumOrbModule.
19
+ *
20
+ * @param {string} leagueUrl - The league URL to fetch data from.
21
+ */
5
22
  constructor(leagueUrl) {
23
+ /**
24
+ * The constructed query URL for fetching Delirium Orb data.
25
+ *
26
+ * @private
27
+ * @type {string}
28
+ */
6
29
  this.#queryUrl = `currency${leagueUrl}`;
7
30
  }
31
+
32
+ /**
33
+ * Asynchronously retrieves Delirium Orb data based on the specified properties.
34
+ *
35
+ * @async
36
+ * @param {Array<string>} requestedProperties - An array of properties to retrieve.
37
+ * @returns {Promise<Object>} A promise that resolves to the retrieved data.
38
+ */
8
39
  async getData(requestedProperties) {
9
- return getData(this.#queryUrl, requestedProperties);
40
+ try {
41
+ /**
42
+ * Calls the getData function to fetch Delirium Orb data.
43
+ *
44
+ * @type {Promise<Array<Object>>}
45
+ */
46
+ return getData(this.#queryUrl, requestedProperties);
47
+ } catch (error) {
48
+ /**
49
+ * Throws an error if there's an issue fetching or processing the Delirium Orb data.
50
+ *
51
+ * @throws {Error}
52
+ */
53
+ throw new Error(`Error fetching Delirium Orb data: ${error.message}`);
54
+ }
10
55
  }
11
56
  }
12
57
 
58
+ // Export the DeliriumOrbModule class
13
59
  module.exports = DeliriumOrbModule;
@@ -1,13 +1,59 @@
1
1
  const getData = require("../functions/getData");
2
2
 
3
+ /**
4
+ * Represents a module for fetching data related to Divination Cards.
5
+ *
6
+ * @class
7
+ */
3
8
  class DivsModule {
9
+ /**
10
+ * The query URL for fetching Divination Card data.
11
+ *
12
+ * @private
13
+ * @type {string}
14
+ */
4
15
  #queryUrl;
16
+
17
+ /**
18
+ * Creates an instance of DivsModule.
19
+ *
20
+ * @param {string} leagueUrl - The league URL to fetch data from.
21
+ */
5
22
  constructor(leagueUrl) {
23
+ /**
24
+ * The constructed query URL for fetching Divination Card data.
25
+ *
26
+ * @private
27
+ * @type {string}
28
+ */
6
29
  this.#queryUrl = `currency${leagueUrl}`;
7
30
  }
31
+
32
+ /**
33
+ * Asynchronously retrieves Divination Card data based on the specified properties.
34
+ *
35
+ * @async
36
+ * @param {Array<string>} requestedProperties - An array of properties to retrieve.
37
+ * @returns {Promise<Object>} A promise that resolves to the retrieved data.
38
+ */
8
39
  async getData(requestedProperties) {
9
- return getData(this.#queryUrl, requestedProperties);
40
+ try {
41
+ /**
42
+ * Calls the getData function to fetch Divination Card data.
43
+ *
44
+ * @type {Promise<Array<Object>>}
45
+ */
46
+ return getData(this.#queryUrl, requestedProperties);
47
+ } catch (error) {
48
+ /**
49
+ * Throws an error if there's an issue fetching or processing the Divination Card data.
50
+ *
51
+ * @throws {Error}
52
+ */
53
+ throw new Error(`Error fetching Divination Card data: ${error.message}`);
54
+ }
10
55
  }
11
56
  }
12
57
 
58
+ // Export the DivsModule class
13
59
  module.exports = DivsModule;
@@ -1,13 +1,59 @@
1
1
  const getData = require("../functions/getData");
2
2
 
3
+ /**
4
+ * Represents a module for fetching data related to Essences.
5
+ *
6
+ * @class
7
+ */
3
8
  class EssenceModule {
9
+ /**
10
+ * The query URL for fetching Essence data.
11
+ *
12
+ * @private
13
+ * @type {string}
14
+ */
4
15
  #queryUrl;
16
+
17
+ /**
18
+ * Creates an instance of EssenceModule.
19
+ *
20
+ * @param {string} leagueUrl - The league URL to fetch data from.
21
+ */
5
22
  constructor(leagueUrl) {
23
+ /**
24
+ * The constructed query URL for fetching Essence data.
25
+ *
26
+ * @private
27
+ * @type {string}
28
+ */
6
29
  this.#queryUrl = `essence${leagueUrl}`;
7
30
  }
31
+
32
+ /**
33
+ * Asynchronously retrieves Essence data based on the specified properties.
34
+ *
35
+ * @async
36
+ * @param {Array<string>} requestedProperties - An array of properties to retrieve.
37
+ * @returns {Promise<Object>} A promise that resolves to the retrieved data.
38
+ */
8
39
  async getData(requestedProperties) {
9
- return getData(this.#queryUrl, requestedProperties);
40
+ try {
41
+ /**
42
+ * Calls the getData function to fetch Essence data.
43
+ *
44
+ * @type {Promise<Array<Object>>}
45
+ */
46
+ return getData(this.#queryUrl, requestedProperties);
47
+ } catch (error) {
48
+ /**
49
+ * Throws an error if there's an issue fetching or processing the Essence data.
50
+ *
51
+ * @throws {Error}
52
+ */
53
+ throw new Error(`Error fetching Essence data: ${error.message}`);
54
+ }
10
55
  }
11
56
  }
12
57
 
58
+ // Export the EssenceModule class
13
59
  module.exports = EssenceModule;