| 1 | <?php |
||
| 8 | class ApiProvider |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Base API URI. |
||
| 12 | * |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | const BASE_URI = 'https://forge.laravel.com/api/v1/'; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * API token. |
||
| 19 | * |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | private $token; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * HTTP client. |
||
| 26 | * |
||
| 27 | * @var \GuzzleHttp\ClientInterface |
||
| 28 | */ |
||
| 29 | protected $client; |
||
| 30 | |||
| 31 | |||
| 32 | /** |
||
| 33 | * The optional rate limiting function. |
||
| 34 | * |
||
| 35 | * @var \Closure | null |
||
| 36 | */ |
||
| 37 | protected $rateLimiter = null; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Create new API provider instance. |
||
| 41 | * |
||
| 42 | * @param string $token |
||
| 43 | */ |
||
| 44 | public function __construct(string $token) |
||
| 48 | |||
| 49 | /** |
||
| 50 | * HTTP client. |
||
| 51 | * |
||
| 52 | * @return \GuzzleHttp\ClientInterface |
||
| 53 | */ |
||
| 54 | public function getClient(): ClientInterface |
||
| 66 | |||
| 67 | /** |
||
| 68 | * API token. |
||
| 69 | * |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | public function getToken(): string |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Create new HTTP client. |
||
| 79 | * |
||
| 80 | * @return \GuzzleHttp\ClientInterface |
||
| 81 | */ |
||
| 82 | public function createClient(): ClientInterface |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Sets an optional rate limiting function. |
||
| 98 | * |
||
| 99 | * @param \Closure |
||
| 100 | */ |
||
| 101 | public function setRateLimiter(\Closure $rateLimiter) |
||
| 105 | } |
||
| 106 |