Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsburgermeister authored Apr 3, 2017
1 parent 12b23a2 commit 677e11e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions vote_in_poll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {

var pollId = request.pathParams.poll_id;
var pollHelper = new x_snc_polls.PollData_Creator();

// Validate if poll record exists
var pollRecord = new GlideRecord("x_snc_polls_poll");
pollRecord.get(pollId);

var voteData = request.body.data.votes;

// Record votes
pollHelper.voteInPoll(voteData, pollId);

// Set response details
response.setStatus(201);
response.setContentType("application/json");
var responseBody = '{"message":"Voting successful"}';
response.getStreamWriter().writeString(responseBody);
})(request, response);

0 comments on commit 677e11e

Please sign in to comment.