export type GetApiV1FlowTickersTickerContractOptionsArgs = {ticker: string, session_date?: string | undefined, root?: string | undefined, expiration: string, limit?: number | undefined, cursor?: string | undefined}; export type GetApiV1FlowTickersTickerContractOptionsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Option-contract directory for one required expiration, paged up to 200 contracts. ET dates use YYYY-MM-DD. * * GET /v1/flow/tickers/{ticker}/contract-options */ export const getApiV1FlowTickersTickerContractOptions = async (args: GetApiV1FlowTickersTickerContractOptionsArgs, options?: GetApiV1FlowTickersTickerContractOptionsOptions) => { const {baseUrl = "https://api.yehangshe.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.session_date != null) query.append("session_date", String(args.session_date)) if (args.root != null) query.append("root", String(args.root)) if (args.expiration != null) query.append("expiration", String(args.expiration)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.cursor != null) query.append("cursor", String(args.cursor)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/flow/tickers/${encodeURIComponent(String(args.ticker))}/contract-options${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };