// cargo run --example evaluations use std::collections::HashMap; use flipt::api::FliptClient; use flipt::evaluation::models::{BatchEvaluationRequest, EvaluationRequest}; #[tokio::main] #[cfg_attr(not(feature = "flipt_integration"), ignore)] async fn main() -> Result<(), Box> { let client = FliptClient::default(); let mut context: HashMap = HashMap::new(); context.insert("fizz".into(), "buzz".into()); let variant_result = client .evaluation .variant(&EvaluationRequest { namespace_key: "default".into(), flag_key: "flag1".into(), entity_id: "entity".into(), context: context.clone(), reference: None, }) .await .unwrap(); print!("{:?}", variant_result); let boolean_result = client .evaluation .boolean(&EvaluationRequest { namespace_key: "default".into(), flag_key: "flag_boolean".into(), entity_id: "entity".into(), context: context.clone(), reference: None, }) .await .unwrap(); print!("{:?}", boolean_result); let requests: Vec = vec![ EvaluationRequest { namespace_key: "default".into(), flag_key: "flag1".into(), entity_id: "entity".into(), context: context.clone(), reference: None, }, EvaluationRequest { namespace_key: "default".into(), flag_key: "flag_boolean".into(), entity_id: "entity".into(), context: context.clone(), reference: None, }, ]; let batch_result = client .evaluation .batch(&BatchEvaluationRequest { requests, reference: None, }) .await .unwrap(); print!("{:?}", batch_result); Ok(()) }