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.

46.4 KB
Raw Blame
/**
 * Generated by orval v7.21.0 🍺
 * Do not edit manually.
 * calendar_service
 * OpenAPI spec version: 0.1.0
 */
import type {
  AvailabilityCalendarBody,
  AvailabilityCalendarsResponse,
  BookingChange,
  BookingInsights,
  BookingLink,
  BookingLinkListing,
  BookingProfile,
  BookingResponse,
  BookingsResponse,
  CalendarEvent,
  CalendarEventProviderUrl,
  CalendarEventProviderUrlParams,
  CalendarJoinRequest,
  CalendarMutationApiError,
  CalendarReplacementView,
  CopyCalendarEventRequest,
  CreateBookingLinkParams,
  CreateBookingLinkRequest,
  CreateCalendarEventRequest,
  DeleteCalendarEventParams,
  EditBookingLinkParams,
  EditBookingLinkRequest,
  GetBookingInsightsParams,
  GetBookingSettingsParams,
  InsightQuery,
  InviteCalendarEventGuestsRequest,
  ListBookingLinksParams,
  ListBookingRescheduleSlotsParams,
  ListBookingsParams,
  ListCalendarsResponse,
  PrepareCalendarReplacementRequest,
  ProfileResponse,
  ReceiptResponse,
  RespondToJoinRequestRequest,
  RsvpCalendarEventRequest,
  SaveBookingSettingsParams,
  SlotsResponse,
  TeamCalendarSharingBody,
  UpdateCalendarEventRequest,
} from './schemas';

/**
 * @summary List calendars and their personal-availability inclusion.
 */
export type getAvailabilityCalendarsResponse200 = {
  data: AvailabilityCalendarsResponse;
  status: 200;
};

export type getAvailabilityCalendarsResponseSuccess =
  getAvailabilityCalendarsResponse200 & {
    headers: Headers;
  };

export type getAvailabilityCalendarsResponse =
  getAvailabilityCalendarsResponseSuccess;

export const getGetAvailabilityCalendarsUrl = () => {
  return `/availability-calendars`;
};

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

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

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

/**
 * @summary Change which source calendars normally occupy this user's time.
 */
export type setAvailabilityCalendarResponse204 = {
  data: void;
  status: 204;
};

export type setAvailabilityCalendarResponseSuccess =
  setAvailabilityCalendarResponse204 & {
    headers: Headers;
  };

export type setAvailabilityCalendarResponse =
  setAvailabilityCalendarResponseSuccess;

export const getSetAvailabilityCalendarUrl = (calendarId: string) => {
  return `/availability-calendars/${calendarId}`;
};

export const setAvailabilityCalendar = async (
  calendarId: string,
  availabilityCalendarBody: AvailabilityCalendarBody,
  options?: RequestInit
): Promise<setAvailabilityCalendarResponse> => {
  const res = await fetch(getSetAvailabilityCalendarUrl(calendarId), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(availabilityCalendarBody),
  });

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

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

/**
 * @summary List the requester's visible calendars for pickers and filters.
 */
export type listCalendarsResponse200 = {
  data: ListCalendarsResponse;
  status: 200;
};

export type listCalendarsResponse401 = {
  data: void;
  status: 401;
};

export type listCalendarsResponse503 = {
  data: CalendarMutationApiError;
  status: 503;
};

export type listCalendarsResponseSuccess = listCalendarsResponse200 & {
  headers: Headers;
};
export type listCalendarsResponseError = (
  | listCalendarsResponse401
  | listCalendarsResponse503
) & {
  headers: Headers;
};

export type listCalendarsResponse =
  | listCalendarsResponseSuccess
  | listCalendarsResponseError;

export const getListCalendarsUrl = () => {
  return `/calendars`;
};

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

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

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

/**
 * @summary Create a calendar event and return its synced entity.
 */
export type createCalendarEventResponse201 = {
  data: CalendarEvent;
  status: 201;
};

export type createCalendarEventResponse400 = {
  data: CalendarMutationApiError;
  status: 400;
};

export type createCalendarEventResponse401 = {
  data: void;
  status: 401;
};

export type createCalendarEventResponse403 = {
  data: CalendarMutationApiError;
  status: 403;
};

export type createCalendarEventResponse409 = {
  data: CalendarMutationApiError;
  status: 409;
};

export type createCalendarEventResponse503 = {
  data: CalendarMutationApiError;
  status: 503;
};

export type createCalendarEventResponseSuccess =
  createCalendarEventResponse201 & {
    headers: Headers;
  };
