Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion app/Services/HaloDotApi/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
use App\Models\Team;
use App\Services\HaloDotApi\Enums\Mode;
use App\Support\Session\SeasonSession;
use GuzzleHttp\Middleware;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
use Psr\Http\Message\ResponseInterface;
use Symfony\Component\HttpFoundation\Response as ResponseAlias;

class ApiClient implements InfiniteInterface
Expand Down Expand Up @@ -253,7 +256,15 @@ public function banSummary(Player $player): Collection

private function getPendingRequest(): PendingRequest
{
return Http::asJson()
$responseParser = function (ResponseInterface $response) {
Cache::put('ratelimit-limit', $response->getHeader('Ratelimit-Limit'));
Cache::put('ratelimit-remaining', $response->getHeader('Ratelimit-Remaining'));
Cache::put('ratelimit-reset', $response->getHeader('Ratelimit-Reset'));

return $response;
};

return Http::withMiddleware(Middleware::mapResponse($responseParser))
->baseUrl($this->config['domain'].'/games/halo-infinite/')
->withUserAgent('Leaf - v'.config('sentry.release', 'dirty'))
->withHeaders([
Expand Down