Module: TriviaCrack::API::Profile

Includes:
Common
Included in:
Client
Defined in:
lib/triviacrack/api/profile.rb

Instance Method Summary collapse

Methods included from Common

#get, #post

Instance Method Details

#get_my_profileObject

Public: Uses the Trivia Crack API to get the profile of current user.

Examples

profile = client.get_my_profile

Returns the TriviaCrack::Profile for the current user. Raises TriviaCrack::Errors::RequestError if the request fails.



35
36
37
38
39
40
# File 'lib/triviacrack/api/profile.rb', line 35

def get_my_profile
  response =
    get "/api/users/#{@session.user_id}/profiles/#{@session.user_id}"

  TriviaCrack::Parsers::ProfileParser.parse response.body
end

#get_profile(user_id) ⇒ Object

Public: Uses the Trivia Crack API to get the profile of the user with the given user id.

user_id - The unique identifier of the user.

Examples

profile = client.get_profile 123

Returns the TriviaCrack::Profile for the given user. Raises TriviaCrack::Errors::RequestError if the request fails.



21
22
23
24
25
# File 'lib/triviacrack/api/profile.rb', line 21

def get_profile(user_id)
  response = get "/api/users/#{@session.user_id}/profiles/#{user_id}"

  TriviaCrack::Parsers::ProfileParser.parse response.body
end