Record Class XRateLimitReset

java.lang.Object
java.lang.Record
net.ygbstudio.jbrave.api.rate.XRateLimitReset
Record Components:
secondsUntilNextRequest - Seconds until you can make another request (per-second limit resets)
secondsUntilMonthlyReset - Seconds until your monthly quota fully resets
timestamp - the instant the rate-limit metadata was read

public record XRateLimitReset(int secondsUntilNextRequest, int secondsUntilMonthlyReset, Instant timestamp) extends Record
Shows when each quota window will reset, expressed in seconds from now.

When you receive a 429 status code, check the X-RateLimit-Reset header to determine how long to wait before retrying.

  • Constructor Details

    • XRateLimitReset

      public XRateLimitReset(int secondsUntilNextRequest, int secondsUntilMonthlyReset, Instant timestamp)
      Creates an instance of a XRateLimitReset record class.
      Parameters:
      secondsUntilNextRequest - the value for the secondsUntilNextRequest record component
      secondsUntilMonthlyReset - the value for the secondsUntilMonthlyReset record component
      timestamp - the value for the timestamp record component
  • Method Details

    • from

      public static <T> Optional<XRateLimitReset> from(@NotNull @NotNull HttpResponse<T> httpResponse)
      Extracts the rate limit reset from the HTTP Response.
      Type Parameters:
      T - the type of the response body
      Parameters:
      httpResponse - the HTTP Response object containing the rate limit reset information
      Returns:
      an optional of the rate limit reset extracted from the httpResponse
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • secondsUntilNextRequest

      public int secondsUntilNextRequest()
      Returns the value of the secondsUntilNextRequest record component.
      Returns:
      the value of the secondsUntilNextRequest record component
    • secondsUntilMonthlyReset

      public int secondsUntilMonthlyReset()
      Returns the value of the secondsUntilMonthlyReset record component.
      Returns:
      the value of the secondsUntilMonthlyReset record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component