#![allow(missing_docs)]
#[cfg(feature = "bulk")]
mod example {
use force::auth::ClientCredentials;
use force::client::ForceClientBuilder;
use serde::Serialize;
#[derive(Serialize)]
struct Account {
#[serde(rename = "Name")]
name: String,
#[serde(rename = "Industry")]
industry: String,
}
pub async fn main() -> anyhow::Result<()> {
let auth = ClientCredentials::new_my_domain(
"client-id",
"client-secret",
"https://your-org.my.salesforce.com",
);
let client = ForceClientBuilder::new().authenticate(auth).build().await?;
let accounts = vec![
Account {
name: "Acme Corp".into(),
industry: "Technology".into(),
},
Account {
name: "Global Ltd".into(),
industry: "Manufacturing".into(),
},
];
let job_info = client.bulk().insert("Account", &accounts).await?;
println!(
"Processed: {}, Failed: {}",
job_info.number_records_processed.unwrap_or(0),
job_info.number_records_failed.unwrap_or(0)
);
Ok(())
}
}
#[cfg(feature = "bulk")]
#[tokio::main]
async fn main() -> anyhow::Result<()> {
example::main().await
}
#[cfg(not(feature = "bulk"))]
fn main() {
println!("This example requires the 'bulk' feature.");
}