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.

5.8 KB
Raw Blame
/**
 * Generated by orval v7.21.0 🍺
 * Do not edit manually.
 * connection_gateway
 * OpenAPI spec version: 0.1.0
 */
import type {
  BatchSendMessageBody,
  SendMessageBody,
  SendMessageResponse,
} from './schemas';

export type batchSendMessageHandlerResponse200 = {
  data: SendMessageResponse;
  status: 200;
};

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

export type batchSendMessageHandlerResponseSuccess =
  batchSendMessageHandlerResponse200 & {
    headers: Headers;
  };
export type batchSendMessageHandlerResponseError =
  batchSendMessageHandlerResponse500 & {
    headers: Headers;
  };

export type batchSendMessageHandlerResponse =
  | batchSendMessageHandlerResponseSuccess
  | batchSendMessageHandlerResponseError;

export const getBatchSendMessageHandlerUrl = () => {
  return `/batch_send`;
};

export const batchSendMessageHandler = async (
  batchSendMessageBody: BatchSendMessageBody,
  options?: RequestInit
): Promise<batchSendMessageHandlerResponse> => {
  const res = await fetch(getBatchSendMessageHandlerUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(batchSendMessageBody),
  });

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

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

/**
 * @summary Sends a message to every open connection on every instance. Delivery is
best-effort and asynchronous, so there are no receipts.
 */
export type broadcastMessageHandlerResponse202 = {
  data: void;
  status: 202;
};

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

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

export type broadcastMessageHandlerResponseSuccess =
  broadcastMessageHandlerResponse202 & {
    headers: Headers;
  };
export type broadcastMessageHandlerResponseError = (
  | broadcastMessageHandlerResponse401
  | broadcastMessageHandlerResponse500
) & {
  headers: Headers;
};

export type broadcastMessageHandlerResponse =
  | broadcastMessageHandlerResponseSuccess
  | broadcastMessageHandlerResponseError;

export const getBroadcastMessageHandlerUrl = () => {
  return `/message/broadcast`;
};

export const broadcastMessageHandler = async (
  sendMessageBody: SendMessageBody,
  options?: RequestInit
): Promise<broadcastMessageHandlerResponse> => {
  const res = await fetch(getBroadcastMessageHandlerUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(sendMessageBody),
  });

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

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

export type sendMessageHandlerResponse201 = {
  data: SendMessageResponse;
  status: 201;
};

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

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

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

export type sendMessageHandlerResponseSuccess =
  sendMessageHandlerResponse201 & {
    headers: Headers;
  };
export type sendMessageHandlerResponseError = (
  | sendMessageHandlerResponse401
  | sendMessageHandlerResponse404
  | sendMessageHandlerResponse500
) & {
  headers: Headers;
};

export type sendMessageHandlerResponse =
  | sendMessageHandlerResponseSuccess
  | sendMessageHandlerResponseError;

export const getSendMessageHandlerUrl = (
  entityType: string,
  entityId: string
) => {
  return `/message/send/${entityType}/${entityId}`;
};

export const sendMessageHandler = async (
  entityType: string,
  entityId: string,
  sendMessageBody: SendMessageBody,
  options?: RequestInit
): Promise<sendMessageHandlerResponse> => {
  const res = await fetch(getSendMessageHandlerUrl(entityType, entityId), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(sendMessageBody),
  });

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

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

export type getEntityHandlerResponse200 = {
  data: string[];
  status: 200;
};

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

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

export type getEntityHandlerResponseSuccess = getEntityHandlerResponse200 & {
  headers: Headers;
};
export type getEntityHandlerResponseError = (
  | getEntityHandlerResponse401
  | getEntityHandlerResponse500
) & {
  headers: Headers;
};

export type getEntityHandlerResponse =
  | getEntityHandlerResponseSuccess
  | getEntityHandlerResponseError;

export const getGetEntityHandlerUrl = (
  entityType: string,
  entityId: string
) => {
  return `/track/${entityType}/${entityId}`;
};

export const getEntityHandler = async (
  entityType: string,
  entityId: string,
  options?: RequestInit
): Promise<getEntityHandlerResponse> => {
  const res = await fetch(getGetEntityHandlerUrl(entityType, entityId), {
    ...options,
    method: 'GET',
  });

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

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