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.
- package/.github/workflows/CI_CD.yml +53 -0
- package/Changelog.md +11 -0
- package/README.md +25 -12
- package/index.js +2 -0
- package/lib/Utils.js +15 -0
- package/lib/WatchAPI.js +1 -33
- package/lib/modules/poe.ninja/currency/CurrencyBaseClass.js +47 -0
- package/lib/modules/poe.ninja/currency/CurrencyWievModule.js +2 -27
- package/lib/modules/poe.ninja/currency/currencyFetch/fetchCurrency.js +5 -4
- package/lib/modules/poe.ninja/currency/currencySubmodules/subModules/CurrencyModule.js +33 -40
- package/lib/modules/poe.ninja/currency/currencySubmodules/subModules/FragmentModule.js +8 -52
- package/lib/modules/poe.ninja/currency/currencyUrlGenerator/CurrencyUrlGenerator.js +9 -0
- package/lib/modules/poe.ninja/currency/{currencySubmodules/functions → methods}/getData.js +4 -4
- package/lib/modules/poe.ninja/currency/methods/getQuickCurrency.js +28 -0
- package/lib/modules/poe.ninja/item/ItemBaseClass.js +40 -0
- package/lib/modules/poe.ninja/item/ItemWievModule.js +27 -52
- package/lib/modules/poe.ninja/item/itemFetch/fetchItem.js +5 -10
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BaseTypeModule.js +8 -48
- package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BeastModule.js +11 -46
- 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/itemUrlGenerator/ItemUrlGenerator.js +9 -0
- package/lib/modules/poe.ninja/item/{itemSubmodules/functions → methods}/getData.js +5 -11
- 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/package.json +4 -2
- 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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
npm-publish:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- name: 📚 Checkout repository
|
|
16
|
+
uses: actions/checkout@v2
|
|
17
|
+
|
|
18
|
+
- run: ls
|
|
19
|
+
|
|
20
|
+
- name: Node
|
|
21
|
+
uses: actions/setup-node@v2
|
|
22
|
+
with:
|
|
23
|
+
node-version: '20'
|
|
24
|
+
registry-url: https://registry.npmjs.org
|
|
25
|
+
|
|
26
|
+
- name: 🧪 NPM ci
|
|
27
|
+
run: npm ci
|
|
28
|
+
|
|
29
|
+
- name: 📦 Publish to NPM
|
|
30
|
+
run: npm publish
|
|
31
|
+
env:
|
|
32
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
33
|
+
|
|
34
|
+
- name: 🚀 Get version and release name from package.json
|
|
35
|
+
id: version
|
|
36
|
+
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"
|
|
37
|
+
|
|
38
|
+
- name: 🚀 Get release name
|
|
39
|
+
id: release_name
|
|
40
|
+
run: echo "::set-output name=release_name::$(node -e 'console.log(require("./package.json").name)')"
|
|
41
|
+
|
|
42
|
+
- name: 🚀 Generate Version
|
|
43
|
+
id: create-release
|
|
44
|
+
uses: actions/create-release@v1
|
|
45
|
+
env:
|
|
46
|
+
GITHUB_TOKEN: ${{ secrets.G_TOKEN }}
|
|
47
|
+
with:
|
|
48
|
+
tag_name: v${{ steps.version.outputs.version }}
|
|
49
|
+
release_name: ${{ steps.release_name.outputs.release_name }} v${{ steps.version.outputs.version }}
|
|
50
|
+
body: "[CHANGELOG](https://github.com/ayberkgezer/poe-api-manager/blob/main/CHANGELOG.md)"
|
|
51
|
+
draft: false
|
|
52
|
+
prerelease: false
|
|
53
|
+
|
package/Changelog.md
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## 1.2.2
|
|
3
|
+
- 🛠️ [Fixed] Control mechanisms in API calls have been improved for better error handling.
|
|
4
|
+
- 🔄 [Changed] Updated dependencies to their latest versions for improved security and performance.
|
|
5
|
+
- 🚀 [Added] `getQuickCurrency()` has been added to the Currency class.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## 1.2.1
|
|
9
|
+
- 🔄 [Update] Development was done with OOP. Classes have been changed.
|
|
10
|
+
>There was no change in the scripts.
|
|
11
|
+
- 🚀[Added] Added `filterProperties()` to utils class.
|
|
12
|
+
|
|
2
13
|
## 1.0.0
|
|
3
14
|
- 🚀[New] utils class
|
|
4
15
|
- 🚀[New] utils `getLeagues`function. Get league name.
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
- [Introduction](#introduction)
|
|
11
|
-
- [
|
|
11
|
+
- [Overview](#overview)
|
|
12
12
|
- [Installation](#installation)
|
|
13
13
|
- [Getting Started](#getting-started)
|
|
14
14
|
- [poe.ninja](#ninjaapi)
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
- [itemView](#itemwiev)
|
|
17
17
|
- [poe.watch](#watchapi)
|
|
18
18
|
- [view](#view)
|
|
19
|
+
- [utils](#utils)
|
|
19
20
|
- [Changelog](https://github.com/ayberkgezer/poe-api-manager/blob/main/Changelog.md)
|
|
20
21
|
- [Examples](#examples)
|
|
21
22
|
|
|
@@ -28,7 +29,7 @@ The purpose of this library is to make the economic data in the Path of Exile ga
|
|
|
28
29
|
|
|
29
30
|
> Note: This product is in no way affiliated with or endorsed by Grinding Gear Games, poe.ninja and poe.watch.
|
|
30
31
|
|
|
31
|
-
##
|
|
32
|
+
## Overview
|
|
32
33
|
|
|
33
34
|
Permission to access two different services. poe.ninja and poe.watch
|
|
34
35
|
|
|
@@ -52,14 +53,14 @@ What we can get here is as follows.
|
|
|
52
53
|
- Currency
|
|
53
54
|
- Fragment
|
|
54
55
|
|
|
55
|
-
getData() => function returns data purely.
|
|
56
|
+
- getData() => function returns data purely.
|
|
56
57
|
```javascript
|
|
57
58
|
//Example Currency
|
|
58
59
|
ninjaAPI.currencyView.currency.getData().then((data) => {
|
|
59
60
|
console.log(data);
|
|
60
61
|
});
|
|
61
62
|
```
|
|
62
|
-
|
|
63
|
+
- getData(requestedProperties) => The function filters the data as desired.
|
|
63
64
|
>Note: Enter [poe.ninja Document](https://github.com/ayberkgezer/poe.ninja-API-Document?tab=readme-ov-file#poeninja-api) to access the values for the filter.
|
|
64
65
|
```javascript
|
|
65
66
|
//Filtered data is returned
|
|
@@ -67,6 +68,13 @@ ninjaAPI.currencyView.currency.getData(["id", "name", "icon"]).then((data) => {
|
|
|
67
68
|
console.log(data);
|
|
68
69
|
});
|
|
69
70
|
```
|
|
71
|
+
- getQuickCurrency() => This function returns the chaos value from the currency name. It returns "Divine Orb" chaos as the default value. currencyTypeName default "Divine Orb"
|
|
72
|
+
```javascript
|
|
73
|
+
ninjaAPI.currencyView.currency.getQuickCurrency(currencyTypeName).then((data)=> {
|
|
74
|
+
console.log(data);
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
70
78
|
#### itemView
|
|
71
79
|
What we can get here is as follows.
|
|
72
80
|
- BaseType
|
|
@@ -97,14 +105,14 @@ What we can get here is as follows.
|
|
|
97
105
|
- Invitations
|
|
98
106
|
- Memories
|
|
99
107
|
|
|
100
|
-
getData() => function returns data purely.
|
|
108
|
+
- getData() => function returns data purely.
|
|
101
109
|
```javascript
|
|
102
110
|
//Example BaseType
|
|
103
111
|
ninjaAPI.itemView.baseType.getData().then((data) => {
|
|
104
112
|
console.log(data);
|
|
105
113
|
});
|
|
106
114
|
```
|
|
107
|
-
getdata(requestedProperties) => The function filters the data as desired.
|
|
115
|
+
- getdata(requestedProperties) => The function filters the data as desired.
|
|
108
116
|
>Note: Enter [poe.ninja Document](https://github.com/ayberkgezer/poe.ninja-API-Document?tab=readme-ov-file#poeninja-api) to access the values for the filter.
|
|
109
117
|
```javascript
|
|
110
118
|
//Filtered data is returned
|
|
@@ -138,7 +146,7 @@ What we can get here is as follows.
|
|
|
138
146
|
- Base
|
|
139
147
|
- Beast
|
|
140
148
|
|
|
141
|
-
getData() => function returns data purely.
|
|
149
|
+
- getData() => function returns data purely.
|
|
142
150
|
```javascript
|
|
143
151
|
//Example Currency
|
|
144
152
|
watchAPI.view.baseType.getData().then((data) => {
|
|
@@ -147,14 +155,14 @@ watchAPI.view.baseType.getData().then((data) => {
|
|
|
147
155
|
```
|
|
148
156
|
> Enter [poe.watch Document](https://docs.poe.watch/#get-all-armours) to access the values for the filter.
|
|
149
157
|
|
|
150
|
-
getdata(requestedProperties) => The function filters the data as desired.
|
|
158
|
+
- getdata(requestedProperties) => The function filters the data as desired.
|
|
151
159
|
```javascript
|
|
152
160
|
//Filtered data is returned
|
|
153
161
|
watchAPI.view.currency.getData(["id", "name", "icon"]).then((data) => {
|
|
154
162
|
console.log(data);
|
|
155
163
|
});
|
|
156
164
|
```
|
|
157
|
-
getCategory("categoryName") => The function quickly filters through specific categories.
|
|
165
|
+
- getCategory("categoryName") => The function quickly filters through specific categories.
|
|
158
166
|
|
|
159
167
|
> Note: Used in accessory, armour, base, gem and weapon.
|
|
160
168
|
|
|
@@ -170,16 +178,21 @@ Utils class is a class that contains some auxiliary tools.
|
|
|
170
178
|
const { Utils } = require("poe-api-manager");
|
|
171
179
|
const utils = new Utils();
|
|
172
180
|
```
|
|
173
|
-
getLeagues() => Returns available league names.
|
|
181
|
+
- getLeagues() => Returns available league names.
|
|
174
182
|
|
|
175
183
|
```javascript
|
|
176
|
-
const utils = new Utils();
|
|
177
|
-
|
|
178
184
|
utils.getLeagues().then((data) => {
|
|
179
185
|
console.log(data);
|
|
180
186
|
});
|
|
181
187
|
```
|
|
182
188
|
|
|
189
|
+
- filterProperties(data, properties) => It is used to filter data.
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
utils.filterProperties(data, ["currencyTypeName", "chaosEquivalent"])
|
|
193
|
+
.then((result) => console.log(result));
|
|
194
|
+
```
|
|
195
|
+
|
|
183
196
|
|
|
184
197
|
## Examples
|
|
185
198
|
```javascript
|
package/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const NinjaAPI = require("./lib/NinjaAPI");
|
|
2
2
|
const WatchAPI = require("./lib/WatchAPI");
|
|
3
3
|
const Utils = require("./lib/Utils");
|
|
4
|
+
const RedisManager = require("./lib/RedisManager");
|
|
4
5
|
|
|
5
6
|
module.exports = {
|
|
6
7
|
NinjaAPI: NinjaAPI,
|
|
7
8
|
WatchAPI: WatchAPI,
|
|
8
9
|
Utils: Utils,
|
|
10
|
+
//RedisManager: RedisManager,
|
|
9
11
|
};
|
package/lib/Utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const getLeagues = require("./modules/utils/getLeagues");
|
|
2
|
+
const filterProperties = require("./modules/mainfunctions/filter/propertyFilter");
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* A utility class.
|
|
@@ -21,6 +22,20 @@ class Utils {
|
|
|
21
22
|
throw new Error(`Error fetching data Leagues: ${error.message}`);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Filters properties of objects in an array based on the specified properties.
|
|
27
|
+
*
|
|
28
|
+
* @param {Array<Object>} data - The array of objects to filter.
|
|
29
|
+
* @param {Array<string>} properties - The array of property names to include in the result.
|
|
30
|
+
* @returns {Array<Object>} - An array of objects with only the specified properties.
|
|
31
|
+
*/
|
|
32
|
+
async filterProperties(data, properties) {
|
|
33
|
+
try {
|
|
34
|
+
return filterProperties(data, properties);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
throw new Error(`Error fetching data Leagues: ${error.message}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
24
39
|
}
|
|
25
40
|
|
|
26
41
|
module.exports = Utils;
|
package/lib/WatchAPI.js
CHANGED
|
@@ -6,50 +6,18 @@ const WatchWievModule = require("./modules/poe.watch/WatchWievModule");
|
|
|
6
6
|
* @class
|
|
7
7
|
*/
|
|
8
8
|
class WatchAPI {
|
|
9
|
-
/**
|
|
10
|
-
* The league for which the API is initialized.
|
|
11
|
-
*
|
|
12
|
-
* @private
|
|
13
|
-
* @type {string}
|
|
14
|
-
*/
|
|
15
|
-
#league;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The URL parameter for the league in the Path of Exile.
|
|
19
|
-
*
|
|
20
|
-
* @private
|
|
21
|
-
* @type {string}
|
|
22
|
-
*/
|
|
23
|
-
#leagueUrl;
|
|
24
|
-
|
|
25
9
|
/**
|
|
26
10
|
* Creates an instance of WatchAPI.
|
|
27
11
|
*
|
|
28
12
|
* @param {string} league - The league for which the API should be initialized.
|
|
29
13
|
*/
|
|
30
14
|
constructor(league) {
|
|
31
|
-
/**
|
|
32
|
-
* The league for which the API is initialized.
|
|
33
|
-
*
|
|
34
|
-
* @private
|
|
35
|
-
* @type {string}
|
|
36
|
-
*/
|
|
37
|
-
this.#league = league;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The URL parameter for the league in the Path of Exile watch service.
|
|
41
|
-
*
|
|
42
|
-
* @private
|
|
43
|
-
* @type {string}
|
|
44
|
-
*/
|
|
45
|
-
this.#leagueUrl = `&league=${this.#league}`;
|
|
46
|
-
|
|
47
15
|
/**
|
|
48
16
|
* The WatchWievModule instance associated with this API.
|
|
49
17
|
*
|
|
50
18
|
* @type {WatchWievModule}
|
|
51
19
|
*/
|
|
52
|
-
this.view = new WatchWievModule(
|
|
20
|
+
this.view = new WatchWievModule(league);
|
|
53
21
|
}
|
|
54
22
|
}
|
|
55
23
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const getData = require("./methods/getData");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a base class for interacting with data.
|
|
5
|
+
*/
|
|
6
|
+
class CurrencyBaseClass {
|
|
7
|
+
/**
|
|
8
|
+
* The league name for which data is requested.
|
|
9
|
+
* @type {string}
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
#league;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The type of data.
|
|
16
|
+
* @type {string}
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
#typeName;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a new CurrencyBaseClass instance.
|
|
23
|
+
* @param {string} league - The league name for which data is requested.
|
|
24
|
+
* @param {string} typeName - The type of data.
|
|
25
|
+
*/
|
|
26
|
+
constructor(league, typeName) {
|
|
27
|
+
this.#league = league;
|
|
28
|
+
this.#typeName = typeName;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves data based on the specified properties.
|
|
33
|
+
* @async
|
|
34
|
+
* @param {Array<string>} requestedProperties - The properties to include in the fetched data.
|
|
35
|
+
* @returns {Promise<Array<Object>>} The fetched data in JSON format.
|
|
36
|
+
* @throws {Error} If an error occurs during the data fetching process.
|
|
37
|
+
*/
|
|
38
|
+
async getData(requestedProperties) {
|
|
39
|
+
try {
|
|
40
|
+
return await getData(this.#league, this.#typeName, requestedProperties);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw new Error(`Error fetching CurrencyView data: ${error.message}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = CurrencyBaseClass;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const currencySubmodules = require("./currencySubmodules/CurrencySubModules");
|
|
2
|
-
const baseurl = require("../../../config/poeNinja/url");
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Represents a module for fetching currency overview data.
|
|
@@ -7,8 +6,6 @@ const baseurl = require("../../../config/poeNinja/url");
|
|
|
7
6
|
* @class
|
|
8
7
|
*/
|
|
9
8
|
class CurrencyWievModule {
|
|
10
|
-
#league;
|
|
11
|
-
#baseurl;
|
|
12
9
|
/**
|
|
13
10
|
* Creates a new CurrencyWievModule instance.
|
|
14
11
|
*
|
|
@@ -17,38 +14,16 @@ class CurrencyWievModule {
|
|
|
17
14
|
*/
|
|
18
15
|
constructor(league) {
|
|
19
16
|
/**
|
|
20
|
-
* The league for which the currency overview data is fetched.
|
|
21
|
-
*
|
|
22
|
-
* @private
|
|
23
|
-
* @type {string}
|
|
24
|
-
*/
|
|
25
|
-
this.#league = league;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The base URL for fetching currency overview data.
|
|
29
|
-
*
|
|
30
|
-
* @private
|
|
31
|
-
* @type {string}
|
|
32
|
-
*/
|
|
33
|
-
this.#baseurl = baseurl.baseurl;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The URL for currency overview data specific to the league.
|
|
37
|
-
*
|
|
38
|
-
* @private
|
|
39
|
-
* @type {string}
|
|
40
|
-
*/
|
|
41
|
-
const url = `${this.#baseurl}currencyoverview?league=${this.#league}&type=`;
|
|
42
17
|
|
|
43
18
|
/**
|
|
44
19
|
* Represents a module for fetching currency data.
|
|
45
20
|
*/
|
|
46
|
-
this.currency = new currencySubmodules.CurrencyModule(
|
|
21
|
+
this.currency = new currencySubmodules.CurrencyModule(league);
|
|
47
22
|
|
|
48
23
|
/**
|
|
49
24
|
* Represents a module for fetching fragment data.
|
|
50
25
|
*/
|
|
51
|
-
this.fragment = new currencySubmodules.FragmentModule(
|
|
26
|
+
this.fragment = new currencySubmodules.FragmentModule(league);
|
|
52
27
|
}
|
|
53
28
|
}
|
|
54
29
|
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
const axios = require("axios");
|
|
2
2
|
const mergeData = require("./merge/mergeData");
|
|
3
|
+
const currencyUrlGenerator = require("../currencyUrlGenerator/CurrencyUrlGenerator");
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Fetches data from a specified API endpoint, merges relevant data, and returns the result.
|
|
6
7
|
*
|
|
7
|
-
* @param {string}
|
|
8
|
+
* @param {string} league - The game league for which to fetch currency data.
|
|
8
9
|
* @param {string} type - The type of data to fetch. (e.g. "Currency", "Fragment")
|
|
9
10
|
* @returns {Promise<Array<Object>>} - A promise that resolves to an array of merged objects containing both line and currency details.
|
|
10
11
|
* @throws {Error} - Throws an error if there's an issue with the API response or data fetching process.
|
|
11
12
|
*/
|
|
12
|
-
async function fetchData(
|
|
13
|
+
async function fetchData(league, type) {
|
|
13
14
|
try {
|
|
14
|
-
const url =
|
|
15
|
+
const url = currencyUrlGenerator(league, type);
|
|
15
16
|
const response = await axios.get(url);
|
|
16
17
|
|
|
17
18
|
if (response.data && response.data.lines && response.data.currencyDetails) {
|
|
@@ -23,7 +24,7 @@ async function fetchData(baseurl, type) {
|
|
|
23
24
|
return mergedData;
|
|
24
25
|
} else {
|
|
25
26
|
throw new Error(
|
|
26
|
-
"Invalid response format from POE Ninja API
|
|
27
|
+
"Invalid response format from POE Ninja API CurrencyView"
|
|
27
28
|
);
|
|
28
29
|
}
|
|
29
30
|
} catch (error) {
|
|
@@ -1,59 +1,52 @@
|
|
|
1
|
-
const
|
|
1
|
+
const CurrencyBaseClass = require("../../CurrencyBaseClass");
|
|
2
|
+
const getQuickCurrency = require("../../methods/getQuickCurrency");
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
* Represents a module for
|
|
5
|
-
*
|
|
6
|
-
* @class
|
|
5
|
+
* Represents a module for interacting with currency data.
|
|
6
|
+
* @extends CurrencyBaseClass
|
|
7
7
|
*/
|
|
8
|
-
class CurrencyModule {
|
|
8
|
+
class CurrencyModule extends CurrencyBaseClass {
|
|
9
9
|
/**
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
12
|
-
* @private
|
|
10
|
+
* The league name for which currency data is requested.
|
|
13
11
|
* @type {string}
|
|
12
|
+
* @private
|
|
14
13
|
*/
|
|
15
|
-
#
|
|
16
|
-
|
|
14
|
+
#league;
|
|
17
15
|
/**
|
|
18
|
-
* The type
|
|
19
|
-
*
|
|
20
|
-
* @private
|
|
16
|
+
* The type name for which currency data is requested.
|
|
21
17
|
* @type {string}
|
|
18
|
+
* @private
|
|
22
19
|
*/
|
|
23
|
-
#
|
|
24
|
-
|
|
20
|
+
#typeName;
|
|
25
21
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @param {string} url - The URL to fetch data from.
|
|
22
|
+
* Constructs a new CurrencyModule instance.
|
|
23
|
+
* @param {string} league - The league name for which currency data is requested.
|
|
29
24
|
*/
|
|
30
|
-
constructor(
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
constructor(league) {
|
|
26
|
+
/**
|
|
27
|
+
* The type name for which currency data is requested.
|
|
28
|
+
* @type {string}
|
|
29
|
+
*/
|
|
30
|
+
const type = "Currency";
|
|
31
|
+
super(league, type);
|
|
32
|
+
this.#league = league;
|
|
33
|
+
this.#typeName = type;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @
|
|
39
|
-
* @
|
|
40
|
-
* @returns {Promise<Object>} A promise that resolves to the retrieved data.
|
|
36
|
+
* Fetches quick currency data for a given currency ID. Defaults to "Divine Orb" if no ID is provided.
|
|
37
|
+
* @param {string} currencyTypeName - The "currencyTypeName" of the currency to fetch data for. Defaults to "Divine Orb".
|
|
38
|
+
* @returns {Promise<{currencyTypeName: string, chaosEquivalent: number}>} A promise that resolves with the currency data, including the currency type name and its chaos equivalent.
|
|
39
|
+
* @throws {Error} Throws an error if fetching currency data fails.
|
|
41
40
|
*/
|
|
42
|
-
async
|
|
41
|
+
async getQuickCurrency(currencyTypeName = "Divine Orb") {
|
|
43
42
|
try {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return getData(this.#url, this.#type, requestedProperties);
|
|
43
|
+
return await getQuickCurrency(
|
|
44
|
+
this.#league,
|
|
45
|
+
this.#typeName,
|
|
46
|
+
currencyTypeName
|
|
47
|
+
);
|
|
50
48
|
} catch (error) {
|
|
51
|
-
|
|
52
|
-
* Throws an error if there's an issue fetching or processing the Currency data.
|
|
53
|
-
*
|
|
54
|
-
* @throws {Error}
|
|
55
|
-
*/
|
|
56
|
-
throw new Error(`Error fetching Currency data: ${error.message}`);
|
|
49
|
+
throw new Error(`Error fetching CurrencyData data: ${error.message}`);
|
|
57
50
|
}
|
|
58
51
|
}
|
|
59
52
|
}
|
|
@@ -1,60 +1,16 @@
|
|
|
1
|
-
const
|
|
1
|
+
const CurrencyBaseClass = require("../../CurrencyBaseClass");
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Represents a module for
|
|
5
|
-
*
|
|
6
|
-
* @class
|
|
4
|
+
* Represents a module for interacting with fragment currency data.
|
|
5
|
+
* @extends CurrencyBaseClass
|
|
7
6
|
*/
|
|
8
|
-
class FragmentModule {
|
|
7
|
+
class FragmentModule extends CurrencyBaseClass {
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @private
|
|
13
|
-
* @type {string}
|
|
9
|
+
* Constructs a new FragmentModule instance.
|
|
10
|
+
* @param {string} league - The league name for which fragment currency data is requested.
|
|
14
11
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The type of data (Fragment in this case).
|
|
19
|
-
*
|
|
20
|
-
* @private
|
|
21
|
-
* @type {string}
|
|
22
|
-
*/
|
|
23
|
-
#type;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Creates an instance of FragmentModule.
|
|
27
|
-
*
|
|
28
|
-
* @param {string} url - The URL to fetch data from.
|
|
29
|
-
*/
|
|
30
|
-
constructor(url) {
|
|
31
|
-
this.#url = url;
|
|
32
|
-
this.#type = "Fragment";
|
|
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.
|
|
41
|
-
*/
|
|
42
|
-
async getData(requestedProperties) {
|
|
43
|
-
try {
|
|
44
|
-
/**
|
|
45
|
-
* Calls the getData function to fetch Fragment 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 Fragment data.
|
|
53
|
-
*
|
|
54
|
-
* @throws {Error}
|
|
55
|
-
*/
|
|
56
|
-
throw new Error(`Error fetching Fragment data: ${error.message}`);
|
|
57
|
-
}
|
|
12
|
+
constructor(league) {
|
|
13
|
+
super(league, "Fragment");
|
|
58
14
|
}
|
|
59
15
|
}
|
|
60
16
|
|
|
@@ -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/currencyoverview?league=${league}&type=${type}`;
|
|
9
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const fetchData = require("
|
|
2
|
-
const filterProperties = require("
|
|
1
|
+
const fetchData = require("../currencyFetch/fetchCurrency");
|
|
2
|
+
const filterProperties = require("../../../mainfunctions/filter/propertyFilter");
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Retrieves data from a specified API endpoint, optionally filters the data based on requested properties, and returns the result.
|
|
@@ -14,10 +14,10 @@ const filterProperties = require("../../../../mainfunctions/filter/propertyFilte
|
|
|
14
14
|
* @function
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
|
-
async function getData(
|
|
17
|
+
async function getData(league, type, requestedProperties) {
|
|
18
18
|
try {
|
|
19
19
|
// Fetch data using the fetchData function
|
|
20
|
-
const fetchedData = await fetchData(
|
|
20
|
+
const fetchedData = await fetchData(league, type);
|
|
21
21
|
|
|
22
22
|
// If requestedProperties are specified, filter the data based on those properties
|
|
23
23
|
if (requestedProperties) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const fetchCurrency = require("../currencyFetch/fetchCurrency");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves quick currency data for a specific currency in a given league and type.
|
|
5
|
+
* @param {string} league - The league for which to fetch currency data.
|
|
6
|
+
* @param {string} type - The type of currency data to fetch.
|
|
7
|
+
* @param {string} currencyTypeName - The currencyTypeName of the currency to fetch data for.
|
|
8
|
+
* @returns {Promise<{currencyTypeName: string, chaosEquivalent: number}>} An object containing the currency type name and its chaos equivalent.
|
|
9
|
+
* @throws {Error} Throws an error if the currency data cannot be fetched or if the currency is not found.
|
|
10
|
+
*/
|
|
11
|
+
async function getQuickCurrency(league, type, currencyTypeName) {
|
|
12
|
+
try {
|
|
13
|
+
const fetchedData = await fetchCurrency(league, type);
|
|
14
|
+
for (const data of fetchedData) {
|
|
15
|
+
if (data.currencyTypeName === currencyTypeName) {
|
|
16
|
+
return {
|
|
17
|
+
currencyTypeName: data.currencyTypeName,
|
|
18
|
+
chaosEquivalent: data.chaosEquivalent,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
throw new Error("Currency not found");
|
|
23
|
+
} catch (error) {
|
|
24
|
+
throw new Error(`Error fetching currency data: ${error.message}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = getQuickCurrency;
|