diff --git a/src/content/pricing/pricestf.ts b/src/content/pricing/pricestf.ts index 4f83674..cdb273b 100644 --- a/src/content/pricing/pricestf.ts +++ b/src/content/pricing/pricestf.ts @@ -25,8 +25,17 @@ class PricesResponse { } /** - * Price the given item using https://prices.tf - * @return + * Fetches the current price data for Team Fortress 2 items from prices.tf. + * + * This function authenticates with the prices.tf API using the provided token, + * and uses it to fetch the latest pricing data for the given item in keys and metal. + * + * @example + * const price = await priceUsingPricesTF(token, 105, 11); + * console.log("Strange Brigade Helm price: ${price.keys} keys ${price.metal} metal") + * + * @returns {Promise} Object containing 'keys' and 'metal' prices + * @throws When authentication fails or API returns non-200 status code */ async function priceUsingPricesTF(token: string, defIndex: number, quality: number): Promise { // prices.tf @@ -37,7 +46,6 @@ async function priceUsingPricesTF(token: string, defIndex: number, quality: numb reject(401) } const sku = defIndex + ";" + quality; - // logDebug(`Making network request to prices.tf for ${sku}`) var response = await GM_fetch(`https://api2.prices.tf/prices/${encodeURIComponent(sku)}`, { method: 'get', headers: new Headers({ @@ -64,4 +72,4 @@ async function priceUsingPricesTF(token: string, defIndex: number, quality: numb }) } -export { getPricesToken, priceUsingPricesTF } \ No newline at end of file +export { getPricesToken, priceUsingPricesTF, PricesResponse } \ No newline at end of file