export type GetApiV10GetPublishedListingsArgs = {type: 'LuxVT' | 'AptCom' | 'AllOnMarket', Authorization: string}; export type GetApiV10GetPublishedListingsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Published Listings * * GET /v1.0/getPublishedListings */ export const getApiV10GetPublishedListings = async (args: GetApiV10GetPublishedListingsArgs, options?: GetApiV10GetPublishedListingsOptions) => { const {baseUrl = "https://api.lofty.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/xml") if (args.type != null) query.append("type", String(args.type)) if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/v1.0/getPublishedListings${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() };