//! Paginate through all subscriptions, printing the active ones.
//!
//! Run: `TICKSUPPLY_API_KEY=... cargo run --example paginate_subscriptions`

use futures::TryStreamExt;
use ticksupply::resources::subscriptions::SubscriptionStatus;

#[tokio::main]
async fn main() -> ticksupply::Result<()> {
    let client = ticksupply::Client::new()?;
    let stream = client.subscriptions().list().stream();
    tokio::pin!(stream);
    while let Some(sub) = stream.try_next().await? {
        if matches!(sub.status, SubscriptionStatus::Active) {
            println!("{} -> datastream {}", sub.id, sub.datastream_id);
        }
    }
    Ok(())
}
