"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AttioClient = void 0;
const get_1 = __importDefault(require("lodash/get"));
const sortBy_1 = __importDefault(require("lodash/sortBy"));
class AttioClient {
    constructor(request) {
        this.request = request;
        this.api_url = 'https://api.attio.com';
    }
    async assertRecord({ matching_attribute, object, values, requestOptions }) {
        return await this.request(`${this.api_url}/v2/objects/${object}/records/simple?matching_attribute=${matching_attribute}&append_to_existing_values=true`, {
            method: 'put',
            json: { data: { values } },
            ...requestOptions
        });
    }
    async batchAssert({ assertions, requestOptions }) {
        return await this.request(`${this.api_url}/v2/batch/records`, {
            method: 'put',
            json: { assertions },
            ...requestOptions
        });
    }
    async listObjects() {
        const response = await this.request(`${this.api_url}/v2/objects`);
        const objects = (0, get_1.default)(response, 'data.data', []);
        return (0, sortBy_1.default)(objects, 'singular_noun');
    }
}
exports.AttioClient = AttioClient;
//# sourceMappingURL=index.js.map