setRules - Examples
In the following, an example call and the according return values using the setRules method of a DanubeClient instance are shown.You can also download and try a set of working demo examples for each danube.ai service using the SDK here:
https://gitlab.com/danube.ai/sdkconst { DanubeClient } = require('danube-sdk');
// Initialize a DanubeClient with your API key.
const danubeClient = new DanubeClient(
'my-api-key',
);
async function runTest() {
const rulesId = 'my-sdk-test-rule-set'; // Define a name for your rule-set.
const override = true; // Define if your rule-set will override a rule-set with the same id, if it already exists.
// Specify example rules.
const rules = [
{
property: 'salaryFrom',
type: 'PERCENTAGE',
},
{
property: 'salaryTo',
type: 'PERCENTAGE',
},
{
property: 'daysAgo',
type: 'INVERSE_PERCENTAGE',
},
{
property: 'companyType',
type: 'EQUALS',
equalityScores: [
{
value: 'Startup',
score: 1,
},
{
value: 'Digital agency',
score: 2,
},
{
value: 'Established company',
score: 3,
},
],
},
{
property: 'jobLevel',
type: 'EQUALS',
equalityScores: [
{
value: 'Junior',
score: 1,
},
{
value: 'Experienced',
score: 2,
},
{
value: 'Senior',
score: 3,
},
{
value: 'Lead',
score: 4,
},
],
},
{
property: 'timeDistance',
type: 'INVERSE_PERCENTAGE',
},
{
property: 'technologies',
type: 'OVERLAP_GLOBAL',
},
{
property: 'benefits',
type: 'OVERLAP_LOCAL',
},
];
// Save your rule-set.
const setRulesSuccess = await danubeClient.setRules(
rulesId,
override,
rules,
);
}
runTest();
// Check if rules have been saved successfully.
console.log('Rules successfully saved:', setRulesSuccess);
/*
Rules successfully saved: true
*/