forked from balazsburgermeister/ScriptedRESTAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12b23a2
commit 677e11e
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |