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.

2.6 KB
Raw Blame
/**
 * Generated by orval v7.21.0 🍺
 * Do not edit manually.
 * contacts
 * OpenAPI spec version: 0.1.0
 */
import type { AddContactRequest, GetContactsResponse } from './schemas';

/**
 * @summary GET /contacts handler.
 */
export type getContactsResponse200 = {
  data: GetContactsResponse;
  status: 200;
};

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

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

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

export type getContactsResponseSuccess = getContactsResponse200 & {
  headers: Headers;
};
export type getContactsResponseError = (
  | getContactsResponse401
  | getContactsResponse404
  | getContactsResponse500
) & {
  headers: Headers;
};

export type getContactsResponse =
  | getContactsResponseSuccess
  | getContactsResponseError;

export const getGetContactsUrl = () => {
  return `/contacts`;
};

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

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

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

/**
 * @summary POST /contacts handler.
 */
export type addContactResponse204 = {
  data: void;
  status: 204;
};

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

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

export type addContactResponseSuccess = addContactResponse204 & {
  headers: Headers;
};
export type addContactResponseError = (
  | addContactResponse401
  | addContactResponse500
) & {
  headers: Headers;
};

export type addContactResponse =
  | addContactResponseSuccess
  | addContactResponseError;

export const getAddContactUrl = () => {
  return `/contacts`;
};

export const addContact = async (
  addContactRequest: AddContactRequest,
  options?: RequestInit
): Promise<addContactResponse> => {
  const res = await fetch(getAddContactUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(addContactRequest),
  });

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

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