poe-api-manager 1.0.0 → 1.2.2

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 (75) hide show
  1. package/.github/workflows/CI_CD.yml +53 -0
  2. package/Changelog.md +11 -0
  3. package/README.md +25 -12
  4. package/index.js +2 -0
  5. package/lib/Utils.js +15 -0
  6. package/lib/WatchAPI.js +1 -33
  7. package/lib/modules/poe.ninja/currency/CurrencyBaseClass.js +47 -0
  8. package/lib/modules/poe.ninja/currency/CurrencyWievModule.js +2 -27
  9. package/lib/modules/poe.ninja/currency/currencyFetch/fetchCurrency.js +5 -4
  10. package/lib/modules/poe.ninja/currency/currencySubmodules/subModules/CurrencyModule.js +33 -40
  11. package/lib/modules/poe.ninja/currency/currencySubmodules/subModules/FragmentModule.js +8 -52
  12. package/lib/modules/poe.ninja/currency/currencyUrlGenerator/CurrencyUrlGenerator.js +9 -0
  13. package/lib/modules/poe.ninja/currency/{currencySubmodules/functions → methods}/getData.js +4 -4
  14. package/lib/modules/poe.ninja/currency/methods/getQuickCurrency.js +28 -0
  15. package/lib/modules/poe.ninja/item/ItemBaseClass.js +40 -0
  16. package/lib/modules/poe.ninja/item/ItemWievModule.js +27 -52
  17. package/lib/modules/poe.ninja/item/itemFetch/fetchItem.js +5 -10
  18. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BaseTypeModule.js +8 -48
  19. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BeastModule.js +11 -46
  20. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BlightRavagedMapModule.js +9 -54
  21. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BlightedMapModule.js +7 -49
  22. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ClusterJewelModule.js +7 -52
  23. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/DeliriumOrbsModule.js +7 -52
  24. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/DivinationCardModule.js +7 -52
  25. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/EssenceModule.js +7 -52
  26. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/FossilModule.js +7 -52
  27. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/HelmetEnchantModule.js +7 -52
  28. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/IncubatorModule.js +7 -52
  29. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/InvitationModule.js +7 -52
  30. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/MapModule.js +7 -52
  31. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/MemoryModule.js +7 -52
  32. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/OilModule.js +7 -52
  33. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/OmenModule.js +7 -52
  34. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ResonatorModule.js +7 -52
  35. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ScarabModule.js +7 -52
  36. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/SkillGemModule.js +7 -52
  37. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueAccessoryModule.js +7 -52
  38. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueArmourModule.js +7 -52
  39. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueFlaskModule.js +7 -52
  40. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueJewelModule.js +7 -52
  41. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueMapModule.js +7 -52
  42. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueRelicModule.js +7 -52
  43. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueWeaponModule.js +7 -52
  44. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/VialsModule.js +7 -52
  45. package/lib/modules/poe.ninja/item/itemUrlGenerator/ItemUrlGenerator.js +9 -0
  46. package/lib/modules/poe.ninja/item/{itemSubmodules/functions → methods}/getData.js +5 -11
  47. package/lib/modules/poe.watch/allModules/WatchBaseClass.js +45 -0
  48. package/lib/modules/poe.watch/allModules/fetch/fetch.js +1 -4
  49. package/lib/modules/poe.watch/allModules/submodules/AccessoryModule.js +19 -62
  50. package/lib/modules/poe.watch/allModules/submodules/ArmourModule.js +19 -60
  51. package/lib/modules/poe.watch/allModules/submodules/BaseModule.js +19 -59
  52. package/lib/modules/poe.watch/allModules/submodules/BeastModule.js +13 -42
  53. package/lib/modules/poe.watch/allModules/submodules/CurrencyModule.js +13 -43
  54. package/lib/modules/poe.watch/allModules/submodules/DeliriumOrbModule.js +20 -42
  55. package/lib/modules/poe.watch/allModules/submodules/DivsModule.js +14 -43
  56. package/lib/modules/poe.watch/allModules/submodules/EssenceModule.js +13 -42
  57. package/lib/modules/poe.watch/allModules/submodules/FlaskModule.js +13 -42
  58. package/lib/modules/poe.watch/allModules/submodules/FossilModule.js +13 -42
  59. package/lib/modules/poe.watch/allModules/submodules/FragmentModule.js +13 -42
  60. package/lib/modules/poe.watch/allModules/submodules/GemModule.js +19 -61
  61. package/lib/modules/poe.watch/allModules/submodules/InscribedModule.js +13 -44
  62. package/lib/modules/poe.watch/allModules/submodules/InvitationModule.js +13 -42
  63. package/lib/modules/poe.watch/allModules/submodules/JewelModule.js +13 -42
  64. package/lib/modules/poe.watch/allModules/submodules/MapModule.js +13 -42
  65. package/lib/modules/poe.watch/allModules/submodules/OilModule.js +13 -42
  66. package/lib/modules/poe.watch/allModules/submodules/ScarabModule.js +13 -42
  67. package/lib/modules/poe.watch/allModules/submodules/SextantModule.js +13 -42
  68. package/lib/modules/poe.watch/allModules/submodules/UniqueMapsModule.js +13 -42
  69. package/lib/modules/poe.watch/allModules/submodules/WeaponModule.js +19 -59
  70. package/lib/modules/poe.watch/allModules/watchUrlGenerator/urlGenerator.js +9 -0
  71. package/package.json +4 -2
  72. package/lib/config/poeNinja/url.js +0 -12
  73. package/lib/config/poeWatch/url.js +0 -12
  74. /package/lib/modules/poe.watch/allModules/{functions → methods}/getCategory.js +0 -0
  75. /package/lib/modules/poe.watch/allModules/{functions → methods}/getData.js +0 -0
