poe-api-manager 0.2.8 → 1.2.1

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 (71) hide show
  1. package/Changelog.md +12 -2
  2. package/README.md +31 -9
  3. package/index.js +4 -0
  4. package/lib/Utils.js +41 -0
  5. package/lib/WatchAPI.js +1 -33
  6. package/lib/modules/poe.ninja/currency/CurrencyBaseClass.js +37 -0
  7. package/lib/modules/poe.ninja/currency/CurrencyWievModule.js +2 -27
  8. package/lib/modules/poe.ninja/currency/currencySubmodules/subModules/CurrencyModule.js +8 -52
  9. package/lib/modules/poe.ninja/currency/currencySubmodules/subModules/FragmentModule.js +8 -52
  10. package/lib/modules/poe.ninja/currency/{currencySubmodules/functions → methods}/getData.js +2 -2
  11. package/lib/modules/poe.ninja/item/ItemBaseClass.js +64 -0
  12. package/lib/modules/poe.ninja/item/ItemWievModule.js +27 -52
  13. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BaseTypeModule.js +8 -48
  14. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BeastModule.js +8 -48
  15. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BlightRavagedMapModule.js +9 -54
  16. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BlightedMapModule.js +7 -49
  17. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ClusterJewelModule.js +7 -52
  18. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/DeliriumOrbsModule.js +7 -52
  19. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/DivinationCardModule.js +7 -52
  20. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/EssenceModule.js +7 -52
  21. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/FossilModule.js +7 -52
  22. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/HelmetEnchantModule.js +7 -52
  23. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/IncubatorModule.js +7 -52
  24. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/InvitationModule.js +7 -52
  25. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/MapModule.js +7 -52
  26. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/MemoryModule.js +7 -52
  27. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/OilModule.js +7 -52
  28. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/OmenModule.js +7 -52
  29. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ResonatorModule.js +7 -52
  30. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ScarabModule.js +7 -52
  31. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/SkillGemModule.js +7 -52
  32. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueAccessoryModule.js +7 -52
  33. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueArmourModule.js +7 -52
  34. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueFlaskModule.js +7 -52
  35. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueJewelModule.js +7 -52
  36. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueMapModule.js +7 -52
  37. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueRelicModule.js +7 -52
  38. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueWeaponModule.js +7 -52
  39. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/VialsModule.js +7 -52
  40. package/lib/modules/poe.ninja/item/{itemSubmodules/functions → methods}/getData.js +2 -2
  41. package/lib/modules/poe.watch/allModules/WatchBaseClass.js +45 -0
  42. package/lib/modules/poe.watch/allModules/fetch/fetch.js +1 -4
  43. package/lib/modules/poe.watch/allModules/submodules/AccessoryModule.js +19 -62
  44. package/lib/modules/poe.watch/allModules/submodules/ArmourModule.js +19 -60
  45. package/lib/modules/poe.watch/allModules/submodules/BaseModule.js +19 -59
  46. package/lib/modules/poe.watch/allModules/submodules/BeastModule.js +13 -42
  47. package/lib/modules/poe.watch/allModules/submodules/CurrencyModule.js +13 -43
  48. package/lib/modules/poe.watch/allModules/submodules/DeliriumOrbModule.js +20 -42
  49. package/lib/modules/poe.watch/allModules/submodules/DivsModule.js +14 -43
  50. package/lib/modules/poe.watch/allModules/submodules/EssenceModule.js +13 -42
  51. package/lib/modules/poe.watch/allModules/submodules/FlaskModule.js +13 -42
  52. package/lib/modules/poe.watch/allModules/submodules/FossilModule.js +13 -42
  53. package/lib/modules/poe.watch/allModules/submodules/FragmentModule.js +13 -42
  54. package/lib/modules/poe.watch/allModules/submodules/GemModule.js +19 -61
  55. package/lib/modules/poe.watch/allModules/submodules/InscribedModule.js +13 -44
  56. package/lib/modules/poe.watch/allModules/submodules/InvitationModule.js +13 -42
  57. package/lib/modules/poe.watch/allModules/submodules/JewelModule.js +13 -42
  58. package/lib/modules/poe.watch/allModules/submodules/MapModule.js +13 -42
  59. package/lib/modules/poe.watch/allModules/submodules/OilModule.js +13 -42
  60. package/lib/modules/poe.watch/allModules/submodules/ScarabModule.js +13 -42
  61. package/lib/modules/poe.watch/allModules/submodules/SextantModule.js +13 -42
  62. package/lib/modules/poe.watch/allModules/submodules/UniqueMapsModule.js +13 -42
  63. package/lib/modules/poe.watch/allModules/submodules/WeaponModule.js +19 -59
  64. package/lib/modules/poe.watch/allModules/watchUrlGenerator/urlGenerator.js +9 -0
  65. package/lib/modules/utils/functions/fetch/fetch.js +22 -0
  66. package/lib/modules/utils/getLeagues.js +24 -0
  67. package/package.json +1 -1
  68. package/lib/config/poeNinja/url.js +0 -12
  69. package/lib/config/poeWatch/url.js +0 -12
  70. /package/lib/modules/poe.watch/allModules/{functions → methods}/getCategory.js +0 -0
  71. /package/lib/modules/poe.watch/allModules/{functions → methods}/getData.js +0 -0
