export type SerializedPushGroupJoinPost = {address?: string | undefined, badgeCode?: string | undefined, signature?: string | undefined}; export type CreateApiPushGroupJoinArgs = {body: SerializedPushGroupJoinPost}; export type CreateApiPushGroupJoinOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Request to join a Push Protocol token gated community * * POST /push/group/join */ export const createApiPushGroupJoin = async (args: CreateApiPushGroupJoinArgs, options?: CreateApiPushGroupJoinOptions) => { const {baseUrl = "https://api.unstoppabledomains.com/messaging", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/push/group/join${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 };