Astrotomic / opendor.me

https://opendor.me
Other
75 stars 29 forks source link

Add `\Illuminate\Http\Client\Response->paginated()` macro #103

Open Gummibeer opened 3 years ago

Gummibeer commented 3 years ago

relates to #82

Instead of doing $this->paginated(...) in the job it would be cool to do Http::github()->get()->paginated(fn() => ...).

The paginated macro should accept one closure argument that runs for each response and gets the response instance as it's own argument.

Http::github()
    ->get("/orgs/{$this->organization->name}/repos")
    ->paginated(function(\Illuminate\Http\Client\Response $response): void {
        $response->collect()->map(...);
    });

https://github.com/Astrotomic/opendor.me/blob/b258e25c1d10e0fc1100a634290431bc1bcc8665/app/Jobs/SyncUserContributions.php#L25-L47