npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tm-service-carts

v1.1.2

Published

Carts service SDK

Downloads

5

Readme

Documentation

CartsService

Extends TMMicroServiceAPI

Carts Micro Service API SDK

Parameters

  • props ...any
  • url string service url
  • token (string | null) user access tocken if available (optional, default null)

messages

Object with class service messages

constructor

Constructor of instance

Parameters

  • props ...any
  • url string (required) url to service
  • token string user token

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 iso3
  • attributes object List of predefined attributes to be stored with cart
    • attributes.affiliate string Affiliate name
    • attributes.trackers object Analytics trackers
    • attributes.trackers string [ga] - Google Analytics tracker
    • attributes.trackers string [ad] - Google Adwords tracker
    • attributes.trackers string [sc] - Soft Cube tracker

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

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

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

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 products
  • cartId string (required) cart id
  • itemType string (required) type of product (products | services | promocodes | link-discounts)
  • data object (required) params for link product to cart
    • data.price_variant string price variant for products (required if itemType is products)
    • data.channel string channel for service (required if itemType is services)
    • data.position number position for service
    • data.presentation_id string presentation id for service

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 products
  • cartId string (required) cart id
  • itemId number (required) item id
  • data object (required) params for link product to cart
    • data.channel string (required) channel for service
    • data.position number position for service
    • data.presentation_id string presentation id for service

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

  • targetCartId string (required) target cart id
  • sourceCartId string (required) source cart id

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 products
  • cartId string (required) cart id
  • itemType 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 products
  • cartId string (required) cart id
  • itemTypeTarget string (required) item type target
  • itemId number (required) item id
  • itemTypeSource 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 cone
  • currecy string currency for shopping cart (iso3)
  • attributes object list of predefined attributes to be stored with cart
    • attributes.affiliate string Affiliate name
    • attributes.trackers object Analytics trackers
    • attributes.trackers string [ga] - Google Analytics tracker
    • attributes.trackers string [ad] - Google Adwords tracker
    • attributes.trackers string [sc] - Soft Cube tracker

Returns object object with new cart properties