module TriviaCrack::API::Login
Public Instance Methods
login(email, password)
click to toggle source
Public: Uses the given email and password to log in to Trivia Crack and retrieve a session id and user id.
email - Email of a Trivia Crack user. password - Password of a Trivia Crack user.
Examples
login "user@example.com", "password123"
Returns the user_id and username of the user that has logged in. Raises TriviaCrack::Errors::RequestError
if the request fails.
# File lib/triviacrack/api/login.rb, line 24 def login(email, password) response = post "/api/login", parameters: { email: email, password: password, language: "en" }.to_json @session = TriviaCrack::Parsers::SessionParser.parse response.body end