export type StimulusInCreate = {stimulusType: string, stimulusValue: number, reason?: string | undefined}; export type BodyPokePermissionsSendPokeApiV5PokesSendUserFriendIdPost = {stimulus: StimulusInCreate}; export type CreateApiApiV5PokesSendUserFriendIdArgs = {friend_id: number, body: BodyPokePermissionsSendPokeApiV5PokesSendUserFriendIdPost}; export type CreateApiApiV5PokesSendUserFriendIdOptions = {baseUrl?: string | undefined, RWAPIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send poke * * POST /api/v5/pokes/send/user/{friend_id} */ export const createApiApiV5PokesSendUserFriendId = async (args: CreateApiApiV5PokesSendUserFriendIdArgs, options?: CreateApiApiV5PokesSendUserFriendIdOptions) => { const {baseUrl = "https://api.pavlok.com", fetch: fetchFn = fetch, RWAPIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (RWAPIKeyHeader !== undefined) headers.set("Authorization", RWAPIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/api/v5/pokes/send/user/${encodeURIComponent(String(args.friend_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };