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.
- package/Changelog.md +12 -2
- package/README.md +31 -9
- package/index.js +4 -0
- package/lib/Utils.js +41 -0
- package/lib/WatchAPI.js +1 -33
- package/lib/modules/poe.ninja/currency/CurrencyBaseClass.js +37 -0
- package/lib/modules/poe.ninja/currency/CurrencyWievModule.js +2 -27
- package/lib/modules/poe.ninja/currency/currencySubmodules/subModules/CurrencyModule.js +8 -52
- package/lib/modules/poe.ninja/currency/currencySubmodules/subModules/FragmentModule.js +8 -52
- package/lib/modules/poe.ninja/currency/{currencySubmodules/functions → methods}/getData.js +2 -2
- package/lib/modules/poe.ninja/item/ItemBaseClass.js +64 -0
- package/lib/modules/poe.ninja/item/ItemWievModule.js +27 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BaseTypeModule.js +8 -48
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BeastModule.js +8 -48
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BlightRavagedMapModule.js +9 -54
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BlightedMapModule.js +7 -49
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ClusterJewelModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/DeliriumOrbsModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/DivinationCardModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/EssenceModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/FossilModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/HelmetEnchantModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/IncubatorModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/InvitationModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/MapModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/MemoryModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/OilModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/OmenModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ResonatorModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ScarabModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/SkillGemModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueAccessoryModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueArmourModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueFlaskModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueJewelModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueMapModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueRelicModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueWeaponModule.js +7 -52
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/VialsModule.js +7 -52
- package/lib/modules/poe.ninja/item/{itemSubmodules/functions → methods}/getData.js +2 -2
- package/lib/modules/poe.watch/allModules/WatchBaseClass.js +45 -0
- package/lib/modules/poe.watch/allModules/fetch/fetch.js +1 -4
- package/lib/modules/poe.watch/allModules/submodules/AccessoryModule.js +19 -62
- package/lib/modules/poe.watch/allModules/submodules/ArmourModule.js +19 -60
- package/lib/modules/poe.watch/allModules/submodules/BaseModule.js +19 -59
- package/lib/modules/poe.watch/allModules/submodules/BeastModule.js +13 -42
- package/lib/modules/poe.watch/allModules/submodules/CurrencyModule.js +13 -43
- package/lib/modules/poe.watch/allModules/submodules/DeliriumOrbModule.js +20 -42
- package/lib/modules/poe.watch/allModules/submodules/DivsModule.js +14 -43
- package/lib/modules/poe.watch/allModules/submodules/EssenceModule.js +13 -42
- package/lib/modules/poe.watch/allModules/submodules/FlaskModule.js +13 -42
- package/lib/modules/poe.watch/allModules/submodules/FossilModule.js +13 -42
- package/lib/modules/poe.watch/allModules/submodules/FragmentModule.js +13 -42
- package/lib/modules/poe.watch/allModules/submodules/GemModule.js +19 -61
- package/lib/modules/poe.watch/allModules/submodules/InscribedModule.js +13 -44
- package/lib/modules/poe.watch/allModules/submodules/InvitationModule.js +13 -42
- package/lib/modules/poe.watch/allModules/submodules/JewelModule.js +13 -42
- package/lib/modules/poe.watch/allModules/submodules/MapModule.js +13 -42
- package/lib/modules/poe.watch/allModules/submodules/OilModule.js +13 -42
- package/lib/modules/poe.watch/allModules/submodules/ScarabModule.js +13 -42
- package/lib/modules/poe.watch/allModules/submodules/SextantModule.js +13 -42
- package/lib/modules/poe.watch/allModules/submodules/UniqueMapsModule.js +13 -42
- package/lib/modules/poe.watch/allModules/submodules/WeaponModule.js +19 -59
- package/lib/modules/poe.watch/allModules/watchUrlGenerator/urlGenerator.js +9 -0
- package/lib/modules/utils/functions/fetch/fetch.js +22 -0
- package/lib/modules/utils/getLeagues.js +24 -0
- package/package.json +1 -1
- package/lib/config/poeNinja/url.js +0 -12
- package/lib/config/poeWatch/url.js +0 -12
- /package/lib/modules/poe.watch/allModules/{functions → methods}/getCategory.js +0 -0
- /package/lib/modules/poe.watch/allModules/{functions → methods}/getData.js +0 -0
|
@@ -1,59 +1,30 @@
|
|
|
1
|
-
const
|
|
1
|
+
const WatchBaseClass = require("../WatchBaseClass");
|
|
2
|
+
const urlGenerator = require("../watchUrlGenerator/urlGenerator");
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @class
|
|
5
|
+
* Subclass of WatchBaseClass for accessing jewel data.
|
|
7
6
|
*/
|
|
8
|
-
class JewelModule {
|
|
7
|
+
class JewelModule extends WatchBaseClass {
|
|
9
8
|
/**
|
|
10
|
-
* The query URL for
|
|
11
|
-
*
|
|
12
|
-
* @private
|
|
9
|
+
* The query URL for jewel data.
|
|
13
10
|
* @type {string}
|
|
11
|
+
* @private
|
|
14
12
|
*/
|
|
15
13
|
#queryUrl;
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
|
-
* Creates
|
|
19
|
-
*
|
|
20
|
-
* @param {string} leagueUrl - The league URL to fetch data from.
|
|
16
|
+
* Creates a new instance of JewelModule.
|
|
17
|
+
* @param {string} league - The league from which the data will be fetched.
|
|
21
18
|
*/
|
|
22
|
-
constructor(
|
|
19
|
+
constructor(league) {
|
|
23
20
|
/**
|
|
24
|
-
* The
|
|
25
|
-
*
|
|
26
|
-
* @private
|
|
21
|
+
* The type of data being accessed (jewel).
|
|
27
22
|
* @type {string}
|
|
28
23
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Asynchronously retrieves Jewel 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 Jewel 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 Jewel data.
|
|
50
|
-
*
|
|
51
|
-
* @throws {Error}
|
|
52
|
-
*/
|
|
53
|
-
throw new Error(`Error fetching Jewel data: ${error.message}`);
|
|
54
|
-
}
|
|
24
|
+
const type = "jewel";
|
|
25
|
+
super(league, type);
|
|
26
|
+
this.#queryUrl = urlGenerator(league, type);
|
|
55
27
|
}
|
|
56
28
|
}
|
|
57
29
|
|
|
58
|
-
// Export the JewelModule class
|
|
59
30
|
module.exports = JewelModule;
|
|
@@ -1,59 +1,30 @@
|
|
|
1
|
-
const
|
|
1
|
+
const WatchBaseClass = require("../WatchBaseClass");
|
|
2
|
+
const urlGenerator = require("../watchUrlGenerator/urlGenerator");
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @class
|
|
5
|
+
* Subclass of WatchBaseClass for accessing map data.
|
|
7
6
|
*/
|
|
8
|
-
class MapModule {
|
|
7
|
+
class MapModule extends WatchBaseClass {
|
|
9
8
|
/**
|
|
10
|
-
* The query URL for
|
|
11
|
-
*
|
|
12
|
-
* @private
|
|
9
|
+
* The query URL for map data.
|
|
13
10
|
* @type {string}
|
|
11
|
+
* @private
|
|
14
12
|
*/
|
|
15
13
|
#queryUrl;
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
|
-
* Creates
|
|
19
|
-
*
|
|
20
|
-
* @param {string} leagueUrl - The league URL to fetch data from.
|
|
16
|
+
* Creates a new instance of MapModule.
|
|
17
|
+
* @param {string} league - The league from which the data will be fetched.
|
|
21
18
|
*/
|
|
22
|
-
constructor(
|
|
19
|
+
constructor(league) {
|
|
23
20
|
/**
|
|
24
|
-
* The
|
|
25
|
-
*
|
|
26
|
-
* @private
|
|
21
|
+
* The type of data being accessed (map).
|
|
27
22
|
* @type {string}
|
|
28
23
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Asynchronously retrieves Map 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 Map 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 Map data.
|
|
50
|
-
*
|
|
51
|
-
* @throws {Error}
|
|
52
|
-
*/
|
|
53
|
-
throw new Error(`Error fetching Map data: ${error.message}`);
|
|
54
|
-
}
|
|
24
|
+
const type = "map";
|
|
25
|
+
super(league, type);
|
|
26
|
+
this.#queryUrl = urlGenerator(league, type);
|
|
55
27
|
}
|
|
56
28
|
}
|
|
57
29
|
|
|
58
|
-
// Export the MapModule class
|
|
59
30
|
module.exports = MapModule;
|
|
@@ -1,59 +1,30 @@
|
|
|
1
|
-
const
|
|
1
|
+
const WatchBaseClass = require("../WatchBaseClass");
|
|
2
|
+
const urlGenerator = require("../watchUrlGenerator/urlGenerator");
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @class
|
|
5
|
+
* Subclass of WatchBaseClass for accessing oil data.
|
|
7
6
|
*/
|
|
8
|
-
class OilModule {
|
|
7
|
+
class OilModule extends WatchBaseClass {
|
|
9
8
|
/**
|
|
10
|
-
* The query URL for
|
|
11
|
-
*
|
|
12
|
-
* @private
|
|
9
|
+
* The query URL for oil data.
|
|
13
10
|
* @type {string}
|
|
11
|
+
* @private
|
|
14
12
|
*/
|
|
15
13
|
#queryUrl;
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
|
-
* Creates
|
|
19
|
-
*
|
|
20
|
-
* @param {string} leagueUrl - The league URL to fetch data from.
|
|
16
|
+
* Creates a new instance of OilModule.
|
|
17
|
+
* @param {string} league - The league from which the data will be fetched.
|
|
21
18
|
*/
|
|
22
|
-
constructor(
|
|
19
|
+
constructor(league) {
|
|
23
20
|
/**
|
|
24
|
-
* The
|
|
25
|
-
*
|
|
26
|
-
* @private
|
|
21
|
+
* The type of data being accessed (oil).
|
|
27
22
|
* @type {string}
|
|
28
23
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Asynchronously retrieves Oil 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 Oil 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 Oil data.
|
|
50
|
-
*
|
|
51
|
-
* @throws {Error}
|
|
52
|
-
*/
|
|
53
|
-
throw new Error(`Error fetching Oil data: ${error.message}`);
|
|
54
|
-
}
|
|
24
|
+
const type = "oil";
|
|
25
|
+
super(league, type);
|
|
26
|
+
this.#queryUrl = urlGenerator(league, type);
|
|
55
27
|
}
|
|
56
28
|
}
|
|
57
29
|
|
|
58
|
-
// Export the OilModule class
|
|
59
30
|
module.exports = OilModule;
|
|
@@ -1,59 +1,30 @@
|
|
|
1
|
-
const
|
|
1
|
+
const WatchBaseClass = require("../WatchBaseClass");
|
|
2
|
+
const urlGenerator = require("../watchUrlGenerator/urlGenerator");
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @class
|
|
5
|
+
* Subclass of WatchBaseClass for accessing scarab data.
|
|
7
6
|
*/
|
|
8
|
-
class ScarabModule {
|
|
7
|
+
class ScarabModule extends WatchBaseClass {
|
|
9
8
|
/**
|
|
10
|
-
* The query URL for
|
|
11
|
-
*
|
|
12
|
-
* @private
|
|
9
|
+
* The query URL for scarab data.
|
|
13
10
|
* @type {string}
|
|
11
|
+
* @private
|
|
14
12
|
*/
|
|
15
13
|
#queryUrl;
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
|
-
* Creates
|
|
19
|
-
*
|
|
20
|
-
* @param {string} leagueUrl - The league URL to fetch data from.
|
|
16
|
+
* Creates a new instance of ScarabModule.
|
|
17
|
+
* @param {string} league - The league from which the data will be fetched.
|
|
21
18
|
*/
|
|
22
|
-
constructor(
|
|
19
|
+
constructor(league) {
|
|
23
20
|
/**
|
|
24
|
-
* The
|
|
25
|
-
*
|
|
26
|
-
* @private
|
|
21
|
+
* The type of data being accessed (scarab).
|
|
27
22
|
* @type {string}
|
|
28
23
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Asynchronously retrieves Scarab 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 Scarab 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 Scarab data.
|
|
50
|
-
*
|
|
51
|
-
* @throws {Error}
|
|
52
|
-
*/
|
|
53
|
-
throw new Error(`Error fetching Scarab data: ${error.message}`);
|
|
54
|
-
}
|
|
24
|
+
const type = "scarab";
|
|
25
|
+
super(league, type);
|
|
26
|
+
this.#queryUrl = urlGenerator(league, type);
|
|
55
27
|
}
|
|
56
28
|
}
|
|
57
29
|
|
|
58
|
-
// Export the ScarabModule class
|
|
59
30
|
module.exports = ScarabModule;
|
|
@@ -1,59 +1,30 @@
|
|
|
1
|
-
const
|
|
1
|
+
const WatchBaseClass = require("../WatchBaseClass");
|
|
2
|
+
const urlGenerator = require("../watchUrlGenerator/urlGenerator");
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @class
|
|
5
|
+
* Subclass of WatchBaseClass for accessing sextant data.
|
|
7
6
|
*/
|
|
8
|
-
class SextantModule {
|
|
7
|
+
class SextantModule extends WatchBaseClass {
|
|
9
8
|
/**
|
|
10
|
-
* The query URL for
|
|
11
|
-
*
|
|
12
|
-
* @private
|
|
9
|
+
* The query URL for sextant data.
|
|
13
10
|
* @type {string}
|
|
11
|
+
* @private
|
|
14
12
|
*/
|
|
15
13
|
#queryUrl;
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
|
-
* Creates
|
|
19
|
-
*
|
|
20
|
-
* @param {string} leagueUrl - The league URL to fetch data from.
|
|
16
|
+
* Creates a new instance of SextantModule.
|
|
17
|
+
* @param {string} league - The league from which the data will be fetched.
|
|
21
18
|
*/
|
|
22
|
-
constructor(
|
|
19
|
+
constructor(league) {
|
|
23
20
|
/**
|
|
24
|
-
* The
|
|
25
|
-
*
|
|
26
|
-
* @private
|
|
21
|
+
* The type of data being accessed (sextants).
|
|
27
22
|
* @type {string}
|
|
28
23
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Asynchronously retrieves Sextant 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 Sextant 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 Sextant data.
|
|
50
|
-
*
|
|
51
|
-
* @throws {Error}
|
|
52
|
-
*/
|
|
53
|
-
throw new Error(`Error fetching Sextant data: ${error.message}`);
|
|
54
|
-
}
|
|
24
|
+
const type = "sextants";
|
|
25
|
+
super(league, type);
|
|
26
|
+
this.#queryUrl = urlGenerator(league, type);
|
|
55
27
|
}
|
|
56
28
|
}
|
|
57
29
|
|
|
58
|
-
// Export the SextantModule class
|
|
59
30
|
module.exports = SextantModule;
|
|
@@ -1,59 +1,30 @@
|
|
|
1
|
-
const
|
|
1
|
+
const WatchBaseClass = require("../WatchBaseClass");
|
|
2
|
+
const urlGenerator = require("../watchUrlGenerator/urlGenerator");
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @class
|
|
5
|
+
* Subclass of WatchBaseClass for accessing unique maps data.
|
|
7
6
|
*/
|
|
8
|
-
class UniqueMapsModule {
|
|
7
|
+
class UniqueMapsModule extends WatchBaseClass {
|
|
9
8
|
/**
|
|
10
|
-
* The query URL for
|
|
11
|
-
*
|
|
12
|
-
* @private
|
|
9
|
+
* The query URL for unique maps data.
|
|
13
10
|
* @type {string}
|
|
11
|
+
* @private
|
|
14
12
|
*/
|
|
15
13
|
#queryUrl;
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
|
-
* Creates
|
|
19
|
-
*
|
|
20
|
-
* @param {string} leagueUrl - The league URL to fetch data from.
|
|
16
|
+
* Creates a new instance of UniqueMapsModule.
|
|
17
|
+
* @param {string} league - The league from which the data will be fetched.
|
|
21
18
|
*/
|
|
22
|
-
constructor(
|
|
19
|
+
constructor(league) {
|
|
23
20
|
/**
|
|
24
|
-
* The
|
|
25
|
-
*
|
|
26
|
-
* @private
|
|
21
|
+
* The type of data being accessed (uniqueMaps).
|
|
27
22
|
* @type {string}
|
|
28
23
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Asynchronously retrieves Unique Maps 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 Unique Maps 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 Unique Maps data.
|
|
50
|
-
*
|
|
51
|
-
* @throws {Error}
|
|
52
|
-
*/
|
|
53
|
-
throw new Error(`Error fetching Unique Maps data: ${error.message}`);
|
|
54
|
-
}
|
|
24
|
+
const type = "uniqueMaps";
|
|
25
|
+
super(league, type);
|
|
26
|
+
this.#queryUrl = urlGenerator(league, type);
|
|
55
27
|
}
|
|
56
28
|
}
|
|
57
29
|
|
|
58
|
-
// Export the UniqueMapsModule class
|
|
59
30
|
module.exports = UniqueMapsModule;
|
|
@@ -1,87 +1,47 @@
|
|
|
1
|
-
const
|
|
2
|
-
const getCategory = require("../
|
|
1
|
+
const WatchBaseClass = require("../WatchBaseClass");
|
|
2
|
+
const getCategory = require("../methods/getCategory");
|
|
3
|
+
const urlGenerator = require("../watchUrlGenerator/urlGenerator");
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @class
|
|
6
|
+
* Subclass of WatchBaseClass for accessing weapon data.
|
|
8
7
|
*/
|
|
9
|
-
class WeaponModule {
|
|
8
|
+
class WeaponModule extends WatchBaseClass {
|
|
10
9
|
/**
|
|
11
|
-
* The query URL for
|
|
12
|
-
*
|
|
13
|
-
* @private
|
|
10
|
+
* The query URL for weapon data.
|
|
14
11
|
* @type {string}
|
|
12
|
+
* @private
|
|
15
13
|
*/
|
|
16
14
|
#queryUrl;
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
|
-
* Creates
|
|
20
|
-
*
|
|
21
|
-
* @param {string} leagueUrl - The league URL to fetch data from.
|
|
17
|
+
* Creates a new instance of WeaponModule.
|
|
18
|
+
* @param {string} league - The league from which the data will be fetched.
|
|
22
19
|
*/
|
|
23
|
-
constructor(
|
|
20
|
+
constructor(league) {
|
|
24
21
|
/**
|
|
25
|
-
* The
|
|
26
|
-
*
|
|
27
|
-
* @private
|
|
22
|
+
* The type of data being accessed (weapon).
|
|
28
23
|
* @type {string}
|
|
29
24
|
*/
|
|
30
|
-
|
|
25
|
+
const type = "weapon";
|
|
26
|
+
super(league, type);
|
|
27
|
+
this.#queryUrl = urlGenerator(league, type);
|
|
31
28
|
}
|
|
32
29
|
|
|
33
30
|
/**
|
|
34
|
-
*
|
|
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 Weapon 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 Weapon data.
|
|
51
|
-
*
|
|
52
|
-
* @throws {Error}
|
|
53
|
-
*/
|
|
54
|
-
throw new Error(`Error fetching Weapon data: ${error.message}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Asynchronously retrieves weapon data based on the specified category name.
|
|
59
|
-
*
|
|
31
|
+
* Retrieves category data for weapons.
|
|
60
32
|
* @async
|
|
61
33
|
* @param {string} categoryName - The name of the category to retrieve.
|
|
62
34
|
* * Possible values: "twohandswords", "fishingrods", "onehandswords", "twohandaxes", "staves", "warstaff", "daggers", "scepters".
|
|
63
|
-
* @returns {Promise<Array<Object>>} - A
|
|
64
|
-
* @throws {Error} - Throws
|
|
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 weapon 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 weapon data for the specified category.
|
|
78
|
-
*
|
|
79
|
-
* @throws {Error}
|
|
80
|
-
*/
|
|
81
|
-
throw new Error(`Error fetching data Weapon Category: ${error.message}`);
|
|
42
|
+
throw new Error(`Error fetching Weapon data: ${error.message}`);
|
|
82
43
|
}
|
|
83
44
|
}
|
|
84
45
|
}
|
|
85
46
|
|
|
86
|
-
// Export the WeaponModule class
|
|
87
47
|
module.exports = WeaponModule;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a URL based on league and type. poe.watch 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://api.poe.watch/get?category=${type}&league=${league}`;
|
|
9
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const axios = require("axios");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Fetches data from the provided URL using Axios.
|
|
5
|
+
* @param {string} url The URL to fetch data from.
|
|
6
|
+
* @returns {Promise<any>} A Promise that resolves with the fetched data.
|
|
7
|
+
* @throws {Error} If an error occurs during the fetch process.
|
|
8
|
+
*/
|
|
9
|
+
async function fetchData(url) {
|
|
10
|
+
try {
|
|
11
|
+
const response = await axios.get(url);
|
|
12
|
+
if (response.data) {
|
|
13
|
+
return response.data;
|
|
14
|
+
} else {
|
|
15
|
+
throw new Error("Invalid response fetched");
|
|
16
|
+
}
|
|
17
|
+
} catch (error) {
|
|
18
|
+
throw new Error(`Error fetching data: ${error.message}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = fetchData;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const fetchData = require("./functions/fetch/fetch");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Fetches league names from the provided URL.
|
|
5
|
+
*
|
|
6
|
+
* This function fetches data from the specified URL which contains information about
|
|
7
|
+
* Path of Exile leagues. It then extracts the names of the leagues from the fetched data
|
|
8
|
+
* and returns them as an array.
|
|
9
|
+
*
|
|
10
|
+
* @returns {Promise<string[]>} A Promise that resolves with an array of league names.
|
|
11
|
+
* @throws {Error} If an error occurs during the fetch process or if the response data is empty.
|
|
12
|
+
*/
|
|
13
|
+
async function getLeagues() {
|
|
14
|
+
const url = "https://api.poe.watch/leagues";
|
|
15
|
+
try {
|
|
16
|
+
const fetchedData = await fetchData(url);
|
|
17
|
+
const names = fetchedData.map((item) => item.name);
|
|
18
|
+
return names;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
throw new Error(`Error fetching League Names: ${error.message}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = getLeagues;
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|