addsearch-js-client
Version:
AddSearch API JavaScript client
33 lines • 1.29 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.putSentimentClick = void 0;
require("es6-promise/auto");
const api_1 = require("./api");
const putSentimentClick = (apiHostname, sitekey, conversationId, sentimentValue) => {
return new Promise((resolve, reject) => {
api_1.aiAnswersInteractionsInstance
.put(`https://${apiHostname}/v2/indices/${sitekey}/conversations/${conversationId}/rating`, {
value: sentimentValue === 'positive' ? 1 : sentimentValue === 'negative' ? -1 : 0
})
.then((response) => {
if (response.status === 200) {
resolve(true);
}
else {
reject(new Error(JSON.stringify({
type: api_1.RESPONSE_SERVER_ERROR,
message: 'Unable to put sentiment click value.'
})));
}
})
.catch((error) => {
console.error(error);
reject(new Error(JSON.stringify({
type: api_1.RESPONSE_SERVER_ERROR,
message: 'Unable to put sentiment click value.'
})));
});
});
};
exports.putSentimentClick = putSentimentClick;
//# sourceMappingURL=ai-answers-interactions-api.js.map
;