UNPKG

recommendation-library

Version:

This will provide the recommendation when provided with tenant and country with other info

65 lines (49 loc) 1.66 kB
# recommendation-library > To get product recommendations [![NPM](https://img.shields.io/npm/v/recommendation-library.svg)](https://www.npmjs.com/package/recommendation-library) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) ## Install ```bash npm install --save recommendation-library ``` ## Usage ```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' ## License MIT © [ramiBoss](https://github.com/ramiBoss) #