Module: Osu::API::GetRequest

Included in:
Beatmap, BeatmapScore, User, UserBestScore, UserRecentScore
Defined in:
lib/osu/api/get_request.rb

Overview

Structure of a GET request to the API

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#endpointString (readonly)

Returns endpoint to query.

Returns:

  • (String)

    endpoint to query


6
7
8
# File 'lib/osu/api/get_request.rb', line 6

def endpoint
  @endpoint
end

#paramsHash (readonly)

Returns parameters to pass as a querystring.

Returns:

  • (Hash)

    parameters to pass as a querystring


9
10
11
# File 'lib/osu/api/get_request.rb', line 9

def params
  @params
end

Instance Method Details

#execute(key) ⇒ Object

Executes the request set up by the instance of whatever implements GetRequest


19
20
21
22
23
24
# File 'lib/osu/api/get_request.rb', line 19

def execute(key)
  params.merge! API.auth(key)

  response = RestClient.get url, params: params
  JSON.parse response
end

#urlObject

Compose a request URL from API_URL and endpoint


13
14
15
# File 'lib/osu/api/get_request.rb', line 13

def url
  "#{API_URL}/#{endpoint}"
end