Let's write a function to fetch the poll details by poll ID. It's another simple query that returns the Poll object along with its result.
The heart of the function is as follows:
return if (pollRecord != null) { val poll = Poll(pollRecord.pollId, pollRecord.pollTitle, pollRecord.pollQuestion) val respondentDetails = RespondentDetails(respondentDisplayName = respondentRecord.respondentDisplayName, respondentEmail = respondentRecord.respondentEmailId) val stateOne = PollResponseStatistics("NO", 10) val stateTwo = PollResponseStatistics("YES", 90) val pollDetailsResponse = PollDetailsResponse(poll, respondentDetails, listOf(stateOne, stateTwo)) ApiGatewayResponse.builder().setStatusCode(200).setObjectBody(pollDetailsResponse) ...