@commercelayer/sdk
Version:
Commerce Layer Javascript SDK
64 lines (62 loc) • 2.87 kB
JavaScript
import { ApiResource } from './chunk-XKERR6OR.js';
// src/resources/stock_items.ts
var StockItems = class _StockItems extends ApiResource {
static TYPE = "stock_items";
async create(resource, params, options) {
return this.resources.create({ ...resource, type: _StockItems.TYPE }, params, options);
}
async update(resource, params, options) {
return this.resources.update({ ...resource, type: _StockItems.TYPE }, params, options);
}
async delete(id, options) {
await this.resources.delete(typeof id === "string" ? { id, type: _StockItems.TYPE } : id, options);
}
async stock_location(stockItemId, params, options) {
const _stockItemId = stockItemId.id || stockItemId;
return this.resources.fetch({ type: "stock_locations" }, `stock_items/${_stockItemId}/stock_location`, params, options);
}
async sku(stockItemId, params, options) {
const _stockItemId = stockItemId.id || stockItemId;
return this.resources.fetch({ type: "skus" }, `stock_items/${_stockItemId}/sku`, params, options);
}
async reserved_stock(stockItemId, params, options) {
const _stockItemId = stockItemId.id || stockItemId;
return this.resources.fetch({ type: "reserved_stocks" }, `stock_items/${_stockItemId}/reserved_stock`, params, options);
}
async stock_reservations(stockItemId, params, options) {
const _stockItemId = stockItemId.id || stockItemId;
return this.resources.fetch({ type: "stock_reservations" }, `stock_items/${_stockItemId}/stock_reservations`, params, options);
}
async attachments(stockItemId, params, options) {
const _stockItemId = stockItemId.id || stockItemId;
return this.resources.fetch({ type: "attachments" }, `stock_items/${_stockItemId}/attachments`, params, options);
}
async versions(stockItemId, params, options) {
const _stockItemId = stockItemId.id || stockItemId;
return this.resources.fetch({ type: "versions" }, `stock_items/${_stockItemId}/versions`, params, options);
}
async event_stores(stockItemId, params, options) {
const _stockItemId = stockItemId.id || stockItemId;
return this.resources.fetch({ type: "event_stores" }, `stock_items/${_stockItemId}/event_stores`, params, options);
}
async _validate(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _StockItems.TYPE, _validate: true }, params, options);
}
isStockItem(resource) {
return resource.type && resource.type === _StockItems.TYPE;
}
relationship(id) {
return super.relationshipOneToOne(id);
}
relationshipToMany(...ids) {
return super.relationshipOneToMany(...ids);
}
type() {
return _StockItems.TYPE;
}
};
var instance = new StockItems();
var stock_items_default = instance;
export { stock_items_default };
//# sourceMappingURL=chunk-N35FM5P4.js.map
//# sourceMappingURL=chunk-N35FM5P4.js.map