export type createCalendarEventResponseError = (
  | createCalendarEventResponse400
  | createCalendarEventResponse401
  | createCalendarEventResponse403
  | createCalendarEventResponse409
  | createCalendarEventResponse503
) & {
  headers: Headers;
};

export type createCalendarEventResponse =
  | createCalendarEventResponseSuccess
  | createCalendarEventResponseError;

export const getCreateCalendarEventUrl = () => {
  return `/events`;
};

export const createCalendarEvent = async (
  createCalendarEventRequest: CreateCalendarEventRequest,
  options?: RequestInit
): Promise<createCalendarEventResponse> => {
  const res = await fetch(getCreateCalendarEventUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(createCalendarEventRequest),
  });

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

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

/**
 * @summary Delete a calendar event at its provider.
 */
export type deleteCalendarEventResponse204 = {
  data: void;
  status: 204;
};

export type deleteCalendarEventResponse401 = {
  data: void;
  status: 401;
};

export type deleteCalendarEventResponse403 = {
  data: CalendarMutationApiError;
  status: 403;
};

export type deleteCalendarEventResponse404 = {
  data: CalendarMutationApiError;
  status: 404;
};

export type deleteCalendarEventResponse409 = {
  data: CalendarMutationApiError;
  status: 409;
};

export type deleteCalendarEventResponse503 = {
  data: CalendarMutationApiError;
  status: 503;
};

export type deleteCalendarEventResponseSuccess =
  deleteCalendarEventResponse204 & {
    headers: Headers;
  };
export type deleteCalendarEventResponseError = (
  | deleteCalendarEventResponse401
  | deleteCalendarEventResponse403
  | deleteCalendarEventResponse404
  | deleteCalendarEventResponse409
  | deleteCalendarEventResponse503
) & {
  headers: Headers;
};

export type deleteCalendarEventResponse =
  | deleteCalendarEventResponseSuccess
  | deleteCalendarEventResponseError;

export const getDeleteCalendarEventUrl = (
  eventId: string,
  params?: DeleteCalendarEventParams
) => {
  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
    ? `/events/${eventId}?${stringifiedParams}`
    : `/events/${eventId}`;
};

