Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Automatically grant and revoke perks #7

Open
driesvints opened this issue Aug 21, 2021 · 0 comments
Open

Automatically grant and revoke perks #7

driesvints opened this issue Aug 21, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@driesvints
Copy link
Owner

One of the bigger features I'd like to develop over time for this library is the ability to automatically grant and revoke perks. The way that this would work is that the library would offer a common interface for granting and revoking perks as well as an integration with either GitHub Webhooks or the Laravel Scheduler to check periodically for updates and then handle revoking or granting perks.

The actual implementations of whatever perk would be a custom implementation for the consumer of the library. This would open the door for an entire ecosystem of perks like a collection of integrations with different services and what not.

The interface would look as follows:

interface Perk
{
    public function grant(): bool;
    public function revoke(): bool;
    public function tiers(): array;
}

A practical example could be to grant access to a Discord server when you're sponsoring someone:

final class DiscordServerPerk implements Perk
{
    public function grant(): bool
    {
        // handle the logic to grant access to the server...
    }

    public function revoke(): bool
    {
        // handle the logic to revoke access to the server...
    }

    public function tiers(): array
    {
        // return the tiers that allow access to this perk...
    }
}

By returning the tiers that allow access to the perk the library should be able to automatically grant or revoke the perk depending when a user is changing tiers. If they're changing to a new tier that's also in the tiers list of the perk, nothing would change of course.

This idea is a little rough and there's probably tons of edge cases but it would be worth to explore a PoC for this.

@driesvints driesvints added the enhancement New feature or request label Aug 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant