use crate::sdk::orders::http::responses::create::CreateAnalysisResponse;
use crate::{KondutoClient, KondutoResult, Order};

impl KondutoClient {
    /// Envia um pedido para análise
    ///
    /// # Argumentos
    ///
    /// * `order` - Dados do pedido a ser analisado
    ///
    /// # Exemplo
    ///
    /// ```no_run
    /// use konduto::{KondutoClient, Order, Customer};
    ///
    /// #[tokio::main]
    /// async fn main() -> Result<(), Box<dyn std::error::Error>> {
    ///     use konduto::{OrderId, TotalAmount};
    ///     let client = KondutoClient::new()?;
    ///
    ///     let order = Order::builder()
    ///         .id(OrderId::try_new("ORDER123")?)
    ///         .total_amount(TotalAmount::new(100.0)?)
    ///         .customer(
    ///             Customer::builder()
    ///                 .id("customer-001")?
    ///                 .name("some customer name")?
    ///                 .email("customer@mail.com")?
    ///                 .build()?
    ///         )
    ///         .build()?;
    ///
    ///     let response = client.analyze(&order).await;
    ///
    ///     match response {
    ///         Ok(order_response) => println!("Pedido analisado com sucesso: {:?}", order_response.order.recommendation),
    ///         Err(err) => println!("Erro ao analisar pedido: {:?}", err)
    ///     }
    ///
    ///     Ok(())
    /// }
    /// ```
    pub async fn analyze_batch(
        &self,
        orders: &[Order],
    ) -> KondutoResult<Vec<CreateAnalysisResponse>> {
        let mut responses = Vec::new();

        for order in orders {
            let response = self.analyze(order).await?;
            responses.push(response);
        }

        Ok(responses)
    }
}
