doc: fix incomplete documentation of priceUsingPricesTF

This commit is contained in:
xenticore
2025-03-27 15:28:53 -04:00
parent 7c7e58d0d2
commit b24cda98ad

View File

@@ -25,8 +25,17 @@ class PricesResponse {
} }
/** /**
* Price the given item using https://prices.tf * Fetches the current price data for Team Fortress 2 items from prices.tf.
* @return *
* 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<PricesResponse>} 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<PricesResponse> { async function priceUsingPricesTF(token: string, defIndex: number, quality: number): Promise<PricesResponse> {
// prices.tf // prices.tf
@@ -37,7 +46,6 @@ async function priceUsingPricesTF(token: string, defIndex: number, quality: numb
reject(401) reject(401)
} }
const sku = defIndex + ";" + quality; 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)}`, { var response = await GM_fetch(`https://api2.prices.tf/prices/${encodeURIComponent(sku)}`, {
method: 'get', method: 'get',
headers: new Headers({ headers: new Headers({
@@ -64,4 +72,4 @@ async function priceUsingPricesTF(token: string, defIndex: number, quality: numb
}) })
} }
export { getPricesToken, priceUsingPricesTF } export { getPricesToken, priceUsingPricesTF, PricesResponse }