@@ -1,60 +1,15 @@
1
- const getData = require("../functions/getData");
2
-
1
+ const ItemBaseClass = require("../../ItemBaseClass");
3
2
  /**
4
- * Represents a module for fetching data related to Vials.
5
- *
6
- * @class
3
+ * Represents a module for handling vials.
4
+ * @extends ItemBaseClass
7
5
  */
8
- class VialsModule {
9
- /**
10
- * The URL for fetching data.
11
- *
12
- * @private
13
- * @type {string}
14
- */
15
- #url;
16
-
17
- /**
18
- * The type of data (Vial in this case).
19
- *
20
- * @private
21
- * @type {string}
22
- */
23
- #type;
24
-
6
+ class VialsModule extends ItemBaseClass {
25
7
  /**
26
8
  * Creates an instance of VialsModule.
27
- *
28
- * @param {string} url - The URL to fetch data from.
29
- */
30
- constructor(url) {
31
- this.#url = url;
32
- this.#type = "Vial";
33
- }
34
-
35
- /**
36
- * Asynchronously retrieves data based on the specified properties.
37
- *
38
- * @async
39
- * @param {Array<string>} requestedProperties - An array of properties to retrieve.
40
- * @returns {Promise<Object>} A promise that resolves to the retrieved data.
9
+ * @param {string} league - The league name.
41
10
  */
42
- async getData(requestedProperties) {
43
- try {
44
- /**
45
- * Calls the getData function to fetch Vial data.
46
- *
47
- * @type {Promise<Array<Object>>}
48
- */
49
- return getData(this.#url, this.#type, requestedProperties);
50
- } catch (error) {
51
- /**
52
- * Throws an error if there's an issue fetching or processing the Vial data.
53
- *
54
- * @throws {Error}
55
- */
56
- throw new Error(`Error fetching Vial data: ${error.message}`);
57
- }
11
+ constructor(league) {
12
+ super(league, "Vial");
58
13
  }
59
14
  }
60
15
 
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generates a URL based on league and type. poe.ninja (currencyView) API is used.
3
+ * @param {string} league - The league for which the URL is generated.
4
+ * @param {string} type - The type of data for which the URL is generated.
5
+ * @returns {string} - The generated URL.
6
+ */
7
+ module.exports = function urlGenerator(league, type) {
8
+ return `https://poe.ninja/api/data/itemoverview?league=${league}&type=${type}`;
9
+ };
@@ -1,28 +1,22 @@
1
- const fetchData = require("../../itemFetch/fetchItem");
2
- const filterProperties = require("../../../../mainfunctions/filter/propertyFilter");
1
+ const fetchData = require("../itemFetch/fetchItem");
2
+ const filterProperties = require("../../../mainfunctions/filter/propertyFilter");
3
3
 
4
4
  /**
5
5
  * Asynchronously fetches and filters item-related data from a specified URL.
6
6
  *
7
- * @param {string} url - The URL to fetch item-related data from.
7
+ * @param {string} league - The name of the current league.
8
8
  * @param {string} type - The type of item data to fetch.
9
9
  * @param {Array<string>} [requestedProperties] - (Optional) An array of property names to include in the filtered result.
10
10
  * @returns {Promise<Array<Object>|Object>} - A promise that resolves to the fetched or filtered item data.
11
11
  * @throws {Error} - Throws an error if there's an issue fetching or processing the data.
12
12
  */
13
- async function getData(url, type, requestedProperties) {
13
+ async function getData(league, type, requestedProperties) {
14
14
  try {
15
15
  // Fetch data using the fetchData function
16
- /**
17
- * @type {Array<Object>|Object} fetchedData - The fetched item data.
18
- */
19
- const fetchedData = await fetchData(url, type);
16
+ const fetchedData = await fetchData(league, type);
20
17
 
21
18
  // If requestedProperties are specified, filter the data based on those properties
22
19
  if (requestedProperties) {
23
- /**
24
- * @type {Array<Object>|Object} result - The filtered item data based on requested properties.
25
- */
26
20
  const result = filterProperties(fetchedData, requestedProperties);
27
21
  return result;
28
22
  } else {
@@ -0,0 +1,45 @@
1
+ const getData = require("./methods/getData");
2
+ const urlGenerator = require("./watchUrlGenerator/urlGenerator");
3
+
4
+ /**
5
+ * Basic class for handling data retrieval.
6
+ */
7
+ class WatchBaseClass {
8
+ /**
9
+ * Private field to store the query URL.
10
+ * @type {string}
11
+ * @private
12
+ */
13
+ #queryUrl;
14
+
15
+ /**
16
+ * Creates a new instance of WatchBaseClass.
17
+ * @param {string} league - The league from which the data will be fetched.
18
+ * @param {string} type - The type of data to be fetched.
19
+ */
20
+ constructor(league, type) {
21
+ /**
22
+ * Function that generates the query URL.
23
+ * @type {Function}
24
+ * @private
25
+ */
26
+ this.#queryUrl = urlGenerator(league, type);
27
+ }
28
+
29
+ /**
30
+ * Executes queries to fetch data.
31
+ * @async
32
+ * @param {Array<string>} requestedProperties - List of properties to be fetched.
33
+ * @returns {Promise<Array<Object>>} - A Promise containing an object with the requested properties.
34
+ * @throws {Error} - Throws errors encountered while fetching data.
35
+ */
36
+ async getData(requestedProperties) {
37
+ try {
38
+ return await getData(this.#queryUrl, requestedProperties);
39
+ } catch (error) {
40
+ throw new Error(`Error fetching WatchView data: ${error.message}`);
41
+ }
42
+ }
43
+ }
44
+
45
+ module.exports = WatchBaseClass;
@@ -1,5 +1,4 @@
1
1
  const axios = require("axios");
2
- const baseUrl = require("../../../../config/poeWatch/url").baseurl;
3
2
  /**
4
3
  * Fetches data from the POE Watch API based on the provided query URL.
5
4
  * @param {string} queryUrl - The query URL to be appended to the base URL.
@@ -8,9 +7,7 @@ const baseUrl = require("../../../../config/poeWatch/url").baseurl;
8
7
  */
9
8
  async function fetchData(queryUrl) {
10
9
  try {
11
- const url = `${baseUrl}${queryUrl}`;
12
-
13
- const response = await axios.get(url);
10
+ const response = await axios.get(queryUrl);
14
11
 
15
12
  if (response.data) {
16
13
  return response.data;
@@ -1,89 +1,46 @@
1
- const getData = require("../functions/getData");
2
- const getCategory = require("../functions/getCategory");
1
+ const WatchBaseClass = require("../WatchBaseClass");
2
+ const getCategory = require("../methods/getCategory");
3
+ const urlGenerator = require("../watchUrlGenerator/urlGenerator");
3
4
 
4
5
  /**
5
- * Represents a module for fetching data related to Accessories.
6
- *
7
- * @class
6
+ * Subclass of WatchBaseClass for accessing accessory data.
8
7
  */
9
- class AccessoryModule {
8
+ class AccessoryModule extends WatchBaseClass {
10
9
  /**
11
- * The query URL for fetching accessory data.
12
- *
13
- * @private
10
+ * The query URL for accessing accessory data.
14
11
  * @type {string}
12
+ * @private
15
13
  */
16
14
  #queryUrl;
17
-
18
15
  /**
19
- * Creates an instance of AccessoryModule.
20
- *
21
- * @param {string} leagueUrl - The league URL to fetch data from.
16
+ * Creates a new instance of AccessoryModule.
17
+ * @param {string} league - The league from which the data will be fetched.
22
18
  */
23
- constructor(leagueUrl) {
19
+ constructor(league) {
24
20
  /**
25
- * The constructed query URL for fetching accessory data.
26
- *
27
- * @private
21
+ * The type of data being accessed (accessory).
28
22
  * @type {string}
29
23
  */
30
- this.#queryUrl = `accessory${leagueUrl}`;
24
+ const type = "accessory";
25
+ super(league, type);
26
+ this.#queryUrl = urlGenerator(league, type);
31
27
  }
32
28
 
33
29
  /**
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
- */
40
- async getData(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
- *
30
+ * Retrieves category data for accessories.
60
31
  * @async
61
32
  * @param {string} categoryName - The name of the category to retrieve.
62
33
  * * 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
- *
34
+ * @returns {Promise<Array<Object>>} - A Promise containing data for the specified category.
35
+ * @throws {Error} - Throws errors encountered while fetching data.
66
36
  */
67
37
  async getCategory(categoryName) {
68
38
  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);
39
+ return await getCategory(this.#queryUrl, categoryName);
75
40
  } 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
- );
41
+ throw new Error(`Error fetching Accessory data: ${error.message}`);
84
42
  }
85
43
  }
86
44
  }
87
45
 
88
- // Export the AccessoryModule class
89
46
  module.exports = AccessoryModule;
@@ -1,87 +1,46 @@
1
- const getData = require("../functions/getData");
2
- const getCategory = require("../functions/getCategory");
1
+ const WatchBaseClass = require("../WatchBaseClass");
2
+ const getCategory = require("../methods/getCategory");
3
+ const urlGenerator = require("../watchUrlGenerator/urlGenerator");
3
4
 
4
5
  /**
5
- * Represents a module for fetching data related to Armour.
6
- *
7
- * @class
6
+ * Subclass of WatchBaseClass for accessing armour data.
8
7
  */
9
- class ArmourModule {
8
+ class ArmourModule extends WatchBaseClass {
10
9
  /**
11
- * The query URL for fetching armour data.
12
- *
13
- * @private
10
+ * The query URL for armour data.
14
11
  * @type {string}
12
+ * @private
15
13
  */
16
14
  #queryUrl;
17
-
18
15
  /**
19
- * Creates an instance of ArmourModule.
20
- *
21
- * @param {string} leagueUrl - The league URL to fetch data from.
16
+ * Creates a new instance of ArmourModule.
17
+ * @param {string} league - The league from which the data will be fetched.
22
18
  */
23
- constructor(leagueUrl) {
19
+ constructor(league) {
24
20
  /**
25
- * The constructed query URL for fetching armour data.
26
- *
27
- * @private
21
+ * The type of data being accessed (armour).
28
22
  * @type {string}
29
23
  */
30
- this.#queryUrl = `armour${leagueUrl}`;
24
+ const type = "armour";
25
+ super(league, type);
26
+ this.#queryUrl = urlGenerator(league, type);
31
27
  }
32
28
 
33
29
  /**
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
- */
40
- async getData(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
- *
30
+ * Retrieves category data for armour.
60
31
  * @async
61
32
  * @param {string} categoryName - The name of the category to retrieve.
62
33
  * * 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
- *
34
+ * @returns {Promise<Array<Object>>} - A Promise containing data for the specified category.
35
+ * @throws {Error} - Throws errors encountered while fetching data.
66
36
  */
67
37
  async getCategory(categoryName) {
68
38
  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);
39
+ return await getCategory(this.#queryUrl, categoryName);
75
40
  } 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}`);
41
+ throw new Error(`Error fetching Armour data: ${error.message}`);
82
42
  }
83
43
  }
84
44
  }
85
45
 
86
- // Export the ArmourModule class
87
46
  module.exports = ArmourModule;
@@ -1,87 +1,47 @@
1
- const getData = require("../functions/getData");
2
- const getCategory = require("../functions/getCategory");
1
+ const WatchBaseClass = require("../WatchBaseClass");
2
+ const getCategory = require("../methods/getCategory");
3
+ const urlGenerator = require("../watchUrlGenerator/urlGenerator");
3
4
 
4
5
  /**
5
- * Represents a module for fetching data related to Bases.
6
- *
7
- * @class
6
+ * Subclass of WatchBaseClass for accessing base data.
8
7
  */
9
- class BaseModule {
8
+ class BaseModule extends WatchBaseClass {
10
9
  /**
11
- * The query URL for fetching base data.
12
- *
13
- * @private
10
+ * The query URL for base data.
14
11
  * @type {string}
12
+ * @private
15
13
  */
16
14
  #queryUrl;
17
15
 
18
16
  /**
19
- * Creates an instance of BaseModule.
20
- *
21
- * @param {string} leagueUrl - The league URL to fetch data from.
17
+ * Creates a new instance of BaseModule.
18
+ * @param {string} league - The league from which the data will be fetched.
22
19
  */
23
- constructor(leagueUrl) {
20
+ constructor(league) {
24
21
  /**
25
- * The constructed query URL for fetching base data.
26
- *
27
- * @private
22
+ * The type of data being accessed (bases).
28
23
  * @type {string}
29
24
  */
30
- this.#queryUrl = `bases${leagueUrl}`;
25
+ const type = "bases";
26
+ super(league, type);
27
+ this.#queryUrl = urlGenerator(league, type);
31
28
  }
32
29
 
33
30
  /**
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
- */
40
- async getData(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
- *
31
+ * Retrieves category data for bases.
60
32
  * @async
61
33
  * @param {string} categoryName - The name of the category to retrieve.
62
34
  * * 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
- *
35
+ * @returns {Promise<Array<Object>>} - A Promise containing data for the specified category.
36
+ * @throws {Error} - Throws errors encountered while fetching data.
66
37
  */
67
38
  async getCategory(categoryName) {
68
39
  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);
40
+ return await getCategory(this.#queryUrl, categoryName);
75
41
  } 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}`);
42
+ throw new Error(`Error fetching Base data: ${error.message}`);
82
43
  }
83
44
  }
84
45
  }
85
46
 
86
- // Export the BaseModule class
87
47
  module.exports = BaseModule;
@@ -1,59 +1,30 @@
1
- const getData = require("../functions/getData");
1
+ const WatchBaseClass = require("../WatchBaseClass");
2
+ const urlGenerator = require("../watchUrlGenerator/urlGenerator");
2
3
 
3
4
  /**
4
- * Represents a module for fetching data related to Beasts.
5
- *
6
- * @class
5
+ * Subclass of WatchBaseClass for accessing beast data.
7
6
  */
8
- class BeastModule {
7
+ class BeastModule extends WatchBaseClass {
9
8
  /**
10
- * The query URL for fetching beast data.
11
- *
12
- * @private
9
+ * The query URL for beast data.
13
10
  * @type {string}
11
+ * @private
14
12
  */
15
13
  #queryUrl;
16
14
 
17
15
  /**
18
- * Creates an instance of BeastModule.
19
- *
20
- * @param {string} leagueUrl - The league URL to fetch data from.
16
+ * Creates a new instance of BeastModule.
17
+ * @param {string} league - The league from which the data will be fetched.
21
18
  */
22
- constructor(leagueUrl) {
19
+ constructor(league) {
23
20
  /**
24
- * The constructed query URL for fetching beast data.
25
- *
26
- * @private
21
+ * The type of data being accessed (beast).
27
22
  * @type {string}
28
23
  */
29
- this.#queryUrl = `beast${leagueUrl}`;
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
- */
39
- async getData(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
- }
24
+ const type = "beast";
25
+ super(league, type);
26
+ this.#queryUrl = urlGenerator(league, type);
55
27
  }
56
28
  }
57
29
 
58
- // Export the BeastModule class
59
30
  module.exports = BeastModule;
@@ -1,60 +1,30 @@
1
- const getData = require("../functions/getData");
1
+ const WatchBaseClass = require("../WatchBaseClass");
2
+ const urlGenerator = require("../watchUrlGenerator/urlGenerator");
2
3
 
3
4
  /**
4
- * Represents a module for fetching data related to Currency.
5
- *
6
- * @class
5
+ * Subclass of WatchBaseClass for accessing currency data.
7
6
  */
8
- class CurrencyModule {
7
+ class CurrencyModule extends WatchBaseClass {
9
8
  /**
10
- * The query URL for fetching currency data.
11
- *
12
- * @private
9
+ * The query URL for currency data.
13
10
  * @type {string}
11
+ * @private
14
12
  */
15
13
  #queryUrl;
16
14
 
17
15
  /**
18
- * Creates an instance of CurrencyModule.
19
- *
20
- * @param {string} leagueUrl - The league URL to fetch data from.
16
+ * Creates a new instance of CurrencyModule.
17
+ * @param {string} league - The league from which the data will be fetched.
21
18
  */
22
- constructor(leagueUrl) {
19
+ constructor(league) {
23
20
  /**
24
- * The constructed query URL for fetching currency data.
25
- *
26
- * @private
21
+ * The type of data being accessed (currency).
27
22
  * @type {string}
28
23
  */
29
- this.#queryUrl = `currency${leagueUrl}`;
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
- */
39
- async getData(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
- }
24
+ const type = "currency";
25
+ super(league, type);
26
+ this.#queryUrl = urlGenerator(league, type);
55
27
  }
56
28
  }
57
29
 
58
- // Uncomment the line below if you want to export the CurrencyModule class
59
- // module.exports = CurrencyModule;
60
30
  module.exports = CurrencyModule;