Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

25.6 KB
Raw Blame
/**
 * Generated by orval v7.21.0 🍺
 * Do not edit manually.
 * scheduled_action
 * API for managing scheduled actions
 * OpenAPI spec version: 0.1.0
 */
import type {
  ActionConfiguration,
  ActionConfigurationUpdate,
  ActionExecutionRecord,
  AiAdmissionErrorBody,
  CodeUpgrade,
  Draft,
  DraftRoutineRequest,
  EmptyResponse,
  InProgressExecution,
  ListScheduledActionsParams,
  RoutineTemplate,
  ScheduledActionResponse,
  SetScheduledActionEnabled,
  ShareRoutineTemplate,
  StarterRoutine,
} from './schemas';

export type scheduledActionHealthResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type scheduledActionHealthResponseSuccess =
  scheduledActionHealthResponse200 & {
    headers: Headers;
  };

export type scheduledActionHealthResponse =
  scheduledActionHealthResponseSuccess;

export const getScheduledActionHealthUrl = () => {
  return `/health`;
};

export const scheduledActionHealth = async (
  options?: RequestInit
): Promise<scheduledActionHealthResponse> => {
  const res = await fetch(getScheduledActionHealthUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: scheduledActionHealthResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as scheduledActionHealthResponse;
};

export type listScheduledActionsResponse200 = {
  data: ScheduledActionResponse[];
  status: 200;
};

export type listScheduledActionsResponse400 = {
  data: string;
  status: 400;
};

export type listScheduledActionsResponse401 = {
  data: string;
  status: 401;
};

export type listScheduledActionsResponse500 = {
  data: string;
  status: 500;
};

export type listScheduledActionsResponseSuccess =
  listScheduledActionsResponse200 & {
    headers: Headers;
  };
export type listScheduledActionsResponseError = (
  | listScheduledActionsResponse400
  | listScheduledActionsResponse401
  | listScheduledActionsResponse500
) & {
  headers: Headers;
};

export type listScheduledActionsResponse =
  | listScheduledActionsResponseSuccess
  | listScheduledActionsResponseError;

export const getListScheduledActionsUrl = (
  params?: ListScheduledActionsParams
) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/scheduled-actions?${stringifiedParams}`
    : `/scheduled-actions`;
};

export const listScheduledActions = async (
  params?: ListScheduledActionsParams,
  options?: RequestInit
): Promise<listScheduledActionsResponse> => {
  const res = await fetch(getListScheduledActionsUrl(params), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: listScheduledActionsResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as listScheduledActionsResponse;
};

export type createScheduledActionResponse201 = {
  data: ScheduledActionResponse;
  status: 201;
};

export type createScheduledActionResponse400 = {
  data: string;
  status: 400;
};

export type createScheduledActionResponse401 = {
  data: string;
  status: 401;
};

export type createScheduledActionResponse403 = {
  data: string;
  status: 403;
};

export type createScheduledActionResponse500 = {
  data: string;
  status: 500;
};

export type createScheduledActionResponseSuccess =
  createScheduledActionResponse201 & {
    headers: Headers;
  };
export type createScheduledActionResponseError = (
  | createScheduledActionResponse400
  | createScheduledActionResponse401
  | createScheduledActionResponse403
  | createScheduledActionResponse500
) & {
  headers: Headers;
};

export type createScheduledActionResponse =
  | createScheduledActionResponseSuccess
  | createScheduledActionResponseError;

export const getCreateScheduledActionUrl = () => {
  return `/scheduled-actions`;
};

export const createScheduledAction = async (
  actionConfiguration: ActionConfiguration,
  options?: RequestInit
): Promise<createScheduledActionResponse> => {
  const res = await fetch(getCreateScheduledActionUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(actionConfiguration),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: createScheduledActionResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as createScheduledActionResponse;
};

export type routineCodeStartersResponse200 = {
  data: StarterRoutine[];
  status: 200;
};

export type routineCodeStartersResponse401 = {
  data: string;
  status: 401;
};

export type routineCodeStartersResponseSuccess =
  routineCodeStartersResponse200 & {
    headers: Headers;
  };
export type routineCodeStartersResponseError =
  routineCodeStartersResponse401 & {
    headers: Headers;
  };

export type routineCodeStartersResponse =
  | routineCodeStartersResponseSuccess
  | routineCodeStartersResponseError;

export const getRoutineCodeStartersUrl = () => {
  return `/scheduled-actions/code/starters`;
};

export const routineCodeStarters = async (
  options?: RequestInit
): Promise<routineCodeStartersResponse> => {
  const res = await fetch(getRoutineCodeStartersUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: routineCodeStartersResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as routineCodeStartersResponse;
};

export type draftRoutineResponse200 = {
  data: Draft;
  status: 200;
};

export type draftRoutineResponse400 = {
  data: string;
  status: 400;
};

export type draftRoutineResponse401 = {
  data: string;
  status: 401;
};

export type draftRoutineResponse402 = {
  data: AiAdmissionErrorBody;
  status: 402;
};

export type draftRoutineResponse500 = {
  data: string;
  status: 500;
};

export type draftRoutineResponse503 = {
  data: AiAdmissionErrorBody;
  status: 503;
};

export type draftRoutineResponseSuccess = draftRoutineResponse200 & {
  headers: Headers;
};
export type draftRoutineResponseError = (
  | draftRoutineResponse400
  | draftRoutineResponse401
  | draftRoutineResponse402
  | draftRoutineResponse500
  | draftRoutineResponse503
) & {
  headers: Headers;
};

export type draftRoutineResponse =
  | draftRoutineResponseSuccess
  | draftRoutineResponseError;

export const getDraftRoutineUrl = () => {
  return `/scheduled-actions/drafts`;
};

export const draftRoutine = async (
  draftRoutineRequest: DraftRoutineRequest,
  options?: RequestInit
): Promise<draftRoutineResponse> => {
  const res = await fetch(getDraftRoutineUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(draftRoutineRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: draftRoutineResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as draftRoutineResponse;
};

export type getScheduledActionResponse200 = {
  data: ScheduledActionResponse;
  status: 200;
};

export type getScheduledActionResponse401 = {
  data: string;
  status: 401;
};

export type getScheduledActionResponse404 = {
  data: string;
  status: 404;
};

export type getScheduledActionResponse500 = {
  data: string;
  status: 500;
};

export type getScheduledActionResponseSuccess =
  getScheduledActionResponse200 & {
    headers: Headers;
  };
export type getScheduledActionResponseError = (
  | getScheduledActionResponse401
  | getScheduledActionResponse404
  | getScheduledActionResponse500
) & {
  headers: Headers;
};

export type getScheduledActionResponse =
  | getScheduledActionResponseSuccess
  | getScheduledActionResponseError;

export const getGetScheduledActionUrl = (id: string) => {
  return `/scheduled-actions/${id}`;
};

export const getScheduledAction = async (
  id: string,
  options?: RequestInit
): Promise<getScheduledActionResponse> => {
  const res = await fetch(getGetScheduledActionUrl(id), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getScheduledActionResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getScheduledActionResponse;
};

export type updateScheduledActionResponse200 = {
  data: ScheduledActionResponse;
  status: 200;
};

export type updateScheduledActionResponse400 = {
  data: string;
  status: 400;
};

export type updateScheduledActionResponse401 = {
  data: string;
  status: 401;
};

export type updateScheduledActionResponse404 = {
  data: string;
  status: 404;
};

export type updateScheduledActionResponse409 = {
  data: string;
  status: 409;
};

export type updateScheduledActionResponse500 = {
  data: string;
  status: 500;
};

export type updateScheduledActionResponseSuccess =
  updateScheduledActionResponse200 & {
    headers: Headers;
  };
export type updateScheduledActionResponseError = (
  | updateScheduledActionResponse400
  | updateScheduledActionResponse401
  | updateScheduledActionResponse404
  | updateScheduledActionResponse409
  | updateScheduledActionResponse500
) & {
  headers: Headers;
};

export type updateScheduledActionResponse =
  | updateScheduledActionResponseSuccess
  | updateScheduledActionResponseError;

export const getUpdateScheduledActionUrl = (id: string) => {
  return `/scheduled-actions/${id}`;
};

export const updateScheduledAction = async (
  id: string,
  actionConfigurationUpdate: ActionConfigurationUpdate,
  options?: RequestInit
): Promise<updateScheduledActionResponse> => {
  const res = await fetch(getUpdateScheduledActionUrl(id), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(actionConfigurationUpdate),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: updateScheduledActionResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as updateScheduledActionResponse;
};

export type deleteScheduledActionResponse204 = {
  data: void;
  status: 204;
};

export type deleteScheduledActionResponse401 = {
  data: string;
  status: 401;
};

export type deleteScheduledActionResponse404 = {
  data: string;
  status: 404;
};

export type deleteScheduledActionResponse500 = {
  data: string;
  status: 500;
};

export type deleteScheduledActionResponseSuccess =
  deleteScheduledActionResponse204 & {
    headers: Headers;
  };
export type deleteScheduledActionResponseError = (
  | deleteScheduledActionResponse401
  | deleteScheduledActionResponse404
  | deleteScheduledActionResponse500
) & {
  headers: Headers;
};

export type deleteScheduledActionResponse =
  | deleteScheduledActionResponseSuccess
  | deleteScheduledActionResponseError;

export const getDeleteScheduledActionUrl = (id: string) => {
  return `/scheduled-actions/${id}`;
};

export const deleteScheduledAction = async (
  id: string,
  options?: RequestInit
): Promise<deleteScheduledActionResponse> => {
  const res = await fetch(getDeleteScheduledActionUrl(id), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: deleteScheduledActionResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as deleteScheduledActionResponse;
};

export type listScheduledActionCodeUpgradesResponse200 = {
  data: CodeUpgrade[];
  status: 200;
};

export type listScheduledActionCodeUpgradesResponse401 = {
  data: string;
  status: 401;
};

export type listScheduledActionCodeUpgradesResponse404 = {
  data: string;
  status: 404;
};

export type listScheduledActionCodeUpgradesResponse500 = {
  data: string;
  status: 500;
};

export type listScheduledActionCodeUpgradesResponseSuccess =
  listScheduledActionCodeUpgradesResponse200 & {
    headers: Headers;
  };
export type listScheduledActionCodeUpgradesResponseError = (
  | listScheduledActionCodeUpgradesResponse401
  | listScheduledActionCodeUpgradesResponse404
  | listScheduledActionCodeUpgradesResponse500
) & {
  headers: Headers;
};

export type listScheduledActionCodeUpgradesResponse =
  | listScheduledActionCodeUpgradesResponseSuccess
  | listScheduledActionCodeUpgradesResponseError;

export const getListScheduledActionCodeUpgradesUrl = (id: string) => {
  return `/scheduled-actions/${id}/code-upgrades`;
};

export const listScheduledActionCodeUpgrades = async (
  id: string,
  options?: RequestInit
): Promise<listScheduledActionCodeUpgradesResponse> => {
  const res = await fetch(getListScheduledActionCodeUpgradesUrl(id), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: listScheduledActionCodeUpgradesResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as listScheduledActionCodeUpgradesResponse;
};

export type setScheduledActionEnabledResponse200 = {
  data: ScheduledActionResponse;
  status: 200;
};

export type setScheduledActionEnabledResponse400 = {
  data: string;
  status: 400;
};

export type setScheduledActionEnabledResponse401 = {
  data: string;
  status: 401;
};

export type setScheduledActionEnabledResponse404 = {
  data: string;
  status: 404;
};

export type setScheduledActionEnabledResponse409 = {
  data: string;
  status: 409;
};

export type setScheduledActionEnabledResponse500 = {
  data: string;
  status: 500;
};

export type setScheduledActionEnabledResponseSuccess =
  setScheduledActionEnabledResponse200 & {
    headers: Headers;
  };
export type setScheduledActionEnabledResponseError = (
  | setScheduledActionEnabledResponse400
  | setScheduledActionEnabledResponse401
  | setScheduledActionEnabledResponse404
  | setScheduledActionEnabledResponse409
  | setScheduledActionEnabledResponse500
) & {
  headers: Headers;
};

export type setScheduledActionEnabledResponse =
  | setScheduledActionEnabledResponseSuccess
  | setScheduledActionEnabledResponseError;

export const getSetScheduledActionEnabledUrl = (id: string) => {
  return `/scheduled-actions/${id}/enabled`;
};

export const setScheduledActionEnabled = async (
  id: string,
  setScheduledActionEnabled: SetScheduledActionEnabled,
  options?: RequestInit
): Promise<setScheduledActionEnabledResponse> => {
  const res = await fetch(getSetScheduledActionEnabledUrl(id), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(setScheduledActionEnabled),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: setScheduledActionEnabledResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as setScheduledActionEnabledResponse;
};

export type executeScheduledActionNowResponse200 = {
  data: InProgressExecution;
  status: 200;
};

export type executeScheduledActionNowResponse400 = {
  data: string;
  status: 400;
};

export type executeScheduledActionNowResponse401 = {
  data: string;
  status: 401;
};

export type executeScheduledActionNowResponse402 = {
  data: AiAdmissionErrorBody;
  status: 402;
};

export type executeScheduledActionNowResponse404 = {
  data: string;
  status: 404;
};

export type executeScheduledActionNowResponse409 = {
  data: string;
  status: 409;
};

export type executeScheduledActionNowResponse500 = {
  data: string;
  status: 500;
};

export type executeScheduledActionNowResponse503 = {
  data: AiAdmissionErrorBody;
  status: 503;
};

export type executeScheduledActionNowResponseSuccess =
  executeScheduledActionNowResponse200 & {
    headers: Headers;
  };
export type executeScheduledActionNowResponseError = (
  | executeScheduledActionNowResponse400
  | executeScheduledActionNowResponse401
  | executeScheduledActionNowResponse402
  | executeScheduledActionNowResponse404
  | executeScheduledActionNowResponse409
  | executeScheduledActionNowResponse500
  | executeScheduledActionNowResponse503
) & {
  headers: Headers;
};

export type executeScheduledActionNowResponse =
  | executeScheduledActionNowResponseSuccess
  | executeScheduledActionNowResponseError;

export const getExecuteScheduledActionNowUrl = (id: string) => {
  return `/scheduled-actions/${id}/execute`;
};

export const executeScheduledActionNow = async (
  id: string,
  options?: RequestInit
): Promise<executeScheduledActionNowResponse> => {
  const res = await fetch(getExecuteScheduledActionNowUrl(id), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: executeScheduledActionNowResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as executeScheduledActionNowResponse;
};

export type listScheduledActionHistoryResponse200 = {
  data: ActionExecutionRecord[];
  status: 200;
};

export type listScheduledActionHistoryResponse401 = {
  data: string;
  status: 401;
};

export type listScheduledActionHistoryResponse404 = {
  data: string;
  status: 404;
};

export type listScheduledActionHistoryResponse500 = {
  data: string;
  status: 500;
};

export type listScheduledActionHistoryResponseSuccess =
  listScheduledActionHistoryResponse200 & {
    headers: Headers;
  };
export type listScheduledActionHistoryResponseError = (
  | listScheduledActionHistoryResponse401
  | listScheduledActionHistoryResponse404
  | listScheduledActionHistoryResponse500
) & {
  headers: Headers;
};

export type listScheduledActionHistoryResponse =
  | listScheduledActionHistoryResponseSuccess
  | listScheduledActionHistoryResponseError;

export const getListScheduledActionHistoryUrl = (id: string) => {
  return `/scheduled-actions/${id}/history`;
};

export const listScheduledActionHistory = async (
  id: string,
  options?: RequestInit
): Promise<listScheduledActionHistoryResponse> => {
  const res = await fetch(getListScheduledActionHistoryUrl(id), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: listScheduledActionHistoryResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as listScheduledActionHistoryResponse;
};

export type getScheduledActionTemplateResponse200 = {
  data: RoutineTemplate;
  status: 200;
};

export type getScheduledActionTemplateResponse401 = {
  data: string;
  status: 401;
};

export type getScheduledActionTemplateResponse404 = {
  data: string;
  status: 404;
};

export type getScheduledActionTemplateResponse500 = {
  data: string;
  status: 500;
};

export type getScheduledActionTemplateResponseSuccess =
  getScheduledActionTemplateResponse200 & {
    headers: Headers;
  };
export type getScheduledActionTemplateResponseError = (
  | getScheduledActionTemplateResponse401
  | getScheduledActionTemplateResponse404
  | getScheduledActionTemplateResponse500
) & {
  headers: Headers;
};

export type getScheduledActionTemplateResponse =
  | getScheduledActionTemplateResponseSuccess
  | getScheduledActionTemplateResponseError;

export const getGetScheduledActionTemplateUrl = (id: string) => {
  return `/scheduled-actions/${id}/template`;
};

export const getScheduledActionTemplate = async (
  id: string,
  options?: RequestInit
): Promise<getScheduledActionTemplateResponse> => {
  const res = await fetch(getGetScheduledActionTemplateUrl(id), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getScheduledActionTemplateResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getScheduledActionTemplateResponse;
};

export type shareScheduledActionTemplateResponse200 = {
  data: RoutineTemplate;
  status: 200;
};

export type shareScheduledActionTemplateResponse400 = {
  data: string;
  status: 400;
};

export type shareScheduledActionTemplateResponse401 = {
  data: string;
  status: 401;
};

export type shareScheduledActionTemplateResponse404 = {
  data: string;
  status: 404;
};

export type shareScheduledActionTemplateResponse500 = {
  data: string;
  status: 500;
};

export type shareScheduledActionTemplateResponseSuccess =
  shareScheduledActionTemplateResponse200 & {
    headers: Headers;
  };
export type shareScheduledActionTemplateResponseError = (
  | shareScheduledActionTemplateResponse400
  | shareScheduledActionTemplateResponse401
  | shareScheduledActionTemplateResponse404
  | shareScheduledActionTemplateResponse500
) & {
  headers: Headers;
};

export type shareScheduledActionTemplateResponse =
  | shareScheduledActionTemplateResponseSuccess
  | shareScheduledActionTemplateResponseError;

export const getShareScheduledActionTemplateUrl = (id: string) => {
  return `/scheduled-actions/${id}/template`;
};

export const shareScheduledActionTemplate = async (
  id: string,
  shareRoutineTemplate: ShareRoutineTemplate,
  options?: RequestInit
): Promise<shareScheduledActionTemplateResponse> => {
  const res = await fetch(getShareScheduledActionTemplateUrl(id), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(shareRoutineTemplate),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: shareScheduledActionTemplateResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as shareScheduledActionTemplateResponse;
};

export type unshareScheduledActionTemplateResponse204 = {
  data: void;
  status: 204;
};

export type unshareScheduledActionTemplateResponse401 = {
  data: string;
  status: 401;
};

export type unshareScheduledActionTemplateResponse404 = {
  data: string;
  status: 404;
};

export type unshareScheduledActionTemplateResponse500 = {
  data: string;
  status: 500;
};

export type unshareScheduledActionTemplateResponseSuccess =
  unshareScheduledActionTemplateResponse204 & {
    headers: Headers;
  };
export type unshareScheduledActionTemplateResponseError = (
  | unshareScheduledActionTemplateResponse401
  | unshareScheduledActionTemplateResponse404
  | unshareScheduledActionTemplateResponse500
) & {
  headers: Headers;
};

export type unshareScheduledActionTemplateResponse =
  | unshareScheduledActionTemplateResponseSuccess
  | unshareScheduledActionTemplateResponseError;

export const getUnshareScheduledActionTemplateUrl = (id: string) => {
  return `/scheduled-actions/${id}/template`;
};

export const unshareScheduledActionTemplate = async (
  id: string,
  options?: RequestInit
): Promise<unshareScheduledActionTemplateResponse> => {
  const res = await fetch(getUnshareScheduledActionTemplateUrl(id), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: unshareScheduledActionTemplateResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as unshareScheduledActionTemplateResponse;
};

export type activateScheduledActionTemplateResponse201 = {
  data: ScheduledActionResponse;
  status: 201;
};

export type activateScheduledActionTemplateResponse400 = {
  data: string;
  status: 400;
};

export type activateScheduledActionTemplateResponse401 = {
  data: string;
  status: 401;
};

export type activateScheduledActionTemplateResponse403 = {
  data: string;
  status: 403;
};

export type activateScheduledActionTemplateResponse404 = {
  data: string;
  status: 404;
};

export type activateScheduledActionTemplateResponse500 = {
  data: string;
  status: 500;
};

export type activateScheduledActionTemplateResponseSuccess =
  activateScheduledActionTemplateResponse201 & {
    headers: Headers;
  };
export type activateScheduledActionTemplateResponseError = (
  | activateScheduledActionTemplateResponse400
  | activateScheduledActionTemplateResponse401
  | activateScheduledActionTemplateResponse403
  | activateScheduledActionTemplateResponse404
  | activateScheduledActionTemplateResponse500
) & {
  headers: Headers;
};

export type activateScheduledActionTemplateResponse =
  | activateScheduledActionTemplateResponseSuccess
  | activateScheduledActionTemplateResponseError;

export const getActivateScheduledActionTemplateUrl = (id: string) => {
  return `/scheduled-actions/${id}/template/activate`;
};

export const activateScheduledActionTemplate = async (
  id: string,
  actionConfiguration: ActionConfiguration,
  options?: RequestInit
): Promise<activateScheduledActionTemplateResponse> => {
  const res = await fetch(getActivateScheduledActionTemplateUrl(id), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(actionConfiguration),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: activateScheduledActionTemplateResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as activateScheduledActionTemplateResponse;
};