use crate::catalog;
use crate::errors::SupplementsError;
use crate::types::{CatalogFile, Interaction};
pub fn check_interactions<'a>(
catalog_file: &'a CatalogFile,
product_ids: &[String],
) -> Result<Vec<&'a Interaction>, SupplementsError> {
for id in product_ids {
if catalog::find_product(catalog_file, id).is_none() {
return Err(SupplementsError::ProductNotFound(id.clone()));
}
}
let ids: Vec<&str> = product_ids.iter().map(|s| s.as_str()).collect();
Ok(catalog::find_interactions(catalog_file, &ids))
}