Crates.io | buy_me_a_coffee |
lib.rs | buy_me_a_coffee |
version | 0.3.1 |
source | src |
created_at | 2024-10-31 02:50:12.717255 |
updated_at | 2024-11-15 17:10:08.360248 |
description | A Rust crate for interacting with the Buy Me a Coffee API |
homepage | |
repository | https://github.com/valentinegb/buy-me-a-coffee-rs |
max_upload_size | |
id | 1429575 |
size | 18,307 |
buy_me_a_coffee
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...