Skip to content

CRM Clients Reference

Доступные клиенты

КлиентПакетОписание
NethuntClient@happ-integ/nethuntNethunt CRM
KeyCrmClient@happ-integ/keycrmKeyCRM
BitrixClient@happ-integ/bitrixBitrix24
SalesDriveClient@happ-integ/salesdriveSalesDrive

Инициализация

Из credentials (рекомендуется)

typescript
import { Creds } from "@happ-integ/creds";
import { NethuntClient } from "@happ-integ/nethunt";

const creds = new Creds({ d1: env.DB, masterKey: env.CRYPTO_KEY, salt: env.CRYPTO_SALT });
const { NETHUNT_EMAIL, NETHUNT_API_KEY } = await creds.get<NethuntCreds>("my-integration");

const nethunt = new NethuntClient(NETHUNT_EMAIL, NETHUNT_API_KEY);

Основные методы

NethuntClient

typescript
// Поиск записей
const records = await nethunt.searchRecords({ folderId: "123", limit: 10 });

// Получить запись по ID
const record = await nethunt.getRecord(recordId);

// Обновить запись
await nethunt.updateRecord(recordId, { fields: { status: "active" } });

// Создать запись
const newRecord = await nethunt.createRecord(folderId, { fields: {...} });

Lazy init паттерн

typescript
let _crm: NethuntClient | null = null;

const getCRM = async (env: CloudflareBindings) => {
	if (!_crm) {
		const creds = await getCreds(env).get<NethuntCreds>("my-integration");
		_crm = new NethuntClient(creds.NETHUNT_EMAIL, creds.NETHUNT_API_KEY);
	}
	return _crm;
};