export type PartnerActionResultUrlType = 'Popup' | 'Page'; export type PartnerActionResultCommandModel = {score?: (number | null) | undefined, url?: (string | null) | undefined, urlType?: PartnerActionResultUrlType | undefined}; export type UpdateJobAdPartnerActionCommand = {status?: (string | null) | undefined, result?: PartnerActionResultCommandModel | undefined}; export type UpdateApiPartnersActionsActionIdJobadsAdIdCompleteArgs = {actionId: string, adId: number, body: UpdateJobAdPartnerActionCommand}; export type UpdateApiPartnersActionsActionIdJobadsAdIdCompleteOptions = {baseUrl: string, jobadderIdentity?: string | undefined, fetch?: typeof fetch | undefined}; /** * Complete a job ad action * * PUT /partners/actions/{actionId}/jobads/{adId}/complete */ export const updateApiPartnersActionsActionIdJobadsAdIdComplete = async (args: UpdateApiPartnersActionsActionIdJobadsAdIdCompleteArgs, options: UpdateApiPartnersActionsActionIdJobadsAdIdCompleteOptions) => { const {baseUrl, fetch: fetchFn = fetch, jobadderIdentity} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (jobadderIdentity !== undefined) headers.set('authorization', `Bearer ${jobadderIdentity}`) const url = `${baseUrl.replace(/\/+$/, '')}/partners/actions/${encodeURIComponent(String(args.actionId))}/jobads/${encodeURIComponent(String(args.adId))}/complete${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 };