Class: Strava::Web::ApiResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/strava/web/api_response.rb

Overview

Wraps an HTTP response with rate limit information.

This class provides access to both the raw HTTP response and parsed rate limit data from the response headers.

Examples:

Accessing response data

activity = client.activity(1234567890)
api_response = activity.http_response

# Access raw HTTP response
status = api_response.response.status
headers = api_response.response.headers

# Access rate limit information
puts "Requests remaining: #{api_response.ratelimit.fifteen_minutes_remaining}"

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ ApiResponse

Initialize a new ApiResponse with an HTTP response.

Parameters:

  • http_response (Faraday::Response)

    HTTP response from the Strava API



37
38
39
40
# File 'lib/strava/web/api_response.rb', line 37

def initialize(http_response)
  @response = http_response
  @ratelimit = Strava::Api::Ratelimit.new(http_response)
end

Instance Attribute Details

#ratelimitStrava::Api::Ratelimit

Returns Rate limit information extracted from response headers.

Returns:



30
31
32
# File 'lib/strava/web/api_response.rb', line 30

def ratelimit
  @ratelimit
end

#responseFaraday::Response

Returns The raw HTTP response.

Returns:

  • (Faraday::Response)

    The raw HTTP response



27
28
29
# File 'lib/strava/web/api_response.rb', line 27

def response
  @response
end