Module: Genius::Account

Defined in:
lib/genius/api/account.rb

Overview

Genius::Account module provides methods to work with Genius account

Class Method Summary collapse

Class Method Details

.account(token: nil) ⇒ Hash, NilClass Also known as: me

TODO:

somehow refactor 50/52 exceptions

Genius::Account.account -> value

An alias to me method

This method is a standard Genius API request to get account info. Output JSON is translated to Hash structure to make it easy to work with account fields.

Examples:

Genius::Auth.="yuiaYqbncErCVwItjQxFspNWUZLhGpXrPbkvgbgHSEKJRAlToamzMfdOeDB"
Genius::Account. #=> {"meta"=>{"status"=>200}, "response"=>{"user"=>{...}}}

Parameters:

Returns:

  • (Hash)
  • (NilClass)

    if TokenError exception raised.

Raises:

  • (TokenError)

    if token or Genius::Auth.token are invalid.



22
23
24
25
26
27
28
29
# File 'lib/genius/api/account.rb', line 22

def (token: nil)
  return if token.nil? && !Auth.authorized?.nil?

  Errors.validate_token(token) unless token.nil?

  response = HTTParty.get("https://api.genius.com/account?access_token=#{token_ext(token)}").body
  JSON.parse(response)
end