/** * Raw Response Resource * * Provides opt-in access to the underlying HTTP status code and response * headers alongside the parsed data. Mirrors the most commonly used top-level * client methods. This is the #1 requested enhancement (issue #7). * * @example * ```typescript * import { OilPriceAPI } from 'oilpriceapi'; * * const client = new OilPriceAPI({ apiKey: 'your_key' }); * * const { data, status, headers } = await client.raw.getLatestPrices(); * console.log(`HTTP ${status}`); * console.log(`Rate limit remaining: ${headers.get('x-ratelimit-remaining')}`); * console.log(data[0].price); * ``` */ import type { OilPriceAPI, APIResponse } from "../client.js"; import type { Price, LatestPricesOptions, HistoricalPricesOptions, Commodity, CommoditiesResponse, CategoriesResponse } from "../types.js"; /** * Raw Response Resource * * Each method returns an {@link APIResponse} with `{ data, status, headers }` * instead of just the parsed data, so callers can inspect HTTP metadata such * as rate-limit headers, caching headers, and the exact status code. */ export declare class RawResource { private client; constructor(client: OilPriceAPI); /** * Make an arbitrary GET request and return data plus HTTP status and headers. * * Use this for endpoints without a dedicated raw helper. * * @typeParam T - Expected parsed response type. * @param endpoint - API path beginning with `/` (e.g. `/v1/prices/latest`). * @param params - Optional query parameters. * @returns The parsed data along with the HTTP status code and headers. * * @example * ```typescript * const { data, status, headers } = await client.raw.get('/v1/futures/CL.1'); * ``` */ get(endpoint: string, params?: Record): Promise>; /** * Latest prices with raw HTTP status and headers. * * @param options - Optional commodity filter. * @returns Prices array with HTTP status and headers. * * @example * ```typescript * const { data, status, headers } = await client.raw.getLatestPrices({ commodity: 'WTI_USD' }); * ``` */ getLatestPrices(options?: LatestPricesOptions): Promise>; /** * Historical prices with raw HTTP status and headers. * * @param options - Time period and filter options. * @returns Prices array with HTTP status and headers. * * @example * ```typescript * const { data, status, headers } = await client.raw.getHistoricalPrices({ * period: 'past_week', * commodity: 'BRENT_CRUDE_USD', * }); * ``` */ getHistoricalPrices(options?: HistoricalPricesOptions): Promise>; /** * Commodities metadata with raw HTTP status and headers. * * @returns Commodities response with HTTP status and headers. */ getCommodities(): Promise>; /** * Commodity categories with raw HTTP status and headers. * * @returns Categories response with HTTP status and headers. */ getCommodityCategories(): Promise>; /** * A single commodity's metadata with raw HTTP status and headers. * * @param code - Commodity code (e.g., "WTI_USD"). * @returns Commodity with HTTP status and headers. */ getCommodity(code: string): Promise>; }