@@ -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 Divination Cards.
5
- *
6
- * @class
5
+ * Subclass of WatchBaseClass for accessing divination card data.
7
6
  */
8
- class DivsModule {
7
+ class DivModule extends WatchBaseClass {
9
8
  /**
10
- * The query URL for fetching Divination Card data.
11
- *
12
- * @private
9
+ * The query URL for divination card data.
13
10
  * @type {string}
11
+ * @private
14
12
  */
15
13
  #queryUrl;
16
14
 
17
15
  /**
18
- * Creates an instance of DivsModule.
19
- *
20
- * @param {string} leagueUrl - The league URL to fetch data from.
16
+ * Creates a new instance of DivModule.
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 Divination Card data.
25
- *
26
- * @private
21
+ * The type of data being accessed (div).
27
22
  * @type {string}
28
23
  */
29
- this.#queryUrl = `currency${leagueUrl}`;
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
- */
39
- async getData(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
- }
24
+ const type = "div";
25
+ super(league, type);
26
+ this.#queryUrl = urlGenerator(league, type);
55
27
  }
56
28
  }
57
29
 
58
- // Export the DivsModule class
59
- module.exports = DivsModule;
30
+ module.exports = DivModule;
@@ -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 Essences.
5
- *
6
- * @class
5
+ * Subclass of WatchBaseClass for accessing essence data.
7
6
  */
8
- class EssenceModule {
7
+ class EssenceModule extends WatchBaseClass {
9
8
  /**
10
- * The query URL for fetching Essence data.
11
- *
12
- * @private
9
+ * The query URL for essence data.
13
10
  * @type {string}
11
+ * @private
14
12
  */
15
13
  #queryUrl;
16
14
 
17
15
  /**
18
- * Creates an instance of EssenceModule.
19
- *
20
- * @param {string} leagueUrl - The league URL to fetch data from.
16
+ * Creates a new instance of EssenceModule.
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 Essence data.
25
- *
26
- * @private
21
+ * The type of data being accessed (essence).
27
22
  * @type {string}
28
23
  */
29
- this.#queryUrl = `essence${leagueUrl}`;
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
- */
39
- async getData(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
- }
24
+ const type = "essence";
25
+ super(league, type);
26
+ this.#queryUrl = urlGenerator(league, type);
55
27
  }
56
28
  }
57
29
 
58
- // Export the EssenceModule class
59
30
  module.exports = EssenceModule;
@@ -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 Flasks.
5
- *
6
- * @class
5
+ * Subclass of WatchBaseClass for accessing flask data.
7
6
  */
8
- class FlaskModule {
7
+ class FlaskModule extends WatchBaseClass {
9
8
  /**
10
- * The query URL for fetching Flask data.
11
- *
12
- * @private
9
+ * The query URL for flask data.
13
10
  * @type {string}
11
+ * @private
14
12
  */
15
13
  #queryUrl;
16
14
 
17
15
  /**
18
- * Creates an instance of FlaskModule.
19
- *
20
- * @param {string} leagueUrl - The league URL to fetch data from.
16
+ * Creates a new instance of FlaskModule.
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 Flask data.
25
- *
26
- * @private
21
+ * The type of data being accessed (flask).
27
22
  * @type {string}
28
23
  */
29
- this.#queryUrl = `flask${leagueUrl}`;
30
- }
31
-
32
- /**
33
- * Asynchronously retrieves Flask 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 Flask 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 Flask data.
50
- *
51
- * @throws {Error}
52
- */
53
- throw new Error(`Error fetching Flask data: ${error.message}`);
54
- }
24
+ const type = "flask";
25
+ super(league, type);
26
+ this.#queryUrl = urlGenerator(league, type);
55
27
  }
56
28
  }
57
29
 
58
- // Export the FlaskModule class
59
30
  module.exports = FlaskModule;
@@ -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 Fossils.
5
- *
6
- * @class
5
+ * Subclass of WatchBaseClass for accessing fossil data.
7
6
  */
