1.0.2 • Published 4 years ago

recommendation-library v1.0.2

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

recommendation-library

To get product recommendations

NPM JavaScript Style Guide

Install

npm install --save recommendation-library

Usage

const recommendations = require('recommendation-library');

const queryBody = {
tenant: 'tenant',
lob: 'lob',
countries:'country_code',
channels:'channels',
components: 'components',
customer_id:'customer_id',
item_id:'item_id',
event_name:'event_name'
};

const tokenBody = {
    tokenAvailable: 'TRUE/FALSE',
    CLIENT_ID: 'CLIENT_ID',
    CLIENT_SECRET: 'CLIENT_SECRET',
    token: 'TOKEN_HERE_IF_AVAILABLE'
};

async function getRecommendations(){
    let response = await recommendations.getRecommendations(queryBody, tokenBody);
    console.log("recommendation response:: " + JSON.stringify(response));
}

const metricBody = {
    token: 'YOUR_TOKEN_HERE',
    tenant: 'TENANT_HERE',
    recommendation_id: 'RECOMMENDATION_ID',
    action: 'ACTION_HERE'
}

async function updateMetric(){
    let response = await recommendations.updateMetric(metricBody);
    console.log("updateMetric response:: " + JSON.stringify(response));
}
getRecommendations();
updateMetric();

The token generated and the tenant will be stored in sessionStorage after the first call with following keys: 'prToken': 'AUTHENTICATION_TOKEN' 'prTenant': 'TENANT'

License

MIT © ramiBoss