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>> {
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(())
}