Class TwitterRateLimit

java.lang.Object
com.northconcepts.datapipeline.twitter.TwitterRateLimit

public class TwitterRateLimit extends Object
A snapshot of a Twitter API rate limit: the calls allowed, the calls remaining and when the limit resets.
  • Constructor Details

    • TwitterRateLimit

      public TwitterRateLimit(RateLimitStatus rateLimit)
      Creates a snapshot of the given status; a null status yields 100 of 100 calls remaining.
  • Method Details

    • getResetInterval

      public Interval getResetInterval()
      Returns the time left until the limit resets, truncated to whole seconds.
    • getLimit

      public int getLimit()
    • getLimitRemaining

      public int getLimitRemaining()
    • getLimitResetTime

      public long getLimitResetTime()
      Returns when the limit resets, in milliseconds since the epoch.
    • getLimitResetTimeRemaining

      public long getLimitResetTimeRemaining()
      Returns the milliseconds left until the limit resets, or 0 if the reset time has passed.
    • getPercentage

      public int getPercentage()
      Returns the percentage of calls remaining, rounded down.
    • getRemainingCallString

      public String getRemainingCallString()
      Returns the remaining percentage as text, such as "75% API calls remaining".
    • getResetTimeString

      public String getResetTimeString()
      Returns "Reset in " followed by the reset interval.
    • toString

      public String toString()
      Overrides:
      toString in class Object