UNPKG

portkey-ai

Version:
53 lines 3.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Collections = void 0; const constants_1 = require("../constants.js"); const apiResource_1 = require("../apiResource.js"); const utils_1 = require("../utils.js"); const createHeaders_1 = require("./createHeaders.js"); class Collections extends apiResource_1.ApiResource { create(_body, params, opts) { const body = _body; if (params) { const config = (0, utils_1.overrideConfig)(this.client.config, params.config); this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign(Object.assign({}, params), { config }))); } const response = this.post(`${constants_1.COLLECTIONS_API}`, Object.assign({ body }, opts)); return response; } list(_query, params, opts) { const query = _query ? (0, utils_1.toQueryParams)(_query) : ''; if (params) { const config = (0, utils_1.overrideConfig)(this.client.config, params.config); this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign(Object.assign({}, params), { config }))); } const response = this.getMethod(`${constants_1.COLLECTIONS_API}${query}`, Object.assign({}, opts)); return response; } retrieve(collectionId, params, opts) { if (params) { const config = (0, utils_1.overrideConfig)(this.client.config, params.config); this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign(Object.assign({}, params), { config }))); } const response = this.getMethod(`${constants_1.COLLECTIONS_API}/${collectionId}`, Object.assign({}, opts)); return response; } update(collectionId, body, params, opts) { if (params) { const config = (0, utils_1.overrideConfig)(this.client.config, params.config); this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign(Object.assign({}, params), { config }))); } const response = this.put(`${constants_1.COLLECTIONS_API}/${collectionId}`, Object.assign({ body }, opts)); return response; } delete(collectionId, params, opts) { if (params) { const config = (0, utils_1.overrideConfig)(this.client.config, params.config); this.client.customHeaders = Object.assign(Object.assign({}, this.client.customHeaders), (0, createHeaders_1.createHeaders)(Object.assign(Object.assign({}, params), { config }))); } const response = this.deleteMethod(`${constants_1.COLLECTIONS_API}/${collectionId}`, Object.assign({}, opts)); return response; } } exports.Collections = Collections; //# sourceMappingURL=collections.js.map