UNPKG

poe-api-manager

Version:
53 lines (52 loc) 2.19 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CurrencyModule = void 0; const PoeNinja_1 = __importDefault(require("../../../../../AbstractClass/PoeNinja")); const getQuickCurrency_1 = __importDefault(require("../../../func/getQuickCurrency")); const CustomError_1 = __importDefault(require("../../../../../errors/CustomError")); const ApiError_1 = __importDefault(require("../../../../../errors/ApiError")); /** * Represents a module for retrieving currency data from the PoeNinja API. */ class CurrencyModule extends PoeNinja_1.default { league; typeName; /** * Creates an instance of CurrencyModule. * @param league - The name of the league. * @param typeName - The name of the type. */ constructor(league, typeName) { const type = "Currency"; super(league, typeName, type); this.league = league; this.typeName = typeName; } /** * Retrieves the quick currency data for the specified currency type. * @param currencyTypeName - The name of the currency. Defaults to "Divine Orb". * @returns A promise that resolves to an object containing the currency type name and its chaos equivalent value. * @throws If there is an error fetching the quick currency data. */ async getQuickCurrency(currencyTypeName = "Divine Orb") { try { return await (0, getQuickCurrency_1.default)(this.league, this.typeName, this.type, currencyTypeName); } catch (error) { // Pass through custom errors if (error instanceof CustomError_1.default) { throw error; } throw new ApiError_1.default(`Error fetching QuickCurrencyData ${this.type} and Currency Name:${currencyTypeName} data: ${error.message}`, 500, { league: this.league, typeName: this.typeName, type: this.type, currencyTypeName, }); } } } exports.CurrencyModule = CurrencyModule;