use crate::products::{Product, States};
use crate::{ApiError, Client};
impl Client {
pub async fn get_products(&self) -> Result<Vec<Product<'_>>, ApiError> {
self.api
.get_product_data(&*self.refresh_tokens_if_needed().await?)
.await
.map(|products| {
products
.into_iter()
.map(|data| Product::new(self, data))
.collect()
})
}
pub(crate) async fn set_product_state(
&self,
product_id: &str,
r#type: &str,
states: States,
) -> Result<bool, ApiError> {
self.api
.set_product_state(
&*self.refresh_tokens_if_needed().await?,
product_id,
r#type,
states,
)
.await
}
}