export type CreateApiV0DeckArgs = {body: {version: number, god: string, protos: Array}}; export type CreateApiV0DeckOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Encodes a deck into a deck string * * POST /v0/deck */ export const createApiV0Deck = async (args: CreateApiV0DeckArgs, options?: CreateApiV0DeckOptions) => { const {baseUrl = "https://api.godsunchained.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v0/deck${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 };