tsonik
Version:
A TypeScript client library for the Iconik API based on Swagger documentation
55 lines • 1.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseResource = void 0;
const utils_1 = require("../utils");
/**
* Base class for all Iconik API resources
*/
class BaseResource {
constructor(client, basePath) {
this.client = client;
this.basePath = basePath;
}
/**
* Get a single resource by ID
*/
async get(id) {
return this.client.get(`${this.basePath}/${id}`);
}
/**
* List resources with optional query parameters
*/
// Using unknown here instead of strict Record type to allow interfaces without index signatures
async list(params) {
return this.client.get(`${this.basePath}/`, { params: (0, utils_1.cleanParams)(params) });
}
/**
* Create a new resource
*/
// Using unknown here instead of strict Record type to allow interfaces without index signatures
async create(data) {
return this.client.post(this.basePath, data);
}
/**
* Update a resource by ID
*/
// Using unknown here instead of strict Record type to allow interfaces without index signatures
async update(id, data) {
return this.client.put(`${this.basePath}/${id}`, data);
}
/**
* Partially update a resource by ID
*/
// Using unknown here instead of strict Record type to allow interfaces without index signatures
async patch(id, data) {
return this.client.patch(`${this.basePath}/${id}`, data);
}
/**
* Delete a resource by ID
*/
async delete(id) {
return this.client.delete(`${this.basePath}/${id}`);
}
}
exports.BaseResource = BaseResource;
//# sourceMappingURL=base.js.map