poe-api-manager 1.2.12 → 1.2.14
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 +6 -0
- package/README.md +1 -0
- package/dist/lib/modules/poe.ninja/itemView/ItemViewModule.d.ts +1 -1
- package/dist/lib/modules/poe.ninja/itemView/ItemViewModule.js +1 -1
- package/jsr.json +5 -0
- package/package.json +2 -2
- package/src/index.ts +0 -9
- package/src/lib/NinjaAPI.ts +0 -27
- package/src/lib/Utils.ts +0 -39
- package/src/lib/WatchAPI.ts +0 -19
- package/src/lib/modules/AbstractClass/PoeNinja.ts +0 -37
- package/src/lib/modules/AbstractClass/PoeWatch.ts +0 -26
- package/src/lib/modules/Interfaces/IPoeNinja.ts +0 -13
- package/src/lib/modules/Interfaces/IPoeWatch.ts +0 -13
- package/src/lib/modules/mainfunctions/propertyFilter.ts +0 -25
- package/src/lib/modules/poe.ninja/currencyView/CurrencyViewModule.ts +0 -26
- package/src/lib/modules/poe.ninja/currencyView/currencySubModules/CurrencySubModules.ts +0 -7
- package/src/lib/modules/poe.ninja/currencyView/currencySubModules/submodules/CurrencyModule.ts +0 -33
- package/src/lib/modules/poe.ninja/currencyView/currencySubModules/submodules/FragmentModule.ts +0 -18
- package/src/lib/modules/poe.ninja/fetch/fetchData.ts +0 -51
- package/src/lib/modules/poe.ninja/fetch/merge/mergeData.ts +0 -35
- package/src/lib/modules/poe.ninja/func/getData.ts +0 -30
- package/src/lib/modules/poe.ninja/func/getQuickCurrency.ts +0 -30
- package/src/lib/modules/poe.ninja/func/urlGenerator.ts +0 -10
- package/src/lib/modules/poe.ninja/itemView/ItemViewModule.ts +0 -188
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/itemSubModules.ts +0 -61
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/AllflameEmberModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/BaseTypeModule.ts +0 -19
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/BeastModule.ts +0 -20
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/BlightRavagedMapModule.ts +0 -19
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/BlightedMapModule.ts +0 -19
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/ClusterJewelModule.ts +0 -19
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/CoffinModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/DeliriumOrbsModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/DivinationCardModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/EssenceModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/FossilModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/HelmetEnchantModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/IncubatorModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/InvitationModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/MapModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/MemoryModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/OilModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/OmenModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/ResonatorModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/ScarabModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/SkillGemModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/UniqueAccessoryModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/UniqueArmourModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/UniqueFlaskModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/UniqueJewelModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/UniqueMapModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/UniqueRelicModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/UniqueWeaponModule.ts +0 -18
- package/src/lib/modules/poe.ninja/itemView/itemSubmodules/subModules/VialsModule.ts +0 -18
- package/src/lib/modules/poe.watch/WatchViewModule.ts +0 -141
- package/src/lib/modules/poe.watch/allModules/Modules.ts +0 -46
- package/src/lib/modules/poe.watch/allModules/fetch/watchFetch.ts +0 -30
- package/src/lib/modules/poe.watch/allModules/func/WatchUrlGenerator.ts +0 -10
- package/src/lib/modules/poe.watch/allModules/func/getCategory.ts +0 -34
- package/src/lib/modules/poe.watch/allModules/func/getData.ts +0 -30
- package/src/lib/modules/poe.watch/allModules/subModules/AccessoryModule.ts +0 -34
- package/src/lib/modules/poe.watch/allModules/subModules/ArmourModule.ts +0 -34
- package/src/lib/modules/poe.watch/allModules/subModules/BaseModule.ts +0 -34
- package/src/lib/modules/poe.watch/allModules/subModules/BeastModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/CurrencyModule.ts +0 -18
- package/src/lib/modules/poe.watch/allModules/subModules/DeliriumOrbModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/DivsModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/EssenceModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/FlaskModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/FossilModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/FragmentModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/GemModule.ts +0 -34
- package/src/lib/modules/poe.watch/allModules/subModules/InscribedModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/InvitationModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/JewelModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/MapModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/OilModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/ScarabModule.ts +0 -18
- package/src/lib/modules/poe.watch/allModules/subModules/SextantModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/UniqueMapsModule.ts +0 -17
- package/src/lib/modules/poe.watch/allModules/subModules/WeaponModule.ts +0 -35
- package/src/lib/modules/utils/fetchData/fetchData.ts +0 -22
- package/src/lib/modules/utils/getLeagues.ts +0 -26
package/Changelog.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.14
|
|
4
|
+
- 🚀[New] Publish jsr.
|
|
5
|
+
|
|
6
|
+
## 1.2.13
|
|
7
|
+
- 🛠️[Fix] Quick Fix.
|
|
8
|
+
|
|
3
9
|
## 1.2.12
|
|
4
10
|
- 🚀[New] I decided to develop the main project with Typescript language. From now on, development will only continue from here.
|
|
5
11
|
- 🛠️[Fix] Typescript uses.
|
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|

