export type FileRequest = {fileId: string}; export type CreateSubmissionMessageRequest = {subject: string, body: string, files?: (Array | null) | undefined, shouldUseOrganizationEmailAsFromAddress?: boolean | undefined}; export type UpdateSubmissionStatusAcceptedRequest = {status: 'new' | 'in_progress' | 'accepted' | 'declined' | 'withdrawn' | 'completed' | 'editable' | 'viewed' | 'received' | 'published', internalNote?: (string | null) | undefined, message?: CreateSubmissionMessageRequest | undefined}; export type UpdateSubmissionStatusInProgressRequest = {status: 'new' | 'in_progress' | 'accepted' | 'declined' | 'withdrawn' | 'completed' | 'editable' | 'viewed' | 'received' | 'published', internalNote?: (string | null) | undefined, message?: CreateSubmissionMessageRequest | undefined}; export type UpdateSubmissionStatusDeclinedRequest = {status: 'new' | 'in_progress' | 'accepted' | 'declined' | 'withdrawn' | 'completed' | 'editable' | 'viewed' | 'received' | 'published', internalNote?: (string | null) | undefined, message?: CreateSubmissionMessageRequest | undefined}; export type UpdateSubmissionStatusWithdrawnRequest = {status: 'new' | 'in_progress' | 'accepted' | 'declined' | 'withdrawn' | 'completed' | 'editable' | 'viewed' | 'received' | 'published', internalNote?: (string | null) | undefined, message?: CreateSubmissionMessageRequest | undefined}; export type UpdateSubmissionStatusCompletedRequest = {status: 'new' | 'in_progress' | 'accepted' | 'declined' | 'withdrawn' | 'completed' | 'editable' | 'viewed' | 'received' | 'published', internalNote?: (string | null) | undefined, message?: CreateSubmissionMessageRequest | undefined}; export type UpdateApiV4SubmissionsSubmissionIdStatusArgs = {submissionId: string, body: UpdateSubmissionStatusAcceptedRequest | UpdateSubmissionStatusInProgressRequest | UpdateSubmissionStatusDeclinedRequest | UpdateSubmissionStatusWithdrawnRequest | UpdateSubmissionStatusCompletedRequest}; export type UpdateApiV4SubmissionsSubmissionIdStatusOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update status of a submission * * PUT /v4/submissions/{submissionId}/status */ export const updateApiV4SubmissionsSubmissionIdStatus = async (args: UpdateApiV4SubmissionsSubmissionIdStatusArgs, options?: UpdateApiV4SubmissionsSubmissionIdStatusOptions) => { 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))}/status${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };