logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Twitter::API::Context - Encapsulated state for a request/response

Author

       Marc Mims <marc@questright.com>

Description

       The state for every API call is stored in a context object. It is automatically created when a request is
       initiated and is returned to the caller as the second value in list context. The context includes the
       HTTP::Request and HTTP::Response objects, a reference to the API return data, and accessor for rate limit
       information.

       A reference to the context is also included in a Twitter::API::Error exception.

Methods

http_request
       Returns the HTTP::Request object for the API call.

   http_response
       Returns the HTTP::Response object for the API call.

   result
       Returns the result data for the API call.

   rate_limit
       Every API endpoint has a rate limit. This method returns the rate limit for the endpoint of the API call.
       See <https://developer.twitter.com/en/docs/basics/rate-limiting> for details.

   rate_limit_remaining
       Returns the number of API calls remaining for the endpoint in the current rate limit window.

   rate_limit_reset
       Returns the time of the next rate limit window in UTC epoch seconds.

Name

       Twitter::API::Context - Encapsulated state for a request/response

Synopsis

           my ( $r, $c ) = $client->verify_credentials;

           say sprintf '%d verify_credentials calls remaining unitl %s',
               $c->rate_limit_remaining,
               scalar localtime $c->rate_limit_reset;

           # output:
           74 verify_credentials_calls remaining until Sat Dec  3 22:05:41 2016

Version

       version 1.0006

See Also