export type GetApiV1MockApisMockApiIdRequestsArgs = {limit?: string | undefined, since?: string | undefined}; export type GetApiV1MockApisMockApiIdRequestsOptions = {baseUrl?: string | undefined, tokenAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get all requests in journal * * GET /v1/mock-apis/{mockApiId}/requests */ export const getApiV1MockApisMockApiIdRequests = async (args: GetApiV1MockApisMockApiIdRequestsArgs, options?: GetApiV1MockApisMockApiIdRequestsOptions) => { const {baseUrl = "https://wmc.wiremockapi.cloud", fetch: fetchFn = fetch, tokenAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.limit != null) query.append("limit", String(args.limit)) if (args.since != null) query.append("since", String(args.since)) if (tokenAuth !== undefined) headers.set("Authorization", tokenAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/mock-apis/${encodeURIComponent(String(args.mockApiId))}/requests${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 (await res.json()) as unknown };