Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@linx-impulse/banner-client-js

chaordic42MIT1.10.2

Banner SDK for Linx Banner API customers

banner, sdk, js, linx, linx impulse

readme

banner-client-js

Version CircleCI License Downloads jsDelivr Hits

Front end Banner SDK for Linx Banner API customers

Installation

CDN

<script src="https://cdn.jsdelivr.net/npm/@linx-impulse/banner-client-js/dist/linx-banner.min.js"></script>

There will be created a property called banner in global linx object.

const LinxBanner = linx.banner;
// or
const LinxBanner = window.linx.banner;

npm

npm install --save @linx-impulse/banner-client-js

Using some module bundler like Webpack, it should be called this way:


const LinxBanner = require('@linx-impulse/banner-client-js');
// or
import { BannerClient } from '@linx-impulse/banner-client-js';

Usage

getRecommendations

Parameters

  • options (object)
    • page(string): current page. Ex: home, product, category, subcategory, cart.
    • source(string): device of user. Ex: app, desktop, mobile.
    • showLayout(boolean): whether or not bring layout properties previously set. Default: false.
    • userId(string): the user identifier, used to personalize slides even when user access a new device.
    • homologation(boolean): enable banner homologation. With this feature enabled the disabled banners will be sent on api response.
    • timeout(number): defines a timeout for request in milliseconds.
    • categories(array): list of categories of the page. This information is used by api to apply the exhibition rules for banners.
    • product(object): object containing product data. Useful for product pages.
    • tags(array): array of tags of the page.
    • url(string): url of the page.
    • testGroup(string): AB test group info.
    • searchQuery(string): query terms used if in a search page.

PS: options parameter is not required, neither any of these properties.

Example

LinxBanner.getRecommendations({
  page: 'home',
  source: 'desktop',
  showLayout: true,
  userId: 'user01',
})
  .then((banners) => {
    console.log('Banners: ', banners);
  })
  .catch((error) => {
    console.error('Banners error: ', error);
  });
LinxBanner.getRecommendations({
  page: 'product',
  source: 'mobile',
  showLayout: true,
  product: {
    id: 'prod001',
  },
  url: 'https://www.yourdomain/product/prod001'
})
  .then((banners) => {
    console.log('Banners: ', banners);
  })
  .catch((error) => {
    console.error('Banners error: ', error);
  });
LinxBanner.getRecommendations({
  page: 'subcategory',
  source: 'desktop',
  homologation: true,
  showLayout: true,
  categories: [
    { id: 'cat01', parents: null },
    { id: 'cat02', parents: [ 'cat01' ] },
  ],
  tags: [
    { id: 'tag01' },
    { id: 'tag02' },
    { id: 'tag03' },
  ],
  url: 'https://www.yourdomain/category/cat01/cat02'
})
  .then((banners) => {
    console.log('Banners: ', banners);
  })
  .catch((error) => {
    console.error('Banners error: ', error);
  });

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 ;)

Test

Run test command:

npm test

Release

  • Login npm

  • Run release command:

    npm run release

Changelog

CHANGELOG

License

MIT

changelog

Change Log

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.10.2 (2020-02-05)

1.10.1 (2019-12-06)

Bug Fixes

1.10.0 (2019-07-10)

Features

  • send search terms to banner server (09ae10a)

1.9.2 (2018-10-30)

Bug Fixes

  • formattedCategories problem with categories that have a parent with same id (dba47cc)

1.9.0 (2018-10-10)

Features

  • send ab-test information on banner request (18cdbe4)

1.8.1 (2018-08-28)

1.8.0 (2018-08-22)

Features

1.7.0 (2018-08-22)

Features

  • add support to homologation (461d15a)

1.6.0 (2018-08-20)

Features

  • add userId to getRecommendations (6c90cb5)

0.2.0 (2018-08-09)

Bug Fixes

  • rename buildParams function and create config file (12e1dba)
  • switch base url from http to a dynamic url (0f616a0)

Features

  • add get recommendations method (dbe0119)

0.1.0 (2018-06-27)

Bug Fixes

  • switch base url from http to a dynamic url (6aa449d)

Features

  • add get recommendations method (3518b4b)

0.0.1 (2018-06-12)