sap-commerce-sdk
Version:
A TypeScript SDK for SAP Commerce Cloud storefront integration.
26 lines (25 loc) • 886 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OCCCartClient = void 0;
const config_1 = require("./config");
class OCCCartClient {
constructor() {
this.baseUrl = config_1.config.baseUrl;
this.baseSite = config_1.config.baseSite;
}
async getCart(cartId) {
const url = `${this.baseUrl}/${this.baseSite}/users/current/carts/${cartId}`;
const response = await fetch(url);
if (!response.ok)
throw new Error('Cart fetch failed');
return response.json();
}
async createCart() {
const url = `${this.baseUrl}/${this.baseSite}/users/current/carts`;
const response = await fetch(url, { method: 'POST' });
if (!response.ok)
throw new Error('Cart creation failed');
return response.json();
}
}
exports.OCCCartClient = OCCCartClient;