export type AddNoteToSubmissionRequest = {note: string, noteVisibility: 'team' | 'admins_only' | 'staff' | 'private' | 'Private' | 'Entire Team' | 'All Staff', fileId?: (string | null) | undefined, fileStorageKey?: (string | null) | undefined}; export type CreateApiV4SubmissionsSubmissionIdNotesArgs = {submissionId: string, body: AddNoteToSubmissionRequest}; export type CreateApiV4SubmissionsSubmissionIdNotesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add a note to a submission * * POST /v4/submissions/{submissionId}/notes */ export const createApiV4SubmissionsSubmissionIdNotes = async (args: CreateApiV4SubmissionsSubmissionIdNotesArgs, options?: CreateApiV4SubmissionsSubmissionIdNotesOptions) => { const {baseUrl = "https://submittable-api.submittable.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v4/submissions/${encodeURIComponent(String(args.submissionId))}/notes${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 };