0.3.4 • Published 5 years ago

@linx-impulse/engage-wishlist-sdk-js v0.3.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

engage-wishlist-sdk-js

Wishlist SDK for Linx Impulse Wishlist API customers

Usage

Content

getAllLists

Parameters

  • options (object)
    • apiKey (string): API key unique to each store.
    • secretKey (string): Secret key unique to each store.
    • itemType (string): Type of item that can be included on the list, may be either 'product' or 'collection'.
    • userId (string): User ID

PS: options parameter and all of its properties are required.

Example

wishlist.getAllLists({
  apiKey: 'apiKeyFake',
  secretKey: 'secretKeyFake',
  itemType: 'product',
  userId: 'user123456',
})
.then((res) => {
  console.log(`Lists: ${res}`);
  /* Expected output:
  Lists: [
    {
        id: "94170ed7-2569-5499-96bc-62b3c35d0533",
        name: "Favoritos",
        isDefault: true,
        created: 1547587097766
    },
    {
        id: "c65da160-890f-52bb-906d-66694ac20eb7",
        name: "new_list",
        created: 1547588890391
    }
  ]
  */
});

getList

Parameters

  • options (object)
    • apiKey (string): API key unique to each store.
    • secretKey (string): Secret key unique to each store.
    • itemType (string): Type of item that can be included on the list, may be either 'product' or 'collection'.
    • userId (string): User ID.
    • listId (string): List ID.
    • productFormat (string): Format that determines which properties each product object will have, can be one of three: 'onlyIds', 'compact', 'complete'. Defaults to 'compact'.
    • showOnlyAvailable (boolean or number): In case of a list with detailed products, show only products which are available in stock. Will be ignore if productFormat is 'onlyIds'. Can be true, false, 1 or 0. Defaults to false.

Example

wishlist.getList({
  apiKey: 'apiKeyFake',
  secretKey: 'secretKeyFake',
  itemType: 'product',
  userId: 'user123456',
  listId: 'c15ca47b-a980-5ba9-af14-ad38a6b043d6',
  productFormat: 'onlyIds',
})
  .then((res) => {
    console.log(`List: ${res}`);
    /* Expected output:
    List: {
      id: '94170ed7-2569-5499-96bc-62b3c35d0533',
      name: 'Favoritos',
      isDefault: true,
      created: 1547587097766,
      items: [
        id: '10032490428',
      ],
    },
    */
  });

getListItemCount

Parameters

  • options (object)
    • apiKey (string): API key unique to each store.
    • secretKey (string): Secret key unique to each store.
    • itemType (string): Type of item that can be included on the list, may be either 'product' or 'collection'.
    • userId (string): User ID.
    • listId (string): List ID.
    • showOnlyAvailable (boolean or number): Will count only products which are available in stock. Can be true, false, 1 or 0. Defaults to false.

Example

wishlist.getListItemCount({
  apiKey: 'apiKeyFake',
  secretKey: 'secretKeyFake',
  itemType: 'product',
  userId: 'user123456',
  listId: 'c15ca47b-a980-5ba9-af14-ad38a6b043d6',
})
.then((res) => {
  console.log(`Count: ${res}`);
  /* Expected output:
  Count: 1
  */
});

insertItemOnList

Parameters

  • options (object)
    • apiKey (string): API key unique to each store.
    • secretKey (string): Secret key unique to each store.
    • itemType (string): Type of item that can be included on the list, may be either 'product' or 'collection'.
    • userId (string): User ID.
    • listId (string): List ID.
    • itemId (string): ID of the item that will be inserted on the list.
    • skuList (array): ID of the skus (if any) that will be inserted on the list (optional).

Example

wishlist.insertItemOnList({
  apiKey: 'apiKeyFake',
  secretKey: 'secretKeyFake',
  itemType: 'product',
  userId: 'user123456',
  listId: 'c15ca47b-a980-5ba9-af14-ad38a6b043d6',
  itemId: '10032490428',
})
.then((res) => {
  console.log(`${res}`);
  /* Expected output:
  Items successfully inserted on list
  */
});

removeItemFromList

Parameters

  • options (object)
    • apiKey (string): API key unique to each store.
    • secretKey (string): Secret key unique to each store.
    • itemType (string): Type of item that can be included on the list, may be either 'product' or 'collection'.
    • userId (string): User ID.
    • listId (string): List ID.
    • itemId (string): ID of the item that will be removed from the list.

Example

wishlist.removeItemFromList({
  apiKey: 'apiKeyFake',
  secretKey: 'secretKeyFake',
  itemType: 'product',
  userId: 'user123456',
  listId: 'c15ca47b-a980-5ba9-af14-ad38a6b043d6',
  itemId: '10032490428',
})
.then((res) => {
  console.log(`${res}`);
  /* Expected output:
  Items successfully removed from list
  */
});

createList

Parameters

  • options (object)
    • apiKey (string): API key unique to each store.
    • secretKey (string): Secret key unique to each store.
    • itemType (string): Type of item that can be included on the list, may be either 'product' or 'collection'.
    • userId (string): User ID.
    • name (string): Name of the list to be created.
    • extras (object): Object containing any properties to be added to the list (optional).

Example

wishlist.createList({
  apiKey: 'apiKeyFake',
  secretKey: 'secretKeyFake',
  itemType: 'product',
  userId: 'user123456',
  name: 'My list',
})
.then((res) => {
  console.log(`My list: ${res}`);
  /* Expected output:
  My List: {
    id: '94170ed7-2569-5499-96bc-62b3c35d0533',
    name: 'My list',
    created: 1547587097766,
    items: [],
  },
  */
});

updateList

Parameters

  • options (object)
    • apiKey (string): API key unique to each store.
    • secretKey (string): Secret key unique to each store.
    • itemType (string): Type of item that can be included on the list, may be either 'product' or 'collection'.
    • userId (string): User ID.
    • listId (string): List ID.
    • name (string): The new name for the list being updated.
    • extras (object): Object containing any properties to be added to the list (optional).

Example

wishlist.updateList({
  apiKey: 'apiKeyFake',
  secretKey: 'secretKeyFake',
  itemType: 'product',
  userId: 'user123456',
  listId: 'c15ca47b-a980-5ba9-af14-ad38a6b043d6',
  name: 'Wedding list',
  extras: {
    categories: ['appliances', 'decoration'],
  },
})
.then((res) => {
  console.log(`Wedding list: ${res}`);
  /* Expected output:
  Wedding list: {
    id: 'c15ca47b-a980-5ba9-af14-ad38a6b043d6',
    name: 'Wedding list',
    created: 1547587097766,
    items: [
      {
        id: '1314112124',
      }
    ],
    extras: {
      categories: ['appliances', 'decoration'],
    },
  },
  */
});

deleteList

Parameters

  • options (object)
    • apiKey (string): API key unique to each store.
    • secretKey (string): Secret key unique to each store.
    • itemType (string): Type of item that can be included on the list, may be either 'product' or 'collection'.
    • userId (string): User ID.
    • listId (string): List ID.

Example

wishlist.deleteList({
  apiKey: 'apiKeyFake',
  secretKey: 'secretKeyFake',
  itemType: 'product',
  userId: 'user123456',
  listId: 'c15ca47b-a980-5ba9-af14-ad38a6b043d6',
})
.then((res) => {
  console.log(res);
  /* Expected output:
  List deleted successfully
  */
});

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

PS: Do not forget the tests ;)