export const deleteCalendarEvent = async (
  eventId: string,
  params?: DeleteCalendarEventParams,
  options?: RequestInit
): Promise<deleteCalendarEventResponse> => {
  const res = await fetch(getDeleteCalendarEventUrl(eventId, params), {
    ...options,
    method: 'DELETE',
  });

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

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

/**
 * @summary Update fields of a calendar event and return its synced entity.
 */
export type updateCalendarEventResponse200 = {
  data: CalendarEvent;
  status: 200;
};

export type updateCalendarEventResponse400 = {
  data: CalendarMutationApiError;
  status: 400;
};

export type updateCalendarEventResponse401 = {
  data: void;
  status: 401;
};

export type updateCalendarEventResponse403 = {
  data: CalendarMutationApiError;
  status: 403;
};

export type updateCalendarEventResponse404 = {
  data: CalendarMutationApiError;
  status: 404;
};

export type updateCalendarEventResponse409 = {
  data: CalendarMutationApiError;
  status: 409;
};

export type updateCalendarEventResponse503 = {
  data: CalendarMutationApiError;
  status: 503;
};

export type updateCalendarEventResponseSuccess =
  updateCalendarEventResponse200 & {
    headers: Headers;
  };
export type updateCalendarEventResponseError = (
  | updateCalendarEventResponse400
  | updateCalendarEventResponse401
  | updateCalendarEventResponse403
  | updateCalendarEventResponse404
  | updateCalendarEventResponse409
  | updateCalendarEventResponse503
) & {
  headers: Headers;
};

export type updateCalendarEventResponse =
  | updateCalendarEventResponseSuccess
  | updateCalendarEventResponseError;

export const getUpdateCalendarEventUrl = (eventId: string) => {
  return `/events/${eventId}`;
};

export const updateCalendarEvent = async (
  eventId: string,
  updateCalendarEventRequest: UpdateCalendarEventRequest,
  options?: RequestInit
): Promise<updateCalendarEventResponse> => {
  const res = await fetch(getUpdateCalendarEventUrl(eventId), {
    ...options,
    method: 'PATCH',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(updateCalendarEventRequest),
  });

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

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

/**
 * @summary Add a snapshot of an event shared with one of the requester's channels to
one of their Google calendars and return the synced snapshot. The
snapshot keeps the meeting's iCalendar UID and organizer, lists only the
requester as a guest, and carries no join link; nobody is notified.
While the requester's request to join the event is pending or accepted,
the copy is refused with `join_request_open`: the meeting reaches their
calendar as the invitation, which a copy would otherwise take in.
 */
export type copyCalendarEventResponse201 = {
  data: CalendarEvent;
  status: 201;
};

export type copyCalendarEventResponse400 = {
  data: CalendarMutationApiError;
  status: 400;
};

export type copyCalendarEventResponse401 = {
  data: void;
  status: 401;
};

export type copyCalendarEventResponse403 = {
  data: CalendarMutationApiError;
  status: 403;
};

export type copyCalendarEventResponse404 = {
  data: CalendarMutationApiError;
  status: 404;
};

export type copyCalendarEventResponse409 = {
  data: CalendarMutationApiError;
  status: 409;
};

export type copyCalendarEventResponse503 = {
  data: CalendarMutationApiError;
  status: 503;
};

export type copyCalendarEventResponseSuccess = copyCalendarEventResponse201 & {
  headers: Headers;
};
export type copyCalendarEventResponseError = (
  | copyCalendarEventResponse400
  | copyCalendarEventResponse401
  | copyCalendarEventResponse403
  | copyCalendarEventResponse404
  | copyCalendarEventResponse409
  | copyCalendarEventResponse503
) & {
  headers: Headers;
};

export type copyCalendarEventResponse =
  | copyCalendarEventResponseSuccess
  | copyCalendarEventResponseError;

export const getCopyCalendarEventUrl = (eventId: string) => {
  return `/events/${eventId}/copy`;
};

export const copyCalendarEvent = async (
  eventId: string,
  copyCalendarEventRequest: CopyCalendarEventRequest,
  options?: RequestInit
): Promise<copyCalendarEventResponse> => {
  const res = await fetch(getCopyCalendarEventUrl(eventId), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(copyCalendarEventRequest),
  });

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

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

/**
 * @summary Add guests to a calendar event without touching anyone already invited,
and return its synced entity. The organizer, and guests the organizer lets
invite others, may call it; Google emails the new guests.
 */
export type inviteCalendarEventGuestsResponse200 = {
  data: CalendarEvent;
  status: 200;
};

export type inviteCalendarEventGuestsResponse400 = {
  data: CalendarMutationApiError;
  status: 400;
};

export type inviteCalendarEventGuestsResponse401 = {
  data: void;
  status: 401;
};

export type inviteCalendarEventGuestsResponse403 = {
  data: CalendarMutationApiError;
  status: 403;
};

export type inviteCalendarEventGuestsResponse404 = {
  data: CalendarMutationApiError;
  status: 404;
};

export type inviteCalendarEventGuestsResponse409 = {
  data: CalendarMutationApiError;
  status: 409;
};

export type inviteCalendarEventGuestsResponse503 = {
  data: CalendarMutationApiError;
  status: 503;
};

export type inviteCalendarEventGuestsResponseSuccess =
  inviteCalendarEventGuestsResponse200 & {
    headers: Headers;
  };
export type inviteCalendarEventGuestsResponseError = (
  | inviteCalendarEventGuestsResponse400
  | inviteCalendarEventGuestsResponse401
  | inviteCalendarEventGuestsResponse403
  | inviteCalendarEventGuestsResponse404
  | inviteCalendarEventGuestsResponse409
  | inviteCalendarEventGuestsResponse503
) & {
  headers: Headers;
};

export type inviteCalendarEventGuestsResponse =
  | inviteCalendarEventGuestsResponseSuccess
  | inviteCalendarEventGuestsResponseError;

export const getInviteCalendarEventGuestsUrl = (eventId: string) => {
  return `/events/${eventId}/guests`;
};

export const inviteCalendarEventGuests = async (
  eventId: string,
  inviteCalendarEventGuestsRequest: InviteCalendarEventGuestsRequest,
  options?: RequestInit
): Promise<inviteCalendarEventGuestsResponse> => {
  const res = await fetch(getInviteCalendarEventGuestsUrl(eventId), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(inviteCalendarEventGuestsRequest),
  });

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

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

/**
 * @summary Resolve an authorized event's provider link for Outlook-only actions.
 */
export type calendarEventProviderUrlResponse200 = {
  data: CalendarEventProviderUrl;
  status: 200;
};

export type calendarEventProviderUrlResponse404 = {
  data: CalendarMutationApiError;
  status: 404;
};

export type calendarEventProviderUrlResponseSuccess =
  calendarEventProviderUrlResponse200 & {
    headers: Headers;
  };
export type calendarEventProviderUrlResponseError =
  calendarEventProviderUrlResponse404 & {
    headers: Headers;
  };

export type calendarEventProviderUrlResponse =
  | calendarEventProviderUrlResponseSuccess
  | calendarEventProviderUrlResponseError;

export const getCalendarEventProviderUrlUrl = (
  eventId: string,
  params?: CalendarEventProviderUrlParams
) => {
  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
    ? `/events/${eventId}/provider-url?${stringifiedParams}`
    : `/events/${eventId}/provider-url`;
};

export const calendarEventProviderUrl = async (
  eventId: string,
  params?: CalendarEventProviderUrlParams,
  options?: RequestInit
): Promise<calendarEventProviderUrlResponse> => {
  const res = await fetch(getCalendarEventProviderUrlUrl(eventId, params), {
    ...options,
    method: 'GET',
  });

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

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

/**
 * @summary Read and persist an organizer-only preview, without sending invitations.
 */
export type prepareCalendarReplacementResponse200 = {
  data: CalendarReplacementView;
  status: 200;
};

export type prepareCalendarReplacementResponse409 = {
  data: CalendarMutationApiError;
  status: 409;
};

export type prepareCalendarReplacementResponseSuccess =
  prepareCalendarReplacementResponse200 & {
    headers: Headers;
  };
export type prepareCalendarReplacementResponseError =
  prepareCalendarReplacementResponse409 & {
    headers: Headers;
  };

export type prepareCalendarReplacementResponse =
  | prepareCalendarReplacementResponseSuccess
  | prepareCalendarReplacementResponseError;

export const getPrepareCalendarReplacementUrl = (eventId: string) => {
  return `/events/${eventId}/replacement`;
};

export const prepareCalendarReplacement = async (
  eventId: string,
  prepareCalendarReplacementRequest: PrepareCalendarReplacementRequest,
  options?: RequestInit
): Promise<prepareCalendarReplacementResponse> => {
  const res = await fetch(getPrepareCalendarReplacementUrl(eventId), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(prepareCalendarReplacementRequest),
  });

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

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

/**
 * @summary Set the requester's RSVP on a calendar event and return its synced entity.
 */
export type rsvpCalendarEventResponse200 = {
  data: CalendarEvent;
  status: 200;
};

export type rsvpCalendarEventResponse401 = {
  data: void;
  status: 401;
};

export type rsvpCalendarEventResponse403 = {
  data: CalendarMutationApiError;
  status: 403;
};

export type rsvpCalendarEventResponse404 = {
  data: CalendarMutationApiError;
  status: 404;
};

export type rsvpCalendarEventResponse409 = {
  data: CalendarMutationApiError;
  status: 409;
};

export type rsvpCalendarEventResponse503 = {
  data: CalendarMutationApiError;
  status: 503;
};

export type rsvpCalendarEventResponseSuccess = rsvpCalendarEventResponse200 & {
  headers: Headers;
};
export type rsvpCalendarEventResponseError = (
  | rsvpCalendarEventResponse401
  | rsvpCalendarEventResponse403
  | rsvpCalendarEventResponse404
  | rsvpCalendarEventResponse409
  | rsvpCalendarEventResponse503
) & {
  headers: Headers;
};

export type rsvpCalendarEventResponse =
  | rsvpCalendarEventResponseSuccess
  | rsvpCalendarEventResponseError;

export const getRsvpCalendarEventUrl = (eventId: string) => {
  return `/events/${eventId}/rsvp`;
};

export const rsvpCalendarEvent = async (
  eventId: string,
  rsvpCalendarEventRequest: RsvpCalendarEventRequest,
  options?: RequestInit
): Promise<rsvpCalendarEventResponse> => {
  const res = await fetch(getRsvpCalendarEventUrl(eventId), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(rsvpCalendarEventRequest),
  });

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

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

/**
 * @summary Health check
 */
export type healthHandlerResponse200 = {
  data: string;
  status: 200;
};

export type healthHandlerResponseSuccess = healthHandlerResponse200 & {
  headers: Headers;
};

export type healthHandlerResponse = healthHandlerResponseSuccess;

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

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

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

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

/**
 * @summary Answer a request to join an event the requester can change and return
where it now stands. Accepting adds the guest through the invite path; an
already answered request is returned unchanged.
 */
export type respondToJoinRequestResponse200 = {
  data: CalendarJoinRequest;
  status: 200;
};

export type respondToJoinRequestResponse401 = {
  data: void;
  status: 401;
};

export type respondToJoinRequestResponse403 = {
  data: CalendarMutationApiError;
  status: 403;
};

export type respondToJoinRequestResponse404 = {
  data: CalendarMutationApiError;
  status: 404;
};

export type respondToJoinRequestResponse409 = {
  data: CalendarMutationApiError;
  status: 409;
};

export type respondToJoinRequestResponse503 = {
  data: CalendarMutationApiError;
  status: 503;
};

export type respondToJoinRequestResponseSuccess =
  respondToJoinRequestResponse200 & {
    headers: Headers;
  };
export type respondToJoinRequestResponseError = (
  | respondToJoinRequestResponse401
  | respondToJoinRequestResponse403
  | respondToJoinRequestResponse404
  | respondToJoinRequestResponse409
  | respondToJoinRequestResponse503
) & {
  headers: Headers;
};

export type respondToJoinRequestResponse =
  | respondToJoinRequestResponseSuccess
  | respondToJoinRequestResponseError;

export const getRespondToJoinRequestUrl = (requestId: string) => {
  return `/join-requests/${requestId}`;
};

export const respondToJoinRequest = async (
  requestId: string,
  respondToJoinRequestRequest: RespondToJoinRequestRequest,
  options?: RequestInit
): Promise<respondToJoinRequestResponse> => {
  const res = await fetch(getRespondToJoinRequestUrl(requestId), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(respondToJoinRequestRequest),
  });

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

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

/**
 * @summary Read saved progress without performing a provider mutation.
 */
export type calendarReplacementStatusResponse200 = {
  data: CalendarReplacementView;
  status: 200;
};

export type calendarReplacementStatusResponse404 = {
  data: CalendarMutationApiError;
  status: 404;
};

export type calendarReplacementStatusResponseSuccess =
  calendarReplacementStatusResponse200 & {
    headers: Headers;
  };
export type calendarReplacementStatusResponseError =
  calendarReplacementStatusResponse404 & {
    headers: Headers;
  };

export type calendarReplacementStatusResponse =
  | calendarReplacementStatusResponseSuccess
  | calendarReplacementStatusResponseError;

export const getCalendarReplacementStatusUrl = (operationId: string) => {
  return `/replacements/${operationId}`;
};

export const calendarReplacementStatus = async (
  operationId: string,
  options?: RequestInit
): Promise<calendarReplacementStatusResponse> => {
  const res = await fetch(getCalendarReplacementStatusUrl(operationId), {
    ...options,
    method: 'GET',
  });

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

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

/**
 * @summary Discard a preview only if no confirmation has been recorded.
 */
export type discardCalendarReplacementResponse204 = {
  data: void;
  status: 204;
};

export type discardCalendarReplacementResponse409 = {
  data: CalendarMutationApiError;
  status: 409;
};

export type discardCalendarReplacementResponseSuccess =
  discardCalendarReplacementResponse204 & {
    headers: Headers;
  };
export type discardCalendarReplacementResponseError =
  discardCalendarReplacementResponse409 & {
    headers: Headers;
  };

export type discardCalendarReplacementResponse =
  | discardCalendarReplacementResponseSuccess
  | discardCalendarReplacementResponseError;

export const getDiscardCalendarReplacementUrl = (operationId: string) => {
  return `/replacements/${operationId}`;
};

export const discardCalendarReplacement = async (
  operationId: string,
  options?: RequestInit
): Promise<discardCalendarReplacementResponse> => {
  const res = await fetch(getDiscardCalendarReplacementUrl(operationId), {
    ...options,
    method: 'DELETE',
  });

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

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

/**
 * @summary Explicitly confirm the saved preview, or resume the same confirmed operation.
 */
export type confirmCalendarReplacementResponse200 = {
  data: CalendarReplacementView;
  status: 200;
};

export type confirmCalendarReplacementResponse409 = {
  data: CalendarMutationApiError;
  status: 409;
};

export type confirmCalendarReplacementResponseSuccess =
  confirmCalendarReplacementResponse200 & {
    headers: Headers;
  };
export type confirmCalendarReplacementResponseError =
  confirmCalendarReplacementResponse409 & {
    headers: Headers;
  };

export type confirmCalendarReplacementResponse =
  | confirmCalendarReplacementResponseSuccess
  | confirmCalendarReplacementResponseError;

export const getConfirmCalendarReplacementUrl = (operationId: string) => {
  return `/replacements/${operationId}/confirm`;
};

export const confirmCalendarReplacement = async (
  operationId: string,
  options?: RequestInit
): Promise<confirmCalendarReplacementResponse> => {
  const res = await fetch(getConfirmCalendarReplacementUrl(operationId), {
    ...options,
    method: 'POST',
  });

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

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

/**
 * @summary List the profile's bookings, optionally those starting in a half-open range.
 */
export type listBookingsResponse200 = {
  data: BookingsResponse;
  status: 200;
};

export type listBookingsResponse400 = {
  data: void;
  status: 400;
};

export type listBookingsResponse403 = {
  data: void;
  status: 403;
};

export type listBookingsResponseSuccess = listBookingsResponse200 & {
  headers: Headers;
};
export type listBookingsResponseError = (
  | listBookingsResponse400
  | listBookingsResponse403
) & {
  headers: Headers;
};

export type listBookingsResponse =
  | listBookingsResponseSuccess
  | listBookingsResponseError;

export const getListBookingsUrl = (params?: ListBookingsParams) => {
  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
    ? `/scheduling/bookings?${stringifiedParams}`
    : `/scheduling/bookings`;
};

export const listBookings = async (
  params?: ListBookingsParams,
  options?: RequestInit
): Promise<listBookingsResponse> => {
  const res = await fetch(getListBookingsUrl(params), {
    ...options,
    method: 'GET',
  });

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

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

/**
 * @summary Approve, cancel, record attendance for, or reschedule one booking.
 */
export type changeBookingResponse200 = {
  data: BookingResponse;
  status: 200;
};

export type changeBookingResponse400 = {
  data: void;
  status: 400;
};

export type changeBookingResponse403 = {
  data: void;
  status: 403;
};

export type changeBookingResponse404 = {
  data: void;
  status: 404;
};

export type changeBookingResponse409 = {
  data: void;
  status: 409;
};

export type changeBookingResponseSuccess = changeBookingResponse200 & {
  headers: Headers;
};
export type changeBookingResponseError = (
  | changeBookingResponse400
  | changeBookingResponse403
  | changeBookingResponse404
  | changeBookingResponse409
) & {
  headers: Headers;
};

export type changeBookingResponse =
  | changeBookingResponseSuccess
  | changeBookingResponseError;

export const getChangeBookingUrl = (id: string) => {
  return `/scheduling/bookings/${id}/change`;
};

export const changeBooking = async (
  id: string,
  bookingChange: BookingChange,
  options?: RequestInit
): Promise<changeBookingResponse> => {
  const res = await fetch(getChangeBookingUrl(id), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(bookingChange),
  });

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

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

/**
 * @summary Read one booking as its personal owner, a host, or a team administrator.
 */
export type getManagedBookingResponse200 = {
  data: ReceiptResponse;
  status: 200;
};

export type getManagedBookingResponse403 = {
  data: void;
  status: 403;
};

export type getManagedBookingResponse404 = {
  data: void;
  status: 404;
};

export type getManagedBookingResponseSuccess = getManagedBookingResponse200 & {
  headers: Headers;
};
export type getManagedBookingResponseError = (
  | getManagedBookingResponse403
  | getManagedBookingResponse404
) & {
  headers: Headers;
};

export type getManagedBookingResponse =
  | getManagedBookingResponseSuccess
  | getManagedBookingResponseError;

export const getGetManagedBookingUrl = (id: string) => {
  return `/scheduling/bookings/${id}/manage`;
};

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

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

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

/**
 * @summary Replacement start times for one booking on a schedule-local date.
 */
export type listBookingRescheduleSlotsResponse200 = {
  data: SlotsResponse;
  status: 200;
};

export type listBookingRescheduleSlotsResponse403 = {
  data: void;
  status: 403;
};

export type listBookingRescheduleSlotsResponse404 = {
  data: void;
  status: 404;
};

export type listBookingRescheduleSlotsResponseSuccess =
  listBookingRescheduleSlotsResponse200 & {
    headers: Headers;
  };
export type listBookingRescheduleSlotsResponseError = (
  | listBookingRescheduleSlotsResponse403
  | listBookingRescheduleSlotsResponse404
) & {
  headers: Headers;
};

export type listBookingRescheduleSlotsResponse =
  | listBookingRescheduleSlotsResponseSuccess
  | listBookingRescheduleSlotsResponseError;

export const getListBookingRescheduleSlotsUrl = (
  id: string,
  params: ListBookingRescheduleSlotsParams
) => {
  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
    ? `/scheduling/bookings/${id}/slots?${stringifiedParams}`
    : `/scheduling/bookings/${id}/slots`;
};

export const listBookingRescheduleSlots = async (
  id: string,
  params: ListBookingRescheduleSlotsParams,
  options?: RequestInit
): Promise<listBookingRescheduleSlotsResponse> => {
  const res = await fetch(getListBookingRescheduleSlotsUrl(id, params), {
    ...options,
    method: 'GET',
  });

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

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

/**
 * @summary Booking statistics for a local date range and the equally long period before it.
 */
export type getBookingInsightsResponse200 = {
  data: BookingInsights;
  status: 200;
};

export type getBookingInsightsResponse400 = {
  data: void;
  status: 400;
};

export type getBookingInsightsResponse403 = {
  data: void;
  status: 403;
};

export type getBookingInsightsResponseSuccess =
  getBookingInsightsResponse200 & {
    headers: Headers;
  };
export type getBookingInsightsResponseError = (
  | getBookingInsightsResponse400
  | getBookingInsightsResponse403
) & {
  headers: Headers;
};

export type getBookingInsightsResponse =
  | getBookingInsightsResponseSuccess
  | getBookingInsightsResponseError;

export const getGetBookingInsightsUrl = (params?: GetBookingInsightsParams) => {
  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
    ? `/scheduling/insights?${stringifiedParams}`
    : `/scheduling/insights`;
};

export const getBookingInsights = async (
  insightQuery: InsightQuery,
  params?: GetBookingInsightsParams,
  options?: RequestInit
): Promise<getBookingInsightsResponse> => {
  const res = await fetch(getGetBookingInsightsUrl(params), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(insightQuery),
  });

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

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

/**
 * @summary List and search booking links with their full drafts and reusable schedules.
 */
export type listBookingLinksResponse200 = {
  data: BookingLinkListing;
  status: 200;
};

export type listBookingLinksResponse403 = {
  data: void;
  status: 403;
};

export type listBookingLinksResponseSuccess = listBookingLinksResponse200 & {
  headers: Headers;
};
export type listBookingLinksResponseError = listBookingLinksResponse403 & {
  headers: Headers;
};

export type listBookingLinksResponse =
  | listBookingLinksResponseSuccess
  | listBookingLinksResponseError;

export const getListBookingLinksUrl = (params?: ListBookingLinksParams) => {
  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
    ? `/scheduling/links?${stringifiedParams}`
    : `/scheduling/links`;
};

export const listBookingLinks = async (
  params?: ListBookingLinksParams,
  options?: RequestInit
): Promise<listBookingLinksResponse> => {
  const res = await fetch(getListBookingLinksUrl(params), {
    ...options,
    method: 'GET',
  });

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

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

/**
 * @summary Create a booking link; an identical replay at the same slug returns the saved link.
 */
export type createBookingLinkResponse200 = {
  data: BookingLink;
  status: 200;
};

export type createBookingLinkResponse400 = {
  data: void;
  status: 400;
};

export type createBookingLinkResponse403 = {
  data: void;
  status: 403;
};

export type createBookingLinkResponse409 = {
  data: void;
  status: 409;
};

export type createBookingLinkResponseSuccess = createBookingLinkResponse200 & {
  headers: Headers;
};
export type createBookingLinkResponseError = (
  | createBookingLinkResponse400
  | createBookingLinkResponse403
  | createBookingLinkResponse409
) & {
  headers: Headers;
};

export type createBookingLinkResponse =
  | createBookingLinkResponseSuccess
  | createBookingLinkResponseError;

export const getCreateBookingLinkUrl = (params?: CreateBookingLinkParams) => {
  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
    ? `/scheduling/links?${stringifiedParams}`
    : `/scheduling/links`;
};

export const createBookingLink = async (
  createBookingLinkRequest: CreateBookingLinkRequest,
  params?: CreateBookingLinkParams,
  options?: RequestInit
): Promise<createBookingLinkResponse> => {
  const res = await fetch(getCreateBookingLinkUrl(params), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(createBookingLinkRequest),
  });

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

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

/**
 * @summary Replace one booking link's configuration at the profile revision it was read with.
 */
export type editBookingLinkResponse200 = {
  data: BookingLink;
  status: 200;
};

export type editBookingLinkResponse400 = {
  data: void;
  status: 400;
};

export type editBookingLinkResponse403 = {
  data: void;
  status: 403;
};

export type editBookingLinkResponse404 = {
  data: void;
  status: 404;
};

export type editBookingLinkResponse409 = {
  data: void;
  status: 409;
};

export type editBookingLinkResponseSuccess = editBookingLinkResponse200 & {
  headers: Headers;
};
export type editBookingLinkResponseError = (
  | editBookingLinkResponse400
  | editBookingLinkResponse403
  | editBookingLinkResponse404
  | editBookingLinkResponse409
) & {
  headers: Headers;
};

export type editBookingLinkResponse =
  | editBookingLinkResponseSuccess
  | editBookingLinkResponseError;

export const getEditBookingLinkUrl = (
  id: string,
  params?: EditBookingLinkParams
) => {
  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
    ? `/scheduling/links/${id}?${stringifiedParams}`
    : `/scheduling/links/${id}`;
};

export const editBookingLink = async (
  id: string,
  editBookingLinkRequest: EditBookingLinkRequest,
  params?: EditBookingLinkParams,
  options?: RequestInit
): Promise<editBookingLinkResponse> => {
  const res = await fetch(getEditBookingLinkUrl(id, params), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(editBookingLinkRequest),
  });

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

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

/**
 * @summary Read personal or team booking settings without creating them.
 */
export type getBookingSettingsResponse200 = {
  data: ProfileResponse;
  status: 200;
};

export type getBookingSettingsResponse403 = {
  data: void;
  status: 403;
};

export type getBookingSettingsResponse404 = {
  data: void;
  status: 404;
};

export type getBookingSettingsResponseSuccess =
  getBookingSettingsResponse200 & {
    headers: Headers;
  };
export type getBookingSettingsResponseError = (
  | getBookingSettingsResponse403
  | getBookingSettingsResponse404
) & {
  headers: Headers;
};

export type getBookingSettingsResponse =
  | getBookingSettingsResponseSuccess
  | getBookingSettingsResponseError;

export const getGetBookingSettingsUrl = (params?: GetBookingSettingsParams) => {
  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
    ? `/scheduling/settings?${stringifiedParams}`
    : `/scheduling/settings`;
};

export const getBookingSettings = async (
  params?: GetBookingSettingsParams,
  options?: RequestInit
): Promise<getBookingSettingsResponse> => {
  const res = await fetch(getGetBookingSettingsUrl(params), {
    ...options,
    method: 'GET',
  });

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

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

/**
 * @summary Save booking settings at the revision they were read with.
 */
export type saveBookingSettingsResponse200 = {
  data: ProfileResponse;
  status: 200;
};

export type saveBookingSettingsResponse400 = {
  data: void;
  status: 400;
};

export type saveBookingSettingsResponse403 = {
  data: void;
  status: 403;
};

export type saveBookingSettingsResponse409 = {
  data: void;
  status: 409;
};

export type saveBookingSettingsResponseSuccess =
  saveBookingSettingsResponse200 & {
    headers: Headers;
  };
export type saveBookingSettingsResponseError = (
  | saveBookingSettingsResponse400
  | saveBookingSettingsResponse403
  | saveBookingSettingsResponse409
) & {
  headers: Headers;
};

export type saveBookingSettingsResponse =
  | saveBookingSettingsResponseSuccess
  | saveBookingSettingsResponseError;

export const getSaveBookingSettingsUrl = (
  params?: SaveBookingSettingsParams
) => {
  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
    ? `/scheduling/settings?${stringifiedParams}`
    : `/scheduling/settings`;
};

export const saveBookingSettings = async (
  bookingProfile: BookingProfile,
  params?: SaveBookingSettingsParams,
  options?: RequestInit
): Promise<saveBookingSettingsResponse> => {
  const res = await fetch(getSaveBookingSettingsUrl(params), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(bookingProfile),
  });

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

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

/**
 * @summary Read the authenticated user's sharing choice.
 */
export type getTeamSharingResponse200 = {
  data: TeamCalendarSharingBody;
  status: 200;
};

export type getTeamSharingResponseSuccess = getTeamSharingResponse200 & {
  headers: Headers;
};

export type getTeamSharingResponse = getTeamSharingResponseSuccess;

export const getGetTeamSharingUrl = () => {
  return `/team-sharing`;
};

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

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

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

/**
 * @summary Set the authenticated user's sharing choice.
 */
export type setTeamSharingResponse200 = {
  data: TeamCalendarSharingBody;
  status: 200;
};

export type setTeamSharingResponseSuccess = setTeamSharingResponse200 & {
  headers: Headers;
};

export type setTeamSharingResponse = setTeamSharingResponseSuccess;

export const getSetTeamSharingUrl = () => {
  return `/team-sharing`;
};

export const setTeamSharing = async (
  teamCalendarSharingBody: TeamCalendarSharingBody,
  options?: RequestInit
): Promise<setTeamSharingResponse> => {
  const res = await fetch(getSetTeamSharingUrl(), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(teamCalendarSharingBody),
  });

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

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