lib/strava/api/ratelimit.rb in strava-ruby-client-1.1.0 vs lib/strava/api/ratelimit.rb in strava-ruby-client-2.0.0
- old
+ new
@@ -7,9 +7,23 @@
@response = response
@headers = response.headers
@body = response.body
end
+ def exceeded
+ return false unless limit?
+
+ @exceeded ||= if fifteen_minutes_remaining && fifteen_minutes_remaining <= 0
+ { fifteen_minutes_remaining: fifteen_minutes_remaining }
+ elsif total_day_remaining && total_day_remaining <= 0
+ { total_day_remaining: total_day_remaining }
+ end
+ end
+
+ def exceeded?
+ !!exceeded
+ end
+
def to_s
to_h.map do |k, v|
"#{k}: #{v}"
end.join(', ')
end