lib/triviacrack/api/question.rb in triviacrack-0.5.1 vs lib/triviacrack/api/question.rb in triviacrack-0.6.0

- old
+ new

@@ -1,5 +1,6 @@ +require "json" require "triviacrack/api/common" require "triviacrack/parsers/game_parser" # Public: All methods in this module make requests to the Trivia Crack answers # API. @@ -29,13 +30,13 @@ answers: [{ id: question.id, answer: answer, category: question.category.upcase }] - }.to_s + }.to_json - game = TriviaCrack::Parsers::GameParser.parse response.body + game = TriviaCrack::Parsers::GameParser.parse response [game, answer == question.correct_answer] end # Public: Uses the Trivia Crack API to answer duel questions for the game. @@ -70,12 +71,12 @@ correct_answers[question.id] = answer_map[question.id] == question.correct_answer end response = post "/api/users/#{@session.user_id}/games/#{game_id}/answers", - parameters: { type: questions.first.type.upcase, answers: answers }.to_s + parameters: { type: questions.first.type.upcase, answers: answers }.to_json - game = TriviaCrack::Parsers::GameParser.parse response.body + game = TriviaCrack::Parsers::GameParser.parse response [game, correct_answers] end end