export type CreateApiOauthTokenRevokeArgs = {authorization: string}; export type CreateApiOauthTokenRevokeOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Revoke OAuth Token * * POST /oauth/token/revoke */ export const createApiOauthTokenRevoke = async (args: CreateApiOauthTokenRevokeArgs, options?: CreateApiOauthTokenRevokeOptions) => { const {baseUrl = "https://paella-sandbox.billie.io/api/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.authorization != null) headers.set("authorization", String(args.authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/oauth/token/revoke${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };