@stackend/api
Version:
JS bindings to api.stackend.com
56 lines • 1.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.edit = exports.vote = exports.getPoll = void 0;
var api_1 = require("../api");
/**
* Get a poll and the results.
*
* @param referenceId {number} Reference id. Required.
*/
function getPoll(_a) {
var referenceId = _a.referenceId;
return (0, api_1.getJson)({ url: '/poll/get', parameters: arguments });
}
exports.getPoll = getPoll;
/**
* Vote for a poll option.
*
* Requires an authorized user.
*
* @param referenceId {number} Reference id. Required.
* @param answerId {number} The answer id. Required.
*/
function vote(_a) {
var referenceId = _a.referenceId, answerId = _a.answerId;
return (0, api_1.post)({ url: '/poll/vote', parameters: arguments });
}
exports.vote = vote;
/**
* Edit/create a poll .
*
* Requires an authorized user.
*
* @param referenceId {number} Reference id. Required.
* @param startDate Start date. (optional).
* @param endDate End date. (optional).
* @param description {String} Description
* @param view {String} View (optional, default "circle")
* @param pollAnswers {Object} The answers: Map from id to description. { 1: "Yes", 2: "No", .... }
*/
function edit(_a) {
var referenceId = _a.referenceId, startDate = _a.startDate, endDate = _a.endDate, description = _a.description, view = _a.view, pollAnswers = _a.pollAnswers;
var ans = JSON.stringify(pollAnswers);
return (0, api_1.post)({
url: '/poll/edit',
parameters: {
referenceId: referenceId,
startDate: startDate,
endDate: endDate,
description: description,
view: view,
pollAnswers: ans
}
});
}
exports.edit = edit;
//# sourceMappingURL=index.js.map