poe-api-manager 0.2.2 → 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.
Files changed (69) hide show
  1. package/Changelog.md +17 -14
  2. package/README.md +31 -18
  3. package/lib/NinjaAPI.js +26 -4
  4. package/lib/WatchAPI.js +45 -1
  5. package/lib/config/poeNinja/url.js +9 -0
  6. package/lib/config/poeWatch/url.js +9 -0
  7. package/lib/modules/mainfunctions/filter/propertyFilter.js +18 -0
  8. package/lib/modules/poe.ninja/currency/CurrencyWievModule.js +39 -2
  9. package/lib/modules/poe.ninja/currency/currencyFetch/fetchCurrency.js +11 -3
  10. package/lib/modules/poe.ninja/currency/currencyFetch/merge/mergeData.js +7 -0
  11. package/lib/modules/poe.ninja/currency/currencySubmodules/functions/getData.js +23 -0
  12. package/lib/modules/poe.ninja/currency/currencySubmodules/subModules/CurrencyModule.js +45 -2
  13. package/lib/modules/poe.ninja/currency/currencySubmodules/subModules/FragmentModule.js +45 -2
  14. package/lib/modules/poe.ninja/item/ItemWievModule.js +135 -2
  15. package/lib/modules/poe.ninja/item/itemFetch/fetchItem.js +23 -2
  16. package/lib/modules/poe.ninja/item/itemSubmodules/functions/getData.js +19 -0
  17. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BaseTypeModule.js +41 -2
  18. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BeastModule.js +41 -2
  19. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BlightRavagedMapModule.js +46 -2
  20. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/BlightedMapModule.js +43 -2
  21. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ClusterJewelModule.js +46 -2
  22. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/DeliriumOrbsModule.js +46 -2
  23. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/DivinationCardModule.js +46 -2
  24. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/EssenceModule.js +46 -2
  25. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/FossilModule.js +46 -2
  26. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/HelmetEnchantModule.js +46 -2
  27. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/IncubatorModule.js +46 -2
  28. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/InvitationModule.js +46 -2
  29. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/MapModule.js +46 -2
  30. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/MemoryModule.js +46 -2
  31. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/OilModule.js +46 -2
  32. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/OmenModule.js +46 -2
  33. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ResonatorModule.js +46 -2
  34. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/ScarabModule.js +46 -2
  35. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/SkillGemModule.js +46 -2
  36. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueAccessoryModule.js +46 -2
  37. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueArmourModule.js +46 -2
  38. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueFlaskModule.js +46 -2
  39. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueJewelModule.js +46 -2
  40. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueMapModule.js +46 -2
  41. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueRelicModule.js +46 -2
  42. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/UniqueWeaponModule.js +46 -2
  43. package/lib/modules/poe.ninja/item/itemSubmodules/subModules/VialsModule.js +46 -2
  44. package/lib/modules/poe.watch/WatchWievModule.js +106 -4
  45. package/lib/modules/poe.watch/allModules/fetch/fetch.js +11 -2
  46. package/lib/modules/poe.watch/allModules/functions/getCategory.js +55 -0
  47. package/lib/modules/poe.watch/allModules/functions/getData.js +20 -1
  48. package/lib/modules/poe.watch/allModules/submodules/AccessoryModule.js +77 -1
  49. package/lib/modules/poe.watch/allModules/submodules/ArmourModule.js +75 -1
  50. package/lib/modules/poe.watch/allModules/submodules/BaseModule.js +75 -1
  51. package/lib/modules/poe.watch/allModules/submodules/BeastModule.js +47 -1
  52. package/lib/modules/poe.watch/allModules/submodules/CurrencyModule.js +49 -2
  53. package/lib/modules/poe.watch/allModules/submodules/DeliriumOrbModule.js +47 -1
  54. package/lib/modules/poe.watch/allModules/submodules/DivsModule.js +47 -1
  55. package/lib/modules/poe.watch/allModules/submodules/EssenceModule.js +47 -1
  56. package/lib/modules/poe.watch/allModules/submodules/FlaskModule.js +47 -1
  57. package/lib/modules/poe.watch/allModules/submodules/FossilModule.js +47 -1
  58. package/lib/modules/poe.watch/allModules/submodules/FragmentModule.js +47 -1
  59. package/lib/modules/poe.watch/allModules/submodules/GemModule.js +76 -1
  60. package/lib/modules/poe.watch/allModules/submodules/InscribedModule.js +49 -1
  61. package/lib/modules/poe.watch/allModules/submodules/InvitationModule.js +47 -1
  62. package/lib/modules/poe.watch/allModules/submodules/JewelModule.js +47 -1
  63. package/lib/modules/poe.watch/allModules/submodules/MapModule.js +47 -1
  64. package/lib/modules/poe.watch/allModules/submodules/OilModule.js +47 -1
  65. package/lib/modules/poe.watch/allModules/submodules/ScarabModule.js +47 -1
  66. package/lib/modules/poe.watch/allModules/submodules/SextantModule.js +47 -1
  67. package/lib/modules/poe.watch/allModules/submodules/UniqueMapsModule.js +47 -1
  68. package/lib/modules/poe.watch/allModules/submodules/WeaponModule.js +75 -1
  69. package/package.json +1 -1
