export type GetApiV1VendorMacArgs = {mac: string}; export type GetApiV1VendorMacOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Vendor name only, plain text, no API key required * * GET /v1/vendor/{mac} */ export const getApiV1VendorMac = async (args: GetApiV1VendorMacArgs, options?: GetApiV1VendorMacOptions) => { const {baseUrl = "https://api.macadress.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") const url = `${baseUrl.replace(/\/+$/, '')}/v1/vendor/${encodeURIComponent(String(args.mac))}${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.text() };