Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
// This file is auto-generated by @hey-api/openapi-ts
import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from './client';
import { client } from './client.gen';
import type { AddContactData, AddContactErrors, AddContactResponses, GetContactsData, GetContactsErrors, GetContactsResponses } from './types.gen';
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
/**
* You can provide a client instance returned by `createClient()` instead of
* individual options. This might be also useful if you want to implement a
* custom client.
*/
client?: Client;
/**
* You can pass arbitrary values through the `meta` object. This can be
* used to access values that aren't defined as part of the SDK function.
*/
meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta;
};
class HeyApiClient {
protected client: Client;
constructor(args?: {
client?: Client;
}) {
this.client = args?.client ?? client;
}
}
class HeyApiRegistry<T> {
private readonly defaultKey = 'default';
private readonly instances: Map<string, T> = new Map();
get(key?: string): T {
const instance = this.instances.get(key ?? this.defaultKey);
if (!instance) {
throw new Error(`No SDK client found. Create one with "new Sdk()" to fix this error.`);
}
return instance;
}
set(value: T, key?: string): void {
this.instances.set(key ?? this.defaultKey, value);
}
}
export class Sdk extends HeyApiClient {
public static readonly __registry: HeyApiRegistry<Sdk> = new HeyApiRegistry<Sdk>();
constructor(args?: {
client?: Client;
key?: string;
}) {
super(args);
Sdk.__registry.set(this, args?.key);
}
/**
* GET /contacts handler.
*/
public getContacts<ThrowOnError extends boolean = false>(options?: Options<GetContactsData, ThrowOnError>): RequestResult<GetContactsResponses, GetContactsErrors, ThrowOnError> {
return (options?.client ?? this.client).get<GetContactsResponses, GetContactsErrors, ThrowOnError>({ url: '/contacts', ...options });
}
/**
* POST /contacts handler.
*/
public addContact<ThrowOnError extends boolean = false>(options: Options<AddContactData, ThrowOnError>): RequestResult<AddContactResponses, AddContactErrors, ThrowOnError> {
return (options.client ?? this.client).post<AddContactResponses, AddContactErrors, ThrowOnError>({
url: '/contacts',
...options,
headers: {
'Content-Type': 'application/json',
...options.headers
}
});
}
}