poe-api-manager 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Changelog.md CHANGED
@@ -1,23 +1,22 @@
1
1
  # Changelog
2
+ ## 0.2.8
3
+ - 🚀[Added] poe.watch API with `getCategory()` function.
4
+ - 🛠️ [Fixed] WatchAPI sınıfında yazım hatası
5
+ - 📝 [Update] The documentation has been updated.
2
6
  ## 0.2.6
3
- JSDocs have been added for easy understanding.
4
-
7
+ - 🎨[Added] JSDocs for easy understanding.
5
8
 
6
9
  ## 0.2.2
7
- poe.watch API add
8
-
9
- use getData() function
10
-
11
-
12
- ## 0.1.0
13
- poe.ninja API new
10
+ - 🚀[Added] poe.watch API with `getData()` function.
14
11
 
15
- - Omens
16
- - Unique Relics
17
- - Cluster Jewels
18
- - Blighted Maps
19
- - Blight Ravaged Maps
20
- - Invitations
21
- - Memories
12
+ ## 0.1.0
13
+ - 🚀[Added] poe.ninja API with the following features:
14
+ - Omens
15
+ - Unique Relics
16
+ - Cluster Jewels
17
+ - Blighted Maps
18
+ - Blight Ravaged Maps
19
+ - Invitations
20
+ - Memories
22
21
 
23
22
  ## 0.0.1 Publish
