sponsors icon indicating copy to clipboard operation
sponsors copied to clipboard

Check sponsorship tiers

Open driesvints opened this issue 2 years ago • 0 comments

With this library it should be possible to check if users are sponsoring through specific tiers. This will allow for even more fine-graned ACL capabilities and perk-granting.

The API would look as something like below. The used token is that of the "driesvints" GitHub account.

// Check if nunomaduro is sponsoring driesvints on the "$5 a month" tier:
$client->hasTier('nunomaduro', '$5 a month');

// Through the Sponsorable trait...
$user->hasTier('$5 a month');

// If the Sponsorable has its own token set and wants to check if they are sponsoring on a specific account:
$user->hasTierOn('$5 a month', 'nunomaduro');

These requests would always need to be made from the viewer's standpoint so the used token will need to be properly set. These API's probably need to be fleshed out some more.

GraphQL field of "tier":

tier {
    closestLesserValueTier {
        name
    }
    createdAt
    isCustomAmount
    isOneTime
    monthlyPriceInCents
    monthlyPriceInDollars
    name
    updatedAt
}

All tiers also have internal ID's on their node through their GraphQL field. But these aren't surfaced in the UI of GitHub Sponsors.

driesvints avatar Aug 21 '21 12:08 driesvints