export type GetApiV1ServicesArgs = {categorized?: string | undefined, search?: string | undefined, ordering?: string | undefined, limit?: number | undefined, offset?: number | undefined}; export type GetApiV1ServicesOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * List services * * GET /v1/services */ export const getApiV1Services = async (args: GetApiV1ServicesArgs, options?: GetApiV1ServicesOptions) => { const {baseUrl = "https://developer.yezza.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.categorized != null) query.append("categorized", String(args.categorized)) if (args.search != null) query.append("search", String(args.search)) if (args.ordering != null) query.append("ordering", String(args.ordering)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (ApiKeyAuth !== undefined) headers.set("X-Api-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/services${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 };