package/README.md CHANGED
@@ -12,10 +12,10 @@
12
12
  - [Installation](#installation)
13
13
  - [Getting Started](#getting-started)
14
14
  - [poe.ninja](#ninjaapi)
15
- - [currencyWiev](#currencywiev)
16
- - [itemWiev](#itemwiev)
15
+ - [currencyView](#currencywiev)
16
+ - [itemView](#itemwiev)
17
17
  - [poe.watch](#watchapi)
18
- - [wiev](#wiev)
18
+ - [view](#view)
19
19
  - [Changelog](https://github.com/ayberkgezer/poe-api-manager/blob/main/Changelog.md)
20
20
  - [Examples](#examples)
21
21
 
@@ -47,7 +47,7 @@ const { NinjaAPI } = require("poe-api-manager");
47
47
  const ninjaAPI = new NinjaAPI("League-Name");
48
48
  ```
49
49
 
50
- #### currencyWiev
50
+ #### currencyView
51
51
  What we can get here is as follows.
52
52
  - Currency
53
53
  - Fragment
@@ -55,7 +55,7 @@ What we can get here is as follows.
55
55
  getData() => function returns data purely.
56
56
  ```javascript
57
57
  //Example Currency
58
- ninjaAPI.currencyWiev.currency.getData().then((data) => {
58
+ ninjaAPI.currencyView.currency.getData().then((data) => {
59
59
  console.log(data);
60
60
  });
61
61
  ```
@@ -63,11 +63,11 @@ getdata(requestedProperties) => The function filters the data as desired.
63
63
  >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
64
  ```javascript
65
65
  //Filtered data is returned
66
- ninjaAPI.currencyWiev.currency.getData(["id", "name", "icon"]).then((data) => {
66
+ ninjaAPI.currencyView.currency.getData(["id", "name", "icon"]).then((data) => {
67
67
  console.log(data);
68
68
  });
69
69
  ```
70
- #### itemWiev
70
+ #### itemView
71
71
  What we can get here is as follows.
72
72
  - BaseType
73
73
  - Beast
@@ -100,7 +100,7 @@ What we can get here is as follows.
100
100
  getData() => function returns data purely.
101
101
  ```javascript
102
102
  //Example BaseType
103
- ninjaAPI.itemWiev.baseType.getData().then((data) => {
103
+ ninjaAPI.itemView.baseType.getData().then((data) => {
104
104
  console.log(data);
105
105
  });
106
106
  ```
@@ -108,7 +108,7 @@ getdata(requestedProperties) => The function filters the data as desired.
108
108
  >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
109
  ```javascript
110
110
  //Filtered data is returned
111
- ninjaAPI.itemWiev.baseType.getData(["id", "name", "icon"]).then((data) => {
111
+ ninjaAPI.itemView.baseType.getData(["id", "name", "icon"]).then((data) => {
112
112
  console.log(data);
113
113
  });
114
114
  ```
@@ -118,7 +118,7 @@ const { WatchAPI } = require("poe-api-manager");
118
118
 
119
119
  const watchAPI = new WatchAPI("League-Name");
120
120
  ```
121
- #### wiev
121
+ #### view
122
122
  What we can get here is as follows.
123
123
  - Currency
124
124
  - Essences
@@ -138,16 +138,29 @@ What we can get here is as follows.
138
138
  - Base
139
139
  - Beast
140
140
 
141
+ getData() => function returns data purely.
141
142
  ```javascript
142
143
  //Example Currency
143
- watchAPI.wiev.baseType.getData().then((data) => {
144
+ watchAPI.view.baseType.getData().then((data) => {
144
145
  console.log(data);
145
146
  });
146
147
  ```
147
148
  > Enter [poe.watch Document](https://docs.poe.watch/#get-all-armours) to access the values for the filter.
149
+
150
+ getdata(requestedProperties) => The function filters the data as desired.
148
151
  ```javascript
149
152
  //Filtered data is returned
150
- watchAPI.wiev.currency.getData(["id", "name", "icon"]).then((data) => {
153
+ watchAPI.view.currency.getData(["id", "name", "icon"]).then((data) => {
154
+ console.log(data);
155
+ });
156
+ ```
157
+ getCategory("categoryName") => The function quickly filters through specific categories.
158
+
159
+ > Note: Used in accessory, armour, base, gem and weapon.
160
+
161
+ ```javascript
162
+ //Returns the chest category in Armor.
163
+ watchAPI.view.armour.getCategory("chest").then((data) => {
151
164
  console.log(data);
152
165
  });
153
166
  ```
@@ -165,17 +178,17 @@ const watchAPI = new WatchAPI("Affliction")
165
178
  const requestedProperties = ["id", "name", "icon"];
166
179
 
167
180
  //filtered BaseType data ninjaAPI
168
- ninjaAPI.itemwiev.baseType.getData(requestedProperties).then((data) => {
181
+ ninjaAPI.itemView.baseType.getData(requestedProperties).then((data) => {
169
182
  console.log(data);
170
183
  });
171
184
 
172
185
  //filtered Currency data ninjaAPI
173
- ninjaAPI.currencyWiev.currency.getData(requestedProperties).then((data) => {
186
+ ninjaAPI.currencyView.currency.getData(requestedProperties).then((data) => {
174
187
  console.log(data);
175
188
  });
176
189
 
177
190
  // filtered Scarab data watchAPI
178
- watchAPI.wiev.scarab.getData(requestedProperties).then((data) => {
191
+ watchAPI.view.scarab.getData(requestedProperties).then((data) => {
179
192
  console.log(data);
180
193
  });
181
194
  ```
@@ -194,18 +207,18 @@ const requestedProperties = ["id", "name", "icon"];
194
207
  const fetchData = async () => {
195
208
  try {
196
209
  //Oil Data poe.ninja
197
- const oilData = await ninjaAPI.item.oil.getData(requestedProperties);
210
+ const oilData = await ninjaAPI.itemView.oil.getData(requestedProperties);
198
211
 
199
212
 
200
213
  console.log("poe.ninja Oil Data:", oilData);
201
214
 
202
215
  //Currency Data poe.ninja
203
- const currencyData = await ninjaAPI.currencyWiev.currency.getData(requestedProperties);
216
+ const currencyData = await ninjaAPI.currencyView.currency.getData(requestedProperties);
204
217
 
205
218
  console.log("poe.ninja Currency Data:", currencyData);
206
219
 
207
220
  //Scarab Data poe.watch
208
- const scarabData = await watchAPI.wiev.scarab.getData(requestedProperties)
221
+ const scarabData = await watchAPI.view.scarab.getData(requestedProperties)
209
222
 
210
223
  console.log("poe.watch Scarab Data", scarabData);
211
224
  } catch (error) {
package/lib/WatchAPI.js CHANGED
@@ -49,7 +49,7 @@ class WatchAPI {
49
49
  *
50
50
  * @type {WatchWievModule}
51
51
  */
52
- this.wiev = new WatchWievModule(this.#leagueUrl);
52
+ this.view = new WatchWievModule(this.#leagueUrl);
53
53
  }
54
54
  }
55
55
 
@@ -0,0 +1,55 @@
1
+ const fetchData = require("../fetch/fetch");
2
+
3
+ /**
4
+ * Fetches data based on the provided query URL and filters it by category name.
5
+ *
6
+ * @async
7
+ * @function
8
+ * @param {string} queryUrl - The URL to fetch the data from.
9
+ * @param {string} categoryName - The name of the category to filter the data by.
10
+ * @returns {Promise<Array<Object>|Object>} - A promise that resolves to an array of filtered data items.
11
+ * @throws {Error} Throws an error if category name is not provided or if there is an issue fetching or filtering the data.
12
+ */
13
+ const getCategory = async (queryUrl, categoryName) => {
14
+ try {
15
+ /**
16
+ * @type {Array<Object>} fetchedData - The fetched data.
17
+ */
18
+ const fetchedData = await fetchData(queryUrl);
19
+
20
+ // Validate category name
21
+ if (!categoryName && categoryName !== 0) {
22
+ /**
23
+ * Throws an error if the category name is not provided.
24
+ * @throws {Error}
25
+ */
26
+ throw new Error("Category name is required.");
27
+ }
28
+
29
+ // Filter data by category name
30
+ const filteredData = fetchedData.filter(
31
+ (item) => item.group === categoryName
32
+ );
33
+
34
+ // Check if filtered data is empty
35
+ if (filteredData.length === 0) {
36
+ /**
37
+ * Throws an error if no data is found for the specified category.
38
+ * @throws {Error}
39
+ */
40
+ throw new Error(`No data found for category: ${categoryName}`);
41
+ }
42
+
43
+ return filteredData;
44
+ } catch (error) {
45
+ /**
46
+ * Throws an error if there's an issue fetching or filtering data for the category.
47
+ * @throws {Error}
48
+ */
49
+ throw new Error(
50
+ `Error fetching or filtering data for category: ${error.message}`
51
+ );
52
+ }
53
+ };
54
+
55
+ module.exports = getCategory;
@@ -1,4 +1,5 @@
1
1
  const getData = require("../functions/getData");
2
+ const getCategory = require("../functions/getCategory");
2
3
 
3
4
  /**
4
5
  * Represents a module for fetching data related to Accessories.
@@ -53,6 +54,35 @@ class AccessoryModule {
53
54
  throw new Error(`Error fetching accessory data: ${error.message}`);
54
55
  }
55
56
  }
57
+ /**
58
+ * Asynchronously retrieves accessory data based on the specified category name.
59
+ *
60
+ * @async
61
+ * @param {string} categoryName - The name of the category to retrieve.
62
+ * * Possible values: "amulets", "rings", "belts", "quivers".
63
+ * @returns {Promise<Array<Object>>} - A promise that resolves to the retrieved data.
64
+ * @throws {Error} - Throws an error if there is an issue fetching or processing the accessory data for the specified category.
65
+ *
66
+ */
67
+ async getCategory(categoryName) {
68
+ try {
69
+ /**
70
+ * Calls the getCategory function to fetch accessory data based on category name.
71
+ *
72
+ * @type {Promise<Array<Object>>}
73
+ */
74
+ return getCategory(this.#queryUrl, categoryName);
75
+ } catch (error) {
76
+ /**
77
+ * Throws an error if there's an issue fetching or processing the accessory data for the specified category.
78
+ *
79
+ * @throws {Error}
80
+ */
81
+ throw new Error(
82
+ `Error fetching data Accessory Category: ${error.message}`
83
+ );
84
+ }
85
+ }
56
86
  }
57
87
 
58
88
  // Export the AccessoryModule class
@@ -1,4 +1,5 @@
1
1
  const getData = require("../functions/getData");
2
+ const getCategory = require("../functions/getCategory");
2
3
 
3
4
  /**
4
5
  * Represents a module for fetching data related to Armour.
@@ -53,6 +54,33 @@ class ArmourModule {
53
54
  throw new Error(`Error fetching armour data: ${error.message}`);
54
55
  }
55
56
  }
57
+ /**
58
+ * Asynchronously retrieves armour data based on the specified category name.
59
+ *
60
+ * @async
61
+ * @param {string} categoryName - The name of the category to retrieve.
62
+ * * Possible values: "chest", "bodyarmours", "shield", "boots", "gloves", "shields", "helmets", "quiver".
63
+ * @returns {Promise<Array<Object>>} - A promise that resolves to the retrieved data.
64
+ * @throws {Error} - Throws an error if there is an issue fetching or processing the armour data for the specified category.
65
+ *
66
+ */
67
+ async getCategory(categoryName) {
68
+ try {
69
+ /**
70
+ * Calls the getCategory function to fetch armour data based on category name.
71
+ *
72
+ * @type {Promise<Array<Object>>}
73
+ */
74
+ return getCategory(this.#queryUrl, categoryName);
75
+ } catch (error) {
76
+ /**
77
+ * Throws an error if there's an issue fetching or processing the armour data for the specified category.
78
+ *
79
+ * @throws {Error}
80
+ */
81
+ throw new Error(`Error fetching data Armour Category: ${error.message}`);
82
+ }
83
+ }
56
84
  }
57
85
 
58
86
  // Export the ArmourModule class
@@ -1,4 +1,5 @@
1
1
  const getData = require("../functions/getData");
2
+ const getCategory = require("../functions/getCategory");
2
3
 
3
4
  /**
4
5
  * Represents a module for fetching data related to Bases.
@@ -53,6 +54,33 @@ class BaseModule {
53
54
  throw new Error(`Error fetching base data: ${error.message}`);
54
55
  }
55
56
  }
57
+ /**
58
+ * Asynchronously retrieves base data based on the specified category name.
59
+ *
60
+ * @async
61
+ * @param {string} categoryName - The name of the category to retrieve.
62
+ * * Possible values: "armour", "weapons", "accessories".
63
+ * @returns {Promise<Array<Object>>} - A promise that resolves to the retrieved data.
64
+ * @throws {Error} - Throws an error if there is an issue fetching or processing the base data for the specified category.
65
+ *
66
+ */
67
+ async getCategory(categoryName) {
68
+ try {
69
+ /**
70
+ * Calls the getCategory function to fetch base data based on category name.
71
+ *
72
+ * @type {Promise<Array<Object>>}
73
+ */
74
+ return getCategory(this.#queryUrl, categoryName);
75
+ } catch (error) {
76
+ /**
77
+ * Throws an error if there's an issue fetching or processing the base data for the specified category.
78
+ *
79
+ * @throws {Error}
80
+ */
81
+ throw new Error(`Error fetching data Base Category: ${error.message}`);
82
+ }
83
+ }
56
84
  }
57
85
 
58
86
  // Export the BaseModule class
@@ -53,6 +53,35 @@ class GemModule {
53
53
  throw new Error(`Error fetching Skill Gem data: ${error.message}`);
54
54
  }
55
55
  }
56
+ /**
57
+ * Asynchronously retrieves gems data based on the specified category name.
58
+ *
59
+ * @async
60
+ * @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
+ *
65
+ */
66
+ async getCategory(categoryName) {
67
+ 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);
74
+ } 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
+ );
83
+ }
84
+ }
56
85
  }
57
86
 
58
87
  // Export the GemModule class
@@ -1,4 +1,5 @@
1
1
  const getData = require("../functions/getData");
2
+ const getCategory = require("../functions/getCategory");
2
3
 
3
4
  /**
4
5
  * Represents a module for fetching data related to Weapons.
@@ -53,6 +54,33 @@ class WeaponModule {
53
54
  throw new Error(`Error fetching Weapon data: ${error.message}`);
54
55
  }
55
56
  }
57
+ /**
58
+ * Asynchronously retrieves weapon data based on the specified category name.
59
+ *
60
+ * @async
61
+ * @param {string} categoryName - The name of the category to retrieve.
62
+ * * Possible values: "twohandswords", "fishingrods", "onehandswords", "twohandaxes", "staves", "warstaff", "daggers", "scepters".
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 weapon data for the specified category.
65
+ *
66
+ */
67
+ async getCategory(categoryName) {
68
+ 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);
75
+ } 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}`);
82
+ }
83
+ }
56
84
  }
57
85
 
58
86
  // Export the WeaponModule class
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-api-manager",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "API management for poe.ninja and poe.watch",
5
5
  "main": "index.js",
6
6
  "scripts": {