8
- class FossilModule {
7
+ class FossilModule extends WatchBaseClass {
9
8
  /**
10
- * The query URL for fetching Fossil data.
11
- *
12
- * @private
9
+ * The query URL for fossil data.
13
10
  * @type {string}
11
+ * @private
14
12
  */
15
13
  #queryUrl;
16
14
 
17
15
  /**
18
- * Creates an instance of FossilModule.
19
- *
20
- * @param {string} leagueUrl - The league URL to fetch data from.
16
+ * Creates a new instance of FossilModule.
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 Fossil data.
25
- *
26
- * @private
21
+ * The type of data being accessed (fossil).
27
22
  * @type {string}
28
23
  */
29
- this.#queryUrl = `fossil${leagueUrl}`;
30
- }
31
-
32
- /**
33
- * Asynchronously retrieves Fossil 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 Fossil 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 Fossil data.
50
- *
51
- * @throws {Error}
52
- */
53
- throw new Error(`Error fetching Fossil data: ${error.message}`);
54
- }
24
+ const type = "fossil";
25
+ super(league, type);
26
+ this.#queryUrl = urlGenerator(league, type);
55
27
  }
56
28
  }
57
29
 
58
- // Export the FossilModule class
59
30
  module.exports = FossilModule;
@@ -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 Fragments.
5
- *
6
- * @class
5
+ * Subclass of WatchBaseClass for accessing fragment data.
7
6
  */
8
- class FragmentModule {
7
+ class FragmentModule extends WatchBaseClass {
9
8
  /**
10
- * The query URL for fetching Fragment data.
11
- *
12
- * @private
9
+ * The query URL for fragment data.
13
10
  * @type {string}
11
+ * @private
14
12
  */
15
13
  #queryUrl;
16
14
 
17
15
  /**
18
- * Creates an instance of FragmentModule.
19
- *
20
- * @param {string} leagueUrl - The league URL to fetch data from.
16
+ * Creates a new instance of FragmentModule.
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 Fragment data.
25
- *
26
- * @private
21
+ * The type of data being accessed (fragment).
27
22
  * @type {string}
28
23
  */
29
- this.#queryUrl = `fragment${leagueUrl}`;
30
- }
31
-
32
- /**
33
- * Asynchronously retrieves Fragment 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 Fragment 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 Fragment data.
50
- *
51
- * @throws {Error}
52
- */
53
- throw new Error(`Error fetching Fragment data: ${error.message}`);
54
- }
24
+ const type = "fragment";
25
+ super(league, type);
26
+ this.#queryUrl = urlGenerator(league, type);
55
27
  }
56
28
  }
57
29
 
58
- // Export the FragmentModule class
59
30
  module.exports = FragmentModule;
@@ -1,88 +1,46 @@
1
- const getData = require("../functions/getData");
1
+ const WatchBaseClass = require("../WatchBaseClass");
2
+ const getCategory = require("../methods/getCategory");
3
+ const urlGenerator = require("../watchUrlGenerator/urlGenerator");
2
4
 
3
5
  /**
4
- * Represents a module for fetching data related to Skill Gems.
5
- *
6
- * @class
6
+ * Subclass of WatchBaseClass for accessing gem data.
7
7
  */
