Module: Genius::WebPages

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

Overview

A web page is a single, publicly accessible page to which annotations may be attached. Web pages map 1-to-1 with unique, canonical URLs.

Class Method Summary collapse

Class Method Details

.lookup(token: nil, options: {}) ⇒ Hash?

Looks up a web page by URL variants and returns Genius metadata.

Parameters:

  • token (String?) (defaults to: nil)

    Token to access api.genius.com.

  • options (Hash) (defaults to: {})

    URL variants: :raw_annotatable_url, :canonical_url, :og_url.

Returns:



13
14
15
16
17
18
19
20
21
# File 'lib/genius/api/web_pages.rb', line 13

def lookup(token: nil, options: {})
  return if token.nil? && !Auth.authorized?.nil?

  Errors.validate_token(token) unless token.nil?

  params = options_helper(options, %i[raw_annotatable_url canonical_url og_url])
  response = HTTParty.get("#{Api::RESOURCE}/?access_token=#{token_ext(token)}#{params}").body
  JSON.parse(response)
end