tm-service-carts
v1.1.2
Published
Carts service SDK
Downloads
5
Maintainers
Readme
Documentation
CartsService
Extends TMMicroServiceAPI
Carts Micro Service API SDK
Parameters
props
...anyurl
string service urltoken
(string | null) user access tocken if available (optional, defaultnull
)
messages
Object with class service messages
constructor
Constructor of instance
Parameters
Examples
(async () => {
const cartsService = new CartsService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
})();
Returns object service SDK object
addNewCart
Add new cart
Parameters
currency
string (required) Currency code iso3attributes
object List of predefined attributes to be stored with cart
Examples
(async () => {
const cartsService = new CartsService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
const cart = await cartsService.addNewCart('USD', { affiliate: 'colorlib' });
})();
Returns object object with new cart properties
cloneCart
Clone cart
Parameters
id
string (required) cart id for cone
Examples
(async () => {
const cartsService = new CartsService('https://jsonplaceholder.typicode.com/', 'hfkjasdhfljkadhflkajdshflkadjhald');
const cart = await cartsService.cloneCart(111);
})();
Returns object object with new cart properties
getCartById
Get cart by id
Parameters
id
string (required) Cart id
Examples
(async () => {
const cartsService = new CartsService('https://jsonplaceholder.typicode.com/');
const cart = await cartsService.getCartById(111);
})();
Returns object object with cart properties
getCartCalculatedById
Get cart calculated by id
Parameters
id
string (required) Cart id
Examples
(async () => {
const cartsService = new CartsService('https://jsonplaceholder.typicode.com/');
const cart = await cartsService.getCartCalculatedById(111);
})();
Returns object object with cart properties
getMyCartById
Get my cart by id
Parameters
id
string (required) Cart id
Examples
(async () => {
const cartsService = new CartsService('https://jsonplaceholder.typicode.com/');
const cart = await cartsService.getMyCartById(111);
})();
Returns object object with cart properties
getMyCarts
Get my carts
Examples
(async () => {
const cartsService = new CartsService('https://jsonplaceholder.typicode.com/');
const cart = await cartsService.getMyCarts();
})();
Returns array array with objects cart properties
linkItemToCart
Link item to cart
Parameters
productServiceLink
string (required) link to product in service productscartId
string (required) cart iditemType
string (required) type of product (products | services | promocodes | link-discounts)data
object (required) params for link product to cart
Examples
(async () => {
const cartsService = new CartsService('https://jsonplaceholder.typicode.com/');
const cart = await cartsService.linkItemToCart('http://service-products.dev/api/v1/products/en/55555', 111, 'products', {
price_variant: 'regular',
});
})();
Returns object object cart properties
linkItemToItem
Link item to item
Parameters
productServiceLink
string (required) link to product in service productscartId
string (required) cart iditemId
number (required) item iddata
object (required) params for link product to cart
Examples
(async () => {
const cartsService = new CartsService('https://jsonplaceholder.typicode.com/');
const cart = await cartsService.linkItemToItem('http://service-services.dev/api/v1/services/en/1', 111, 222, {
channel: 'tm-cart'
});
})();
Returns object object cart properties
mergeCarts
Merge carts
Parameters
Examples
(async () => {
const cartsService = new CartsService('https://jsonplaceholder.typicode.com/', 'dsugsahfdkljhafljkdfhajkldshfad');
const cart = await cartsService.mergeCarts(111, 333);
})();
Returns object object with new cart properties
unLinkItemFromCart
Unlink item from cart
Parameters
productServiceLink
string (required) link to product in service productscartId
string (required) cart iditemType
string (required) type of product (products | services | promocodes | link-discounts)
Examples
(async () => {
const cartsService = new CartsService('https://jsonplaceholder.typicode.com/');
const cart = await cartsService.unLinkItemFromCart('http://service-products.dev/api/v1/products/en/55555', 111, 'products');
})();
Returns object object cart properties
unLinkItemFromItem
Unlink item from item
Parameters
productServiceLink
string (required) link to product in service productscartId
string (required) cart iditemTypeTarget
string (required) item type targetitemId
number (required) item iditemTypeSource
string (required) item type source
Examples
(async () => {
const cartsService = new CartsService('https://jsonplaceholder.typicode.com/');
const cart = await cartsService.unLinkItemFromItem('http://service-services.dev/api/v1/services/en/1', 111, 'services', 222, 'services');
})();
Returns object object cart properties
updateCart
update cart
Parameters
id
string (required) cart id for conecurrecy
string currency for shopping cart (iso3)attributes
object list of predefined attributes to be stored with cart
Returns object object with new cart properties