|
|
6
6
|
[](https://github.com/ayberkgezer/poe-api-manager/issues)
|
|
7
7
|

|
|
8
|
+

|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
- [Introduction](#introduction)
|
|
@@ -120,7 +120,7 @@ export declare class ItemViewModule {
|
|
|
120
120
|
*/
|
|
121
121
|
allflameEmber: AllflameEmberModule;
|
|
122
122
|
/**
|
|
123
|
-
* Creates a new instance of
|
|
123
|
+
* Creates a new instance of ItemViewModule.
|
|
124
124
|
* @param league - The Path of Exile league for which the item information is retrieved.
|
|
125
125
|
* @param typeName - The type of item information to retrieve.
|
|
126
126
|
*/
|
|
@@ -123,7 +123,7 @@ class ItemViewModule {
|
|
|
123
123
|
*/
|
|
124
124
|
allflameEmber;
|
|
125
125
|
/**
|
|
126
|
-
* Creates a new instance of
|
|
126
|
+
* Creates a new instance of ItemViewModule.
|
|
127
127
|
* @param league - The Path of Exile league for which the item information is retrieved.
|
|
128
128
|
* @param typeName - The type of item information to retrieve.
|
|
129
129
|
*/
|
package/jsr.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poe-api-manager",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.14",
|
|
4
4
|
"description": "poe.ninja and poe.watch API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/ayberkgezer/poe-api-manager
|
|
15
|
+
"url": "https://github.com/ayberkgezer/poe-api-manager.git"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"poe",
|
package/src/index.ts
DELETED
package/src/lib/NinjaAPI.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CurrencyViewModule } from "./modules/poe.ninja/currencyView/CurrencyViewModule";
|
|
2
|
-
import { ItemViewModule } from "./modules/poe.ninja/itemView/ItemViewModule";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Represents an API for interacting with the poe.ninja API.
|
|
6
|
-
*/
|
|
7
|
-
export class NinjaAPI {
|
|
8
|
-
/**
|
|
9
|
-
* The CurrencyViewModule instance for fetching currency-related data.
|
|
10
|
-
*/
|
|
11
|
-
public currencyView: CurrencyViewModule;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The ItemViewModule instance for fetching item-related data.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
public itemView: ItemViewModule;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Creates an instance of NinjaAPI.
|
|
21
|
-
* @param league The PoE league for which data is requested.
|
|
22
|
-
*/
|
|
23
|
-
constructor(league: string) {
|
|
24
|
-
this.currencyView = new CurrencyViewModule(league, "currencyoverview");
|
|
25
|
-
this.itemView = new ItemViewModule(league, "itemoverview");
|
|
26
|
-
}
|
|
27
|
-
}
|
package/src/lib/Utils.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import getLeagues from "./modules/utils/getLeagues";
|
|
2
|
-
import filterProperties from "./modules/mainfunctions/propertyFilter";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A utility class.
|
|
6
|
-
*/
|
|
7
|
-
class Utils {
|
|
8
|
-
constructor() {}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Fetches the list of leagues for the game.
|
|
12
|
-
* @returns The array of league names.
|
|
13
|
-
* @throws If there's an error fetching the leagues.
|
|
14
|
-
*/
|
|
15
|
-
async getLeagues(): Promise<string[]> {
|
|
16
|
-
try {
|
|
17
|
-
return await getLeagues();
|
|
18
|
-
} catch (error) {
|
|
19
|
-
throw new Error(`Error fetching data Leagues: ${(error as Error).message}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Filters properties of objects in an array based on the specified properties.
|
|
25
|
-
*
|
|
26
|
-
* @param data - The array of objects to filter.
|
|
27
|
-
* @param properties - The array of property names to include in the result.
|
|
28
|
-
* @returns - An array of objects with only the specified properties.
|
|
29
|
-
*/
|
|
30
|
-
async filterProperties(data: object[], properties: string[]): Promise<object[]> {
|
|
31
|
-
try {
|
|
32
|
-
return filterProperties(data, properties);
|
|
33
|
-
} catch (error) {
|
|
34
|
-
throw new Error(`Error fetching data Leagues: ${(error as Error).message}`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default Utils;
|
package/src/lib/WatchAPI.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import WatchWievModule from "./modules/poe.watch/WatchViewModule";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents an API for interacting with a poe.watch service.
|
|
5
|
-
*/
|
|
6
|
-
export class WatchAPI {
|
|
7
|
-
/**
|
|
8
|
-
* The WatchWievModule instance associated with this API.
|
|
9
|
-
*/
|
|
10
|
-
public view: WatchWievModule;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Creates an instance of WatchAPI.
|
|
14
|
-
* @param league - The league for which the API should be initialized.
|
|
15
|
-
*/
|
|
16
|
-
constructor(league: string) {
|
|
17
|
-
this.view = new WatchWievModule(league);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import IPoeNinja from "../Interfaces/IPoeNinja";
|
|
2
|
-
import getData from "../poe.ninja/func/getData";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Abstract class representing a PoeNinja.
|
|
6
|
-
* @abstract
|
|
7
|
-
* @class
|
|
8
|
-
* @implements {IPoeNinja}
|
|
9
|
-
*/
|
|
10
|
-
abstract class PoeNinja implements IPoeNinja {
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Represents a PoeNinja object.
|
|
14
|
-
* @constructor
|
|
15
|
-
* @param league - The league name.
|
|
16
|
-
* @param typeName
|
|
17
|
-
* @param type - The type.
|
|
18
|
-
*/
|
|
19
|
-
constructor(protected readonly league: string, protected readonly typeName: string, protected readonly type: string) {
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Retrieves data from the API based on the specified league, type name, and type.
|
|
23
|
-
* @param requestedProperties - Optional array of properties to include in the retrieved data.
|
|
24
|
-
* @returns A promise that resolves to an array of objects containing the retrieved data.
|
|
25
|
-
* @throws If there is an error retrieving the data.
|
|
26
|
-
*/
|
|
27
|
-
public async getData(requestedProperties?: string[]): Promise<object[]> {
|
|
28
|
-
try {
|
|
29
|
-
return getData(this.league, this.typeName, this.type, requestedProperties);
|
|
30
|
-
} catch (error: any) {
|
|
31
|
-
throw new Error(`Error getData ${this.typeName} and ${this.type} data: ${error.message}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default PoeNinja;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import IPoeWatch from "../Interfaces/IPoeWatch";
|
|
2
|
-
import getData from "../poe.watch/allModules/func/getData";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Represents an abstract class for interacting with the PoeWatch API.
|
|
6
|
-
*/
|
|
7
|
-
abstract class PoeWatch implements IPoeWatch {
|
|
8
|
-
constructor(protected readonly league: string, protected readonly type: string) {
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Retrieves data from the PoeWatch API.
|
|
13
|
-
* @param requestedProperties Optional array of properties to include in the response.
|
|
14
|
-
* @returns A promise that resolves to an array of objects containing the requested data.
|
|
15
|
-
* @throws If there is an error retrieving the data.
|
|
16
|
-
*/
|
|
17
|
-
public async getData(requestedProperties?: string[]): Promise<object[]> {
|
|
18
|
-
try {
|
|
19
|
-
return getData(this.league, this.type, requestedProperties);
|
|
20
|
-
} catch (error: any) {
|
|
21
|
-
throw new Error(`Error retrieving ${this.type} data: ${error.message}`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default PoeWatch;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents the interface for interacting with the PoeNinja API.
|
|
3
|
-
*/
|
|
4
|
-
interface IPoeNinja {
|
|
5
|
-
/**
|
|
6
|
-
* Retrieves data from the PoeNinja API.
|
|
7
|
-
* @param requestedProperties Optional array of properties to include in the response.
|
|
8
|
-
* @returns A promise that resolves to the retrieved data.
|
|
9
|
-
*/
|
|
10
|
-
getData(requestedProperties?: string[]): Promise<object[]>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default IPoeNinja;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents the interface for interacting with PoeWatch data.
|
|
3
|
-
*/
|
|
4
|
-
interface IPoeWatch {
|
|
5
|
-
/**
|
|
6
|
-
* Retrieves data from PoeWatch API.
|
|
7
|
-
* @param requestedProperties Optional array of properties to include in the response.
|
|
8
|
-
* @returns A promise that resolves to an array of objects representing the retrieved data.
|
|
9
|
-
*/
|
|
10
|
-
getData(requestedProperties?: string[]): Promise<object[]>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default IPoeWatch;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Filters properties of objects in an array based on the specified properties.
|
|
3
|
-
* @param data The array of objects to filter.
|
|
4
|
-
* @param requestedProperties The array of property names to include in the result.
|
|
5
|
-
* @returns An array of objects with only the specified properties.
|
|
6
|
-
*/
|
|
7
|
-
export default function filterProperties(data: Record<string, any>[], requestedProperties: string[]): object[] {
|
|
8
|
-
const result: object[] = [];
|
|
9
|
-
|
|
10
|
-
data.forEach((item) => {
|
|
11
|
-
const itemResult: Record<string, any> = {};
|
|
12
|
-
|
|
13
|
-
requestedProperties.forEach((prop) => {
|
|
14
|
-
if (Object.prototype.hasOwnProperty.call(item, prop)) {
|
|
15
|
-
itemResult[prop] = item[prop];
|
|
16
|
-
} else {
|
|
17
|
-
console.warn(`Property not found: ${prop}`);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
result.push(itemResult);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { CurrencyModule, FragmentModule } from "./currencySubModules/CurrencySubModules";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a module for fetching currency overview data.
|
|
5
|
-
*/
|
|
6
|
-
export class CurrencyViewModule {
|
|
7
|
-
/**
|
|
8
|
-
* Represents a module for fetching currency data.
|
|
9
|
-
*/
|
|
10
|
-
public currency: CurrencyModule;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Represents a module for fetching fragment data.
|
|
14
|
-
*/
|
|
15
|
-
public fragment: FragmentModule;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Creates a new CurrencyViewModule instance.
|
|
19
|
-
* @param league The name of the Path of Exile league.
|
|
20
|
-
* @param typeName The type of data to retrieve.
|
|
21
|
-
*/
|
|
22
|
-
constructor(league: string, typeName: string) {
|
|
23
|
-
this.currency = new CurrencyModule(league, typeName);
|
|
24
|
-
this.fragment = new FragmentModule(league, typeName);
|
|
25
|
-
}
|
|
26
|
-
}
|
package/src/lib/modules/poe.ninja/currencyView/currencySubModules/submodules/CurrencyModule.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import PoeNinja from "../../../../AbstractClass/PoeNinja";
|
|
2
|
-
import getQuickCurrency from "../../../func/getQuickCurrency";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Represents a module for retrieving currency data from the PoeNinja API.
|
|
6
|
-
*/
|
|
7
|
-
class CurrencyModule extends PoeNinja {
|
|
8
|
-
/**
|
|
9
|
-
* Creates an instance of CurrencyModule.
|
|
10
|
-
* @param league - The name of the league.
|
|
11
|
-
* @param typeName - The name of the type.
|
|
12
|
-
*/
|
|
13
|
-
constructor(protected league: string, protected typeName: string) {
|
|
14
|
-
const type: string = "Currency";
|
|
15
|
-
super(league, typeName, type);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Retrieves the quick currency data for the specified currency type.
|
|
20
|
-
* @param currencyTypeName - The name of the currency. Defaults to "Divine Orb".
|
|
21
|
-
* @returns A promise that resolves to an object containing the currency type name and its chaos equivalent value.
|
|
22
|
-
* @throws If there is an error fetching the quick currency data.
|
|
23
|
-
*/
|
|
24
|
-
async getQuickCurrency(currencyTypeName: string = "Divine Orb"): Promise<{ currencyTypeName: string, chaosEquivalent: number }> {
|
|
25
|
-
try {
|
|
26
|
-
return await getQuickCurrency(this.league, this.typeName, this.type, currencyTypeName);
|
|
27
|
-
} catch (error: any) {
|
|
28
|
-
throw new Error(`Error fetching QuickCurrencyData ${this.type} and Currency Name:${currencyTypeName} data: ${error.message}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default CurrencyModule;
|
package/src/lib/modules/poe.ninja/currencyView/currencySubModules/submodules/FragmentModule.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import PoeNinja from "../../../../AbstractClass/PoeNinja";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a module for handling fragments in the PoeNinja currency view.
|
|
5
|
-
*/
|
|
6
|
-
class FragmentModule extends PoeNinja {
|
|
7
|
-
/**
|
|
8
|
-
* Creates an instance of FragmentModule.
|
|
9
|
-
* @param league The league for which the module is created.
|
|
10
|
-
* @param typeName The type name of the module.
|
|
11
|
-
*/
|
|
12
|
-
constructor(protected league: string, protected typeName: string) {
|
|
13
|
-
const type: string = "Fragment";
|
|
14
|
-
super(league, typeName, type);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default FragmentModule;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import mergeData from "./merge/mergeData";
|
|
3
|
-
import urlGenerator from "../func/urlGenerator";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Fetches data from a specified API endpoint, merges relevant data, and returns the result.
|
|
7
|
-
* @param league The game league for which to fetch data.
|
|
8
|
-
* @param type The type of data to fetch. (e.g. "Currency", "Fragment")
|
|
9
|
-
* @param typeName The name of the type of data to fetch. (e.g. "CurrencyOverview", "ItemOverview")
|
|
10
|
-
* @returns A promise that resolves to an array of merged objects containing both line and currency details.
|
|
11
|
-
* @throws Throws an error if there's an issue with the API response or data fetching process.
|
|
12
|
-
*/
|
|
13
|
-
async function fetchData(league: string, typeName: string, type: string): Promise<object[]> {
|
|
14
|
-
try {
|
|
15
|
-
// Generate the URL for the specified league, type name, and type
|
|
16
|
-
const url: string = urlGenerator(league, typeName, type);
|
|
17
|
-
//axios.get(url) is a promise
|
|
18
|
-
const response = await axios.get(url, {
|
|
19
|
-
headers: {
|
|
20
|
-
'Accept-Encoding': 'identity',
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
//typwName is either currencyoverview or itemoverview
|
|
24
|
-
if (typeName == "currencyoverview") {
|
|
25
|
-
//if the response has data and lines and currencyDetails
|
|
26
|
-
if (response.data && response.data.lines && response.data.currencyDetails) {
|
|
27
|
-
const lines: any[] = response.data.lines;
|
|
28
|
-
const currencyDetails: any[] = response.data.currencyDetails;
|
|
29
|
-
//the join data is the currencyDetails
|
|
30
|
-
return mergeData(lines, currencyDetails);
|
|
31
|
-
} else {
|
|
32
|
-
throw new Error(
|
|
33
|
-
`Invalid response format from POE Ninja API CurrencyView Type:${type}`
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
} else if (typeName == "itemoverview") {
|
|
37
|
-
//if the response has data and lines
|
|
38
|
-
if (response.data && response.data.lines) {
|
|
39
|
-
return response.data.lines;
|
|
40
|
-
} else {
|
|
41
|
-
throw new Error(`"Invalid response format from POE Ninja API ItemView Type:${type}`);
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
throw new Error(`Invalid type: ${type}`);
|
|
45
|
-
}
|
|
46
|
-
} catch (error: any) {
|
|
47
|
-
throw new Error(`Error fetching data: ${error.message} TypeName:${typeName} and Type:${type}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default fetchData;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Merges the provided lines with the corresponding currency details.
|
|
3
|
-
* @param lines The lines to be merged.
|
|
4
|
-
* @param currencyDetails The currency details to be merged with the lines.
|
|
5
|
-
* @returns The merged data.
|
|
6
|
-
*/
|
|
7
|
-
function mergeData(lines: any[], currencyDetails: any[]): any[] {
|
|
8
|
-
const mergedData: any[] = [];
|
|
9
|
-
|
|
10
|
-
lines.forEach((line) => {
|
|
11
|
-
const currencyType: string = line.currencyTypeName;
|
|
12
|
-
|
|
13
|
-
// Find the corresponding currencyDetail based on currencyType
|
|
14
|
-
const currencyDetail = currencyDetails.find(
|
|
15
|
-
(detail) => detail.name === currencyType
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
if (currencyDetail) {
|
|
19
|
-
// Merge line and currencyDetail into a new object
|
|
20
|
-
const mergedItem: any = {
|
|
21
|
-
...line,
|
|
22
|
-
id: currencyDetail.id,
|
|
23
|
-
icon: currencyDetail.icon,
|
|
24
|
-
name: currencyDetail.name,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// Add the merged item to the result array
|
|
28
|
-
mergedData.push(mergedItem);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
return mergedData;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default mergeData;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import fetchData from '../fetch/fetchData';
|
|
2
|
-
import filterProperties from '../../mainfunctions/propertyFilter';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Fetches data from the specified league, type, and typeName.
|
|
6
|
-
*
|
|
7
|
-
* @param league - The name of the league to fetch data from.
|
|
8
|
-
* @param typeName - The name of the type to fetch data for.
|
|
9
|
-
* @param type - The type of data to fetch.
|
|
10
|
-
* @param requestedProperties - Optional. An array of properties to filter the fetched data by.
|
|
11
|
-
* @returns A promise that resolves to an array of objects containing the fetched data.
|
|
12
|
-
* @throws If there is an error fetching the data.
|
|
13
|
-
*/
|
|
14
|
-
async function getData(league: string, typeName: string, type: string, requestedProperties?: string[]): Promise<object[]> {
|
|
15
|
-
try {
|
|
16
|
-
const fetchedData: object[] = await fetchData(league, typeName, type);
|
|
17
|
-
|
|
18
|
-
//if requestedProperties use filterProperties to filter fetchedData
|
|
19
|
-
if (requestedProperties) {
|
|
20
|
-
const result: object[] = filterProperties(fetchedData, requestedProperties);
|
|
21
|
-
return result;
|
|
22
|
-
} else {
|
|
23
|
-
return fetchedData;
|
|
24
|
-
}
|
|
25
|
-
} catch (error) {
|
|
26
|
-
throw new Error(`Type:${type} Error fetching data: ${(error as Error).message}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default getData;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import fetchData from "../fetch/fetchData";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Retrieves quick currency data for a specific currency in a given league and type.
|
|
5
|
-
* @param league - The league for which to fetch currency data.
|
|
6
|
-
* @param typeName - The type of currency data to fetch.
|
|
7
|
-
* @param type - The type of currency data to fetch.
|
|
8
|
-
* @param currencyTypeName - The currencyTypeName of the currency to fetch data for.
|
|
9
|
-
* @returns {Promise<{currencyTypeName: string, chaosEquivalent: number}>} An object containing the currency type name and its chaos equivalent.
|
|
10
|
-
* @throws Throws an error if the currency data cannot be fetched or if the currency is not found.
|
|
11
|
-
*/
|
|
12
|
-
async function getQuickCurrency(league: string, typeName: string, type: string, currencyTypeName: string): Promise<{ currencyTypeName: string, chaosEquivalent: number }> {
|
|
13
|
-
try {
|
|
14
|
-
const fetchedData = await fetchData(league, typeName, type) as { currencyTypeName: string, chaosEquivalent: number }[];
|
|
15
|
-
//find the currencyTypeName in the fetchedData
|
|
16
|
-
for (const data of fetchedData) {
|
|
17
|
-
if (data.currencyTypeName === currencyTypeName) {
|
|
18
|
-
return {
|
|
19
|
-
currencyTypeName: data.currencyTypeName,
|
|
20
|
-
chaosEquivalent: data.chaosEquivalent,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
throw new Error("Currency not found");
|
|
25
|
-
} catch (error) {
|
|
26
|
-
throw new Error(`Error fetching currency data: ${(error as Error).message}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default getQuickCurrency;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates a URL based on league and type. poe.ninja (currencyView) API is used.
|
|
3
|
-
* @param league The league for which the URL is generated.
|
|
4
|
-
* @param type The type of data for which the URL is generated.
|
|
5
|
-
* @param typeName The name of the type of data for which the URL is generated.
|
|
6
|
-
* @returns The generated URL.
|
|
7
|
-
*/
|
|
8
|
-
export default function urlGenerator(league: string, typeName: string, type: string): string {
|
|
9
|
-
return `https://poe.ninja/api/data/${typeName}?league=${league}&type=${type}`;
|
|
10
|
-
}
|