export type GetApiBapiV1NewsArgs = {category?: string | undefined, searchKeyword?: string | undefined, sortType?: ('AMOUNT_ASC' | 'AMOUNT_DESC' | 'ASC' | 'DESC' | 'NONE' | 'PRICE_ASC' | 'PRICE_DESC' | 'UNIT_PRICE_ASC' | 'UNIT_PRICE_DESC') | undefined, pageNum: number, pageSize: number}; export type GetApiBapiV1NewsOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * 뉴스 리스트 조회 * * GET /bapi/v1/news */ export const getApiBapiV1News = async (args: GetApiBapiV1NewsArgs, options?: GetApiBapiV1NewsOptions) => { const {baseUrl = "https://api.wincl.io:443", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.category != null) query.append("category", String(args.category)) if (args.searchKeyword != null) query.append("searchKeyword", String(args.searchKeyword)) if (args.sortType != null) query.append("sortType", String(args.sortType)) if (args.pageNum != null) query.append("pageNum", String(args.pageNum)) if (args.pageSize != null) query.append("pageSize", String(args.pageSize)) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/bapi/v1/news${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 res.blob() };