driesvints / sponsors

A package for PHP to interact with GitHub Sponsors.
MIT License
104 stars 7 forks source link

Retrieve sponsorships #2

Closed driesvints closed 2 years ago

driesvints commented 2 years ago

Retrieving a list of sponsorships should be a core feature of this library. With this, people can display the sponsorships on their app/website as well as do additional syncing in their app. The sponsorships on a GitHub account can be retrieved with the sponsorshipsAsMaintainer field. Ideally, you we'd hydrate a new GitHubSponsor object with the data from the GitHub account.

The api could like like this:

// Retrieve all sponsors of driesvints...
$sponsors = $client->sponsors('driesvints');

// With the Sponsorable trait...
$sponsors = $user->sponsors();

// Check if a user has sponsors...
$sponsors = $user->hasSponsors();

Which would return a lazy collection. I'd also opt to implement a cursor based paginator approach as well:

// Retrieve all sponsors of driesvints...
$sponsors = $client->paginateSponsors('driesvints');

Which would return an instance of Illuminate\Pagination\CursorPaginator. I'd also make use of BuildsWithQueries to resolve the cursor from the request for a Laravel implementation. See PaginationState.