export type MetaData = {os?: string | undefined, browser?: string | undefined, timeZone?: string | undefined, browserLanguage?: string | undefined, date_time?: string | undefined}; export type Model193 = {contact_id?: number | undefined, channel_id?: number | undefined, metaData?: MetaData | undefined}; export type CreateApiV1SurveysSurveyIdSubmissionStartArgs = {survey_id: number, body: Model193}; export type CreateApiV1SurveysSurveyIdSubmissionStartOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Start submission * * POST /v1/surveys/{survey_id}/submission/start */ export const createApiV1SurveysSurveyIdSubmissionStart = async (args: CreateApiV1SurveysSurveyIdSubmissionStartArgs, options?: CreateApiV1SurveysSurveyIdSubmissionStartOptions) => { const {baseUrl = "https://api.surveysparrow.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/v1/surveys/${encodeURIComponent(String(args.survey_id))}/submission/start${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 res.blob() };