@commercelayer/sdk
Version:
Commerce Layer Javascript SDK
158 lines (156 loc) • 8.41 kB
JavaScript
import { ApiResource } from './chunk-XKERR6OR.js';
// src/resources/shipments.ts
var Shipments = class _Shipments extends ApiResource {
static TYPE = "shipments";
async create(resource, params, options) {
return this.resources.create({ ...resource, type: _Shipments.TYPE }, params, options);
}
async update(resource, params, options) {
return this.resources.update({ ...resource, type: _Shipments.TYPE }, params, options);
}
async delete(id, options) {
await this.resources.delete(typeof id === "string" ? { id, type: _Shipments.TYPE } : id, options);
}
async order(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "orders" }, `shipments/${_shipmentId}/order`, params, options);
}
async shipping_category(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "shipping_categories" }, `shipments/${_shipmentId}/shipping_category`, params, options);
}
async inventory_stock_location(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "inventory_stock_locations" }, `shipments/${_shipmentId}/inventory_stock_location`, params, options);
}
async stock_location(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "stock_locations" }, `shipments/${_shipmentId}/stock_location`, params, options);
}
async origin_address(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "addresses" }, `shipments/${_shipmentId}/origin_address`, params, options);
}
async shipping_address(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "addresses" }, `shipments/${_shipmentId}/shipping_address`, params, options);
}
async shipping_method(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "shipping_methods" }, `shipments/${_shipmentId}/shipping_method`, params, options);
}
async delivery_lead_time(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "delivery_lead_times" }, `shipments/${_shipmentId}/delivery_lead_time`, params, options);
}
async pickup(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "pickups" }, `shipments/${_shipmentId}/pickup`, params, options);
}
async stock_line_items(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "stock_line_items" }, `shipments/${_shipmentId}/stock_line_items`, params, options);
}
async stock_transfers(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "stock_transfers" }, `shipments/${_shipmentId}/stock_transfers`, params, options);
}
async line_items(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "line_items" }, `shipments/${_shipmentId}/line_items`, params, options);
}
async available_shipping_methods(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "shipping_methods" }, `shipments/${_shipmentId}/available_shipping_methods`, params, options);
}
async carrier_accounts(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "carrier_accounts" }, `shipments/${_shipmentId}/carrier_accounts`, params, options);
}
async parcels(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "parcels" }, `shipments/${_shipmentId}/parcels`, params, options);
}
async attachments(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "attachments" }, `shipments/${_shipmentId}/attachments`, params, options);
}
async events(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "events" }, `shipments/${_shipmentId}/events`, params, options);
}
async tags(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "tags" }, `shipments/${_shipmentId}/tags`, params, options);
}
async versions(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "versions" }, `shipments/${_shipmentId}/versions`, params, options);
}
async event_stores(shipmentId, params, options) {
const _shipmentId = shipmentId.id || shipmentId;
return this.resources.fetch({ type: "event_stores" }, `shipments/${_shipmentId}/event_stores`, params, options);
}
async _upcoming(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _upcoming: true }, params, options);
}
async _cancel(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _cancel: true }, params, options);
}
async _on_hold(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _on_hold: true }, params, options);
}
async _picking(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _picking: true }, params, options);
}
async _packing(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _packing: true }, params, options);
}
async _ready_to_ship(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _ready_to_ship: true }, params, options);
}
async _ship(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _ship: true }, params, options);
}
async _deliver(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _deliver: true }, params, options);
}
async _reserve_stock(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _reserve_stock: true }, params, options);
}
async _release_stock(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _release_stock: true }, params, options);
}
async _decrement_stock(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _decrement_stock: true }, params, options);
}
async _get_rates(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _get_rates: true }, params, options);
}
async _purchase(id, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _purchase: true }, params, options);
}
async _add_tags(id, triggerValue, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _add_tags: triggerValue }, params, options);
}
async _remove_tags(id, triggerValue, params, options) {
return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Shipments.TYPE, _remove_tags: triggerValue }, params, options);
}
isShipment(resource) {
return resource.type && resource.type === _Shipments.TYPE;
}
relationship(id) {
return super.relationshipOneToOne(id);
}
relationshipToMany(...ids) {
return super.relationshipOneToMany(...ids);
}
type() {
return _Shipments.TYPE;
}
};
var instance = new Shipments();
var shipments_default = instance;
export { shipments_default };
//# sourceMappingURL=chunk-ZZ5BND4W.js.map
//# sourceMappingURL=chunk-ZZ5BND4W.js.map