export type ApplicationId = string; export type ErrorDetail = {attribute?: string | undefined, message?: string | undefined}; export type UpsertStorelinkEventResultRequest = {success: boolean, storeId?: (string | null) | undefined, errorMessage?: ({message?: string | undefined, details?: Array | undefined} | null) | undefined}; export type CreateApiV1StoresArgs = {'X-Application-Id': ApplicationId, 'X-Event-Id': string, body: UpsertStorelinkEventResultRequest}; export type CreateApiV1StoresOptions = {baseUrl?: string | undefined, OAuth20?: string | undefined, fetch?: typeof fetch | undefined}; /** * Complete store onboarding * * POST /v1/stores */ export const createApiV1Stores = async (args: CreateApiV1StoresArgs, options?: CreateApiV1StoresOptions) => { const {baseUrl = "https://partners.tryotter.com", fetch: fetchFn = fetch, OAuth20} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Application-Id'] != null) headers.set("X-Application-Id", String(args['X-Application-Id'])) if (args['X-Event-Id'] != null) headers.set("X-Event-Id", String(args['X-Event-Id'])) if (OAuth20 !== undefined) headers.set('authorization', `Bearer ${OAuth20}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/stores${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 };