UNPKG

tsonik

Version:

A TypeScript client library for the Iconik API based on Swagger documentation

68 lines 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CollectionResource = void 0; const base_1 = require("./base"); const utils_1 = require("../utils"); /** * Collection resource for managing collections in Iconik */ class CollectionResource extends base_1.BaseResource { constructor(client) { super(client, '/API/assets/v1/collections'); } /** * Get a list of collections */ async listCollections(params) { return super.list(params); } /** * Get a single collection by ID */ async getCollection(id) { if (!id || id.trim() === '') { throw new Error('Collection ID is required'); } return super.get(id); } /** * Create a new collection */ async createCollection(collectionData) { if (!collectionData.title || collectionData.title.trim() === '') { throw new Error('Collection title is required'); } return super.create(collectionData); } /** * Update a collection by ID */ async updateCollection(id, updateData, options) { if (!id || id.trim() === '') { throw new Error('Collection ID is required'); } const config = Object.keys((0, utils_1.cleanParams)(options)).length > 0 ? { params: (0, utils_1.cleanParams)(options) } : undefined; return this.client.patch(`${this.basePath}/${id}`, updateData, config); } /** * Replace a collection by ID (PUT operation) */ async replaceCollection(id, replaceData, options) { if (!id || id.trim() === '') { throw new Error('Collection ID is required'); } const config = Object.keys((0, utils_1.cleanParams)(options)).length > 0 ? { params: (0, utils_1.cleanParams)(options) } : undefined; return this.client.put(`${this.basePath}/${id}`, replaceData, config); } /** * Delete a collection by ID */ async deleteCollection(id) { if (!id || id.trim() === '') { throw new Error('Collection ID is required'); } return super.delete(id); } } exports.CollectionResource = CollectionResource; //# sourceMappingURL=collections.js.map