sellapp-sdk 0.1.1

Official Rust SDK for the SellApp API: manage products, orders, subscriptions, and customers.
// This file is auto-generated by oagen. Do not edit.

use sellapp::resources::products::ListParams;
use sellapp::{Client, Error};

pub async fn first_request(client: &Client) -> Result<Vec<(i64, String)>, Error> {
    let page = client
        .products()
        .list(ListParams {
            limit: Some(1),
            ..Default::default()
        })
        .await?;
    let products: Vec<_> = page.data.into_iter().map(|p| (p.id, p.title)).collect();
    for (id, title) in &products {
        println!("{id}: {title}");
    }
    if products.is_empty() {
        println!("No products yet. Your connection is ready.");
    }
    Ok(products)
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Require a deliberate destination for this runnable example.
    let base_url = std::env::var("SELLAPP_API_BASE_URL")?;
    let client = Client::from_env()?
        .with_base_url(base_url)
        .with_max_retries(0);
    first_request(&client).await?;
    Ok(())
}