package/Changelog.md CHANGED
@@ -1,19 +1,22 @@
1
1
  # Changelog
2
- ## 0.2.2
3
- poe.watch API add
4
-
5
- use getData() function
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.
6
+ ## 0.2.6
7
+ - 🎨[Added] JSDocs for easy understanding.
6
8
 
9
+ ## 0.2.2
10
+ - 🚀[Added] poe.watch API with `getData()` function.
7
11
 
8
- ## 0.1.0
9
- poe.ninja API new
10
-
11
- - Omens
12
- - Unique Relics
13
- - Cluster Jewels
14
- - Blighted Maps
15
- - Blight Ravaged Maps
16
- - Invitations
17
- - 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
18
21
 
19
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/NinjaAPI.js CHANGED
@@ -1,11 +1,33 @@
1
- const ItemWievModule = require("./modules/poe.ninja/item/ItemWievModule");
2
- const CurrencyWievModule = require("./modules/poe.ninja/currency/CurrencyWievModule");
1
+ const ItemViewModule = require("./modules/poe.ninja/item/ItemWievModule");
2
+ const CurrencyViewModule = require("./modules/poe.ninja/currency/CurrencyWievModule");
3
3
 
4
+ /**
5
+ * Represents an API for interacting with the poe.ninja API.
6
+ *
7
+ * @class
8
+ */
4
9
  class NinjaAPI {
10
+ /**
11
+ * Creates an instance of NinjaAPI.
12
+ *
13
+ * @param {string} league - The PoE league for which data is requested.
14
+ */
5
15
  constructor(league) {
6
- this.currencyWiev = new CurrencyWievModule(league);
7
- this.itemWiev = new ItemWievModule(league);
16
+ /**
17
+ * The CurrencyViewModule instance for fetching currency-related data.
18
+ *
19
+ * @type {CurrencyViewModule}
20
+ */
21
+ this.currencyView = new CurrencyViewModule(league);
22
+
23
+ /**
24
+ * The ItemViewModule instance for fetching item-related data.
25
+ *
26
+ * @type {ItemViewModule}
27
+ */
28
+ this.itemView = new ItemViewModule(league);
8
29
  }
9
30
  }
31
+
10
32
  // Export the NinjaAPI class
11
33
  module.exports = NinjaAPI;
package/lib/WatchAPI.js CHANGED
@@ -1,12 +1,56 @@
1
1
  const WatchWievModule = require("./modules/poe.watch/WatchWievModule");
2
2
 
