RateLimit.js

  1. /**
  2. * @file
  3. * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
  4. * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
  5. * Github.js is freely distributable.
  6. */
  7. import Requestable from './Requestable';
  8. /**
  9. * RateLimit allows users to query their rate-limit status
  10. */
  11. class RateLimit extends Requestable {
  12. /**
  13. * construct a RateLimit
  14. * @param {Requestable.auth} auth - the credentials to authenticate to GitHub
  15. * @param {string} [apiBase] - the base Github API URL
  16. * @return {Promise} - the promise for the http request
  17. */
  18. constructor(auth, apiBase) {
  19. super(auth, apiBase);
  20. }
  21. /**
  22. * Query the current rate limit
  23. * @see https://developer.github.com/v3/rate_limit/
  24. * @param {Requestable.callback} [cb] - will receive the rate-limit data
  25. * @return {Promise} - the promise for the http request
  26. */
  27. getRateLimit(cb) {
  28. return this._request('GET', '/rate_limit', null, cb);
  29. }
  30. }
  31. module.exports = RateLimit;