buy_me_a_coffee

Crates.iobuy_me_a_coffee
lib.rsbuy_me_a_coffee
version0.3.1
sourcesrc
created_at2024-10-31 02:50:12.717255
updated_at2024-11-15 17:10:08.360248
descriptionA Rust crate for interacting with the Buy Me a Coffee API
homepage
repositoryhttps://github.com/valentinegb/buy-me-a-coffee-rs
max_upload_size
id1429575
size18,307
Valentine Briese (valentinegb)

documentation

README

buy_me_a_coffee

Crates.io Version docs.rs Rust

A Rust crate for interacting with the Buy Me a Coffee API.

Here's an example of how you could use this crate to check if somebody has a membership level called "Early Access":

use buy_me_a_coffee::MemberStatus;

async fn has_early_access(email: String) -> bool {
    let client = buy_me_a_coffee::Client::new("personal access token here");
    let mut page_num = 1;

    while let Ok(page) = client.members(MemberStatus::Active, page_num).await {
        for membership in page.data {
            if membership.payer_email != email {
                continue;
            }

            if membership.id != EARLY_ACCESS_ID {
                continue;
            }

            return true;
        }

        page_num += 1;
    }

    false
}

Truthfully, this crate is not really ready to be used. It's not possible to test most things when I don't have any supporters on Buy Me a Coffee since the API returns a "No [subscriptions|supporters|extra purchases]" error. If someone would buy me a coffee, that would really help out with this project, wink wink...

Commit count: 26

cargo fmt