recommendation-library
Version:
This will provide the recommendation when provided with tenant and country with other info
65 lines (49 loc) • 1.66 kB
Markdown
> To get product recommendations
[](https://www.npmjs.com/package/recommendation-library) [](https://standardjs.com)
```bash
npm install --save recommendation-library
```
```jsx
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'
MIT © [ramiBoss](https://github.com/ramiBoss)