8
- class GemModule {
8
+ class GemModule extends WatchBaseClass {
9
9
  /**
10
- * The query URL for fetching Skill Gem data.
11
- *
12
- * @private
10
+ * The query URL for gem data.
13
11
  * @type {string}
12
+ * @private
14
13
  */
15
14
  #queryUrl;
16
15
 
17
16
  /**
18
- * Creates an instance of GemModule.
19
- *
20
- * @param {string} leagueUrl - The league URL to fetch data from.
17
+ * Creates a new instance of GemModule.
18
+ * @param {string} league - The league from which the data will be fetched.
21
19
  */
22
- constructor(leagueUrl) {
20
+ constructor(league) {
23
21
  /**
24
- * The constructed query URL for fetching Skill Gem data.
25
- *
26
- * @private
22
+ * The type of data being accessed (gem).
27
23
  * @type {string}
28
24
  */
29
- this.#queryUrl = `gem${leagueUrl}`;
25
+ const type = "gem";
26
+ super(league, type);
27
+ this.#queryUrl = urlGenerator(league, type);
30
28
  }
31
29
 
32
30
  /**
33
- * Asynchronously retrieves Skill Gem 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 Skill Gem 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 Skill Gem data.
50
- *
51
- * @throws {Error}
52
- */
53
- throw new Error(`Error fetching Skill Gem data: ${error.message}`);
54
- }
55
- }
56
- /**
57
- * Asynchronously retrieves gems data based on the specified category name.
58
- *
31
+ * Retrieves category data for gems.
59
32
  * @async
60
33
  * @param {string} categoryName - The name of the category to retrieve.
61
- * * Possible values: "supportgem", "gems".
62
- * @returns {Promise<Array<Object>>} - A promise that resolves to the retrieved data.
63
- * @throws {Error} - Throws an error if there is an issue fetching or processing the gems data for the specified category.
64
- *
34
+ * @returns {Promise<Array<Object>>} - A Promise containing data for the specified category.
35
+ * @throws {Error} - Throws errors encountered while fetching data.
65
36
  */
66
37
  async getCategory(categoryName) {
67
38
  try {
68
- /**
69
- * Calls the getCategory function to fetch gems data based on category name.
70
- *
71
- * @type {Promise<Array<Object>>}
72
- */
73
- return getCategory(this.#queryUrl, categoryName);
39
+ return await getCategory(this.#queryUrl, categoryName);
74
40
  } catch (error) {
75
- /**
76
- * Throws an error if there's an issue fetching or processing the gems data for the specified category.
77
- *
78
- * @throws {Error}
79
- */
80
- throw new Error(
81
- `Error fetching data Skill Gem Category: ${error.message}`
82
- );
41
+ throw new Error(`Error fetching Gem data: ${error.message}`);
83
42
  }
84
43
  }
85
44
  }
86
45
 
87
- // Export the GemModule class
88
46
  module.exports = GemModule;
@@ -1,61 +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 Inscribed Ultimatums.
5
- *
6
- * @class
5
+ * Subclass of WatchBaseClass for accessing inscribed item data.
7
6
  */
8
- class InscribedModule {
7
+ class InscribedModule extends WatchBaseClass {
9
8
  /**
10
- * The query URL for fetching Inscribed Ultimatum data.
11
- *
12
- * @private
9
+ * The query URL for inscribed item data.
13
10
  * @type {string}
11
+ * @private
14
12
  */
15
13
  #queryUrl;
16
14
 
17
15
  /**
18
- * Creates an instance of InscribedModule.
19
- *
20
- * @param {string} leagueUrl - The league URL to fetch data from.
16
+ * Creates a new instance of InscribedModule.
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 Inscribed Ultimatum data.
25
- *
26
- * @private
21
+ * The type of data being accessed (inscribed).
27
22
  * @type {string}
28
23
  */
29
- this.#queryUrl = `currency${leagueUrl}`;
30
- }
31
-
32
- /**
33
- * Asynchronously retrieves Inscribed Ultimatum 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 Inscribed Ultimatum 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 Inscribed Ultimatum data.
50
- *
51
- * @throws {Error}
52
- */
53
- throw new Error(
54
- `Error fetching Inscribed Ultimatum data: ${error.message}`
55
- );
56
- }
24
+ const type = "inscribed";
25
+ super(league, type);
26
+ this.#queryUrl = urlGenerator(league, type);
57
27
  }
58
28
  }
59
29
 
60
- // Export the InscribedModule class
61
30
  module.exports = InscribedModule;
@@ -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 Invitations.
5
- *
6
- * @class
5
+ * Subclass of WatchBaseClass for accessing invitation data.
7
6
  */
8
- class InvitationModule {
7
+ class InvitationModule extends WatchBaseClass {
9
8
  /**
10
- * The query URL for fetching Invitation data.
11
- *
12
- * @private
9
+ * The query URL for invitation data.
13
10
  * @type {string}
11
+ * @private
14
12
  */
15
13
  #queryUrl;
16
14
 
17
15
  /**
18
- * Creates an instance of InvitationModule.
19
- *
20
- * @param {string} leagueUrl - The league URL to fetch data from.
16
+ * Creates a new instance of InvitationModule.
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 Invitation data.
25
- *
26
- * @private
21
+ * The type of data being accessed (invitation).
27
22
  * @type {string}
28
23
  */
29
- this.#queryUrl = `invitation${leagueUrl}`;
30
- }
31
-
32
- /**
33
- * Asynchronously retrieves Invitation 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 Invitation 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 Invitation data.
50
- *
51
- * @throws {Error}
52
- */
53
- throw new Error(`Error fetching Invitation data: ${error.message}`);
54
- }
24
+ const type = "invitation";
25
+ super(league, type);
26
+ this.#queryUrl = urlGenerator(league, type);
55
27
  }
56
28
  }
57
29
 
58
- // Export the InvitationModule class
59
30
  module.exports = InvitationModule;