3
+ /**
4
+ * Represents an API for interacting with a poe.watch service.
5
+ *
6
+ * @class
7
+ */
3
8
  class WatchAPI {
9
+ /**
10
+ * The league for which the API is initialized.
11
+ *
12
+ * @private
13
+ * @type {string}
14
+ */
4
15
  #league;
16
+
17
+ /**
18
+ * The URL parameter for the league in the Path of Exile.
19
+ *
20
+ * @private
21
+ * @type {string}
22
+ */
5
23
  #leagueUrl;
24
+
25
+ /**
26
+ * Creates an instance of WatchAPI.
27
+ *
28
+ * @param {string} league - The league for which the API should be initialized.
29
+ */
6
30
  constructor(league) {
31
+ /**
32
+ * The league for which the API is initialized.
33
+ *
34
+ * @private
35
+ * @type {string}
36
+ */
7
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
+ */
8
45
  this.#leagueUrl = `&league=${this.#league}`;
9
- this.wiev = new WatchWievModule(this.#leagueUrl);
46
+
47
+ /**
48
+ * The WatchWievModule instance associated with this API.
49
+ *
50
+ * @type {WatchWievModule}
51
+ */
52
+ this.view = new WatchWievModule(this.#leagueUrl);
10
53
  }
11
54
  }
55
+
12
56
  module.exports = WatchAPI;
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Configuration module for poe.ninja API URL.
3
+ * @module config/poeNinja/url
4
+ */
5
+
6
+ /**
7
+ * Base URL for the poe.ninja API.
8
+ * @type {string}
9
+ */
1
10
  module.exports = {
2
11
  baseurl: "https://poe.ninja/api/data/",
3
12
  };
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Configuration module for poe.watch API URL.
3
+ * @module config/poeWatch/url
4
+ */
5
+
6
+ /**
7
+ * Base URL for the poe.watch API.
8
+ * @type {string}
9
+ */
1
10
  module.exports = {
2
11
  baseurl: "https://api.poe.watch/get?category=",
3
12
  };
@@ -1,12 +1,30 @@
1
+ /**
2
+ * Filters properties of objects in an array based on the specified properties.
3
+ *
4
+ * @param {Array<Object>} data - The array of objects to filter.
5
+ * @param {Array<string>} requestedProperties - The array of property names to include in the result.
6
+ * @returns {Array<Object>} - An array of objects with only the specified properties.
7
+ */
1
8
  module.exports = function filterProperties(data, requestedProperties) {
9
+ /**
10
+ * @type {Array<Object>} result - The filtered array of objects.
11
+ */
2
12
  const result = [];
3
13
 
4
14
  data.forEach((item) => {
15
+ /**
16
+ * @type {Object} itemResult - The filtered object with requested properties.
17
+ */
5
18
  const itemResult = {};
19
+
6
20
  requestedProperties.forEach((prop) => {
7
21
  if (item.hasOwnProperty(prop)) {
8
22
  itemResult[prop] = item[prop];
9
23
  } else {
24
+ /**
25
+ * Warn if the requested property is not found in the object.
26
+ * @type {string}
27
+ */
10
28
  console.warn(`Property not found: ${prop}`);
11
29
  }
12
30
  });
@@ -1,19 +1,56 @@
1
1
  const currencySubmodules = require("./currencySubmodules/CurrencySubModules");
2
2
  const baseurl = require("../../../config/poeNinja/url");
3
3
 
4
- //currencywiev module
4
+ /**
5
+ * Represents a module for fetching currency overview data.
6
+ *
7
+ * @class
8
+ */
5
9
  class CurrencyWievModule {
6
10
  #league;
7
11
  #baseurl;
12
+ /**
13
+ * Creates a new CurrencyWievModule instance.
14
+ *
15
+ * @constructor
16
+ * @param {string} league - The name of the Path of Exile league.
17
+ */
8
18
  constructor(league) {
19
+ /**
20
+ * The league for which the currency overview data is fetched.
21
+ *
22
+ * @private
23
+ * @type {string}
24
+ */
9
25
  this.#league = league;
26
+
27
+ /**
28
+ * The base URL for fetching currency overview data.
29
+ *
30
+ * @private
31
+ * @type {string}
32
+ */
10
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
+ */
11
41
  const url = `${this.#baseurl}currencyoverview?league=${this.#league}&type=`;
12
42
 
43
+ /**
44
+ * Represents a module for fetching currency data.
45
+ */
13
46
  this.currency = new currencySubmodules.CurrencyModule(url);
47
+
48
+ /**
49
+ * Represents a module for fetching fragment data.
50
+ */
14
51
  this.fragment = new currencySubmodules.FragmentModule(url);
15
52
  }
16
53
  }
17
54
 
18
- //export CurrencyWievModule;
55
+ // Export the CurrencyWievModule class
19
56
  module.exports = CurrencyWievModule;
@@ -1,7 +1,14 @@
1
1
  const axios = require("axios");
2
2
  const mergeData = require("./merge/mergeData");
3
3
 
4
- // items for a specific fetch function
4
+ /**
5
+ * Fetches data from a specified API endpoint, merges relevant data, and returns the result.
6
+ *
7
+ * @param {string} baseurl - The base URL of the API.
8
+ * @param {string} type - The type of data to fetch. (e.g. "Currency", "Fragment")
9
+ * @returns {Promise<Array<Object>>} - A promise that resolves to an array of merged objects containing both line and currency details.
10
+ * @throws {Error} - Throws an error if there's an issue with the API response or data fetching process.
11
+ */
5
12
  async function fetchData(baseurl, type) {
6
13
  try {
7
14
  const url = `${baseurl}${type}`;
@@ -10,11 +17,13 @@ async function fetchData(baseurl, type) {
10
17
  if (response.data && response.data.lines && response.data.currencyDetails) {
11
18
  const lines = response.data.lines;
12
19
  const currencyDetails = response.data.currencyDetails;
20
+
21
+ // Merge data using the mergeData function
13
22
  const mergedData = mergeData(lines, currencyDetails);
14
23
  return mergedData;
15
24
  } else {
16
25
  throw new Error(
17
- "Invalid response format from POE Ninja API Currencywiev"
26
+ "Invalid response format from POE Ninja API Currencyview"
18
27
  );
19
28
  }
20
29
  } catch (error) {
@@ -22,5 +31,4 @@ async function fetchData(baseurl, type) {
22
31
  }
23
32
  }
24
33
 
25
- // export fetchData;
26
34
  module.exports = fetchData;
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Merges the provided lines with the corresponding currency details.
3
+ *
4
+ * @param {Array} lines - The lines to be merged.
5
+ * @param {Array} currencyDetails - The currency details to be merged with the lines.
6
+ * @returns {Array} - The merged data.
7
+ */
1
8
  function mergeData(lines, currencyDetails) {
2
9
  const mergedData = [];
3
10
 
@@ -1,6 +1,19 @@
1
1
  const fetchData = require("../../currencyFetch/fetchCurrency");
2
2
  const filterProperties = require("../../../../mainfunctions/filter/propertyFilter");
3
3
 
4
+ /**
5
+ * Retrieves data from a specified API endpoint, optionally filters the data based on requested properties, and returns the result.
6
+ *
7
+ * @param {string} url - The URL of the API endpoint.
8
+ * @param {string} type - The type of data to fetch.
9
+ * @param {Array<string>} [requestedProperties] - An optional array of property names to filter the fetched data.
10
+ * @returns {Promise<Array<Object>>} - A promise that resolves to an array of objects containing the fetched and possibly filtered data.
11
+ * @throws {Error} - Throws an error if there's an issue with the data fetching process or filtering process.
12
+ *
13
+ * @async
14
+ * @function
15
+ *
16
+ */
4
17
  async function getData(url, type, requestedProperties) {
5
18
  try {
6
19
  // Fetch data using the fetchData function
@@ -8,6 +21,11 @@ async function getData(url, type, requestedProperties) {
8
21
 
9
22
  // If requestedProperties are specified, filter the data based on those properties
10
23
  if (requestedProperties) {
24
+ /**
25
+ * Filter the fetched data based on the specified properties.
26
+ *
27
+ * @type {Array<Object>}
28
+ */
11
29
  const result = filterProperties(fetchedData, requestedProperties);
12
30
  return result;
13
31
  } else {
@@ -15,6 +33,11 @@ async function getData(url, type, requestedProperties) {
15
33
  return fetchedData;
16
34
  }
17
35
  } catch (error) {
36
+ /**
37
+ * An error indicating an issue with the data fetching or filtering process.
38
+ *
39
+ * @throws {Error} - Throws an error with a descriptive message.
40
+ */
18
41
  throw new Error(`Error fetching data: ${error.message}`);
19
42
  }
20
43
  }
@@ -1,18 +1,61 @@
1
1
  const getData = require("../functions/getData");
2
2
 
3
+ /**
4
+ * Represents a module for fetching data related to Currency.
5
+ *
6
+ * @class
7
+ */
3
8
  class CurrencyModule {
9
+ /**
10
+ * The URL for fetching data.
11
+ *
12
+ * @private
13
+ * @type {string}
14
+ */
4
15
  #url;
16
+
17
+ /**
18
+ * The type of data (Currency in this case).
19
+ *
20
+ * @private
21
+ * @type {string}
22
+ */
5
23
  #type;
6
24
 
25
+ /**
26
+ * Creates an instance of CurrencyModule.
27
+ *
28
+ * @param {string} url - The URL to fetch data from.
29
+ */
7
30
  constructor(url) {
8
31
  this.#url = url;
9
32
  this.#type = "Currency";
10
33
  }
11
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
+ */
12
42
  async getData(requestedProperties) {
13
- return getData(this.#url, this.#type, requestedProperties);
43
+ try {
44
+ /**
45
+ * Calls the getData function to fetch Currency 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 Currency data.
53
+ *
54
+ * @throws {Error}
55
+ */
56
+ throw new Error(`Error fetching Currency data: ${error.message}`);
57
+ }
14
58
  }
15
59
  }
16
60
 
17
- //export CurrencyModule;
18
61
  module.exports = CurrencyModule;
@@ -1,18 +1,61 @@
1
1
  const getData = require("../functions/getData");
2
2
 
3
+ /**
4
+ * Represents a module for fetching data related to Fragments.
5
+ *
6
+ * @class
7
+ */
3
8
  class FragmentModule {
9
+ /**
10
+ * The URL for fetching data.
11
+ *
12
+ * @private
13
+ * @type {string}
14
+ */
4
15
  #url;
16
+
17
+ /**
18
+ * The type of data (Fragment in this case).
19
+ *
20
+ * @private
21
+ * @type {string}
22
+ */
5
23
  #type;
6
24
 
25
+ /**
26
+ * Creates an instance of FragmentModule.
27
+ *
28
+ * @param {string} url - The URL to fetch data from.
29
+ */
7
30
  constructor(url) {
8
31
  this.#url = url;
9
32
  this.#type = "Fragment";
10
33
  }
11
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
+ */
12
42
  async getData(requestedProperties) {
13
- return getData(this.#url, this.#type, 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
+ }
14
58
  }
15
59
  }
16
60
 
17
- //export FragmentModule;
18
61
  module.exports = FragmentModule;