#![allow(missing_docs)]
#[cfg(feature = "rest")]
mod example {
use force::api::RestOperation;
use force::auth::ClientCredentials;
use force::client::ForceClientBuilder;
use serde::Deserialize;
#[derive(Debug, Deserialize)]
struct Account {
#[serde(rename = "Id")]
id: String,
#[serde(rename = "Name")]
name: String,
#[serde(rename = "Industry")]
industry: Option<String>,
}
pub async fn main() -> anyhow::Result<()> {
let auth = ClientCredentials::new_my_domain(
"your-client-id",
"your-client-secret",
"https://your-org.my.salesforce.com",
);
let client = ForceClientBuilder::new().authenticate(auth).build().await?;
let soql = "SELECT Id, Name, Industry FROM Account WHERE Industry = 'Technology' LIMIT 10";
let result = client.rest().query::<Account>(soql).await?;
for account in result.records {
println!(
"{}: {} ({})",
account.id,
account.name,
account.industry.unwrap_or_default()
);
}
Ok(())
}
}
#[cfg(feature = "rest")]
#[tokio::main]
async fn main() -> anyhow::Result<()> {
example::main().await
}
#[cfg(not(feature = "rest"))]
fn main() {
println!("This example requires the 'rest' feature.");
}