Skip to main content

ingest/
ingest.rs

1// Compile-check for the README construction example (no network/runtime needed).
2use std::str::FromStr;
3use metronome_sdk::Client;
4use metronome_sdk::types::IngestV1BodyItem;
5
6#[allow(dead_code)]
7fn build() -> Result<(Client, Vec<IngestV1BodyItem>), Box<dyn std::error::Error>> {
8    let mut headers = reqwest::header::HeaderMap::new();
9    let mut auth = reqwest::header::HeaderValue::from_str("Bearer x")?;
10    auth.set_sensitive(true);
11    headers.insert(reqwest::header::AUTHORIZATION, auth);
12    let http = reqwest::Client::builder().default_headers(headers).build()?;
13    let client = Client::new_with_client("https://api.metronome.com", http);
14
15    let events = vec![IngestV1BodyItem {
16        transaction_id: FromStr::from_str("txn-0001")?,
17        customer_id: FromStr::from_str("cust_abc123")?,
18        event_type: FromStr::from_str("api_request")?,
19        timestamp: "2026-06-15T00:00:00Z".to_string(),
20        properties: serde_json::json!({ "tokens": 4096 }).as_object().unwrap().clone(),
21    }];
22    Ok((client, events))
23}
24
25fn main() {}