UNPKG

@qualifyze/airtable

Version:
52 lines 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AirtableRecordDraft = void 0; const raw_types_1 = require("./raw-types"); const record_1 = require("./record"); class AirtableRecordDraft { constructor(source, id) { this.source = source; this.id = id; } runRecordAction(method, { path, ...options }) { return this.source.runTableAction(method, { path: path ? `${this.id}/${path}` : this.id, ...options, }); } async fetch() { const { fields } = await this.runRecordAction("GET", { responseValidation: new raw_types_1.RecordDataValidation(this.source), }); return new record_1.AirtableRecord(this.source, this.id, fields); } async update(data) { const { id, fields } = await this.runRecordAction("PATCH", { responseValidation: new raw_types_1.RecordDataValidation(this.source), payload: { body: { fields: data, }, }, }); return new record_1.AirtableRecord(this.source, id, fields); } async replace(data) { const { id, fields } = await this.runRecordAction("PUT", { responseValidation: new raw_types_1.RecordDataValidation(this.source), payload: { body: { fields: data, }, }, }); return new record_1.AirtableRecord(this.source, id, fields); } destroy() { return this.runRecordAction("DELETE", { responseValidation: new raw_types_1.DeletedRecordValidation(), }); } } exports.AirtableRecordDraft = AirtableRecordDraft; //# sourceMappingURL=record-draft.js.map