Module: TriviaCrack::API::Login
Instance Method Summary collapse
-
#login(email, password) ⇒ Object
Public: Uses the given email and password to log in to Trivia Crack and retrieve a session id and user id.
Methods included from Common
Instance Method Details
#login(email, password) ⇒ Object
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 "[email protected]", "password123"
Returns the user_id and username of the user that has logged in. Raises TriviaCrack::Errors::RequestError if the request fails.
24 25 26 27 28 29 30 31 |
# 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 |