Skip to content

Commit

Permalink
Merge pull request #33 from tzmfreedom/fix_examples
Browse files Browse the repository at this point in the history
Fix examples
  • Loading branch information
tzmfreedom authored Nov 11, 2024
2 parents 1131004 + 73aea41 commit ad25c34
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async fn main() -> Result<(), Error> {
let mut client = Client::new(Some(client_id), Some(client_secret));
client.login_with_credential(username, password).await?;

let res = client.describe_global().await?;
let res = client.describe("Account").await?;
println!("{:?}", res);

Ok(())
Expand Down
18 changes: 18 additions & 0 deletions examples/describe_global.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use rustforce::{Client, Error};
use std::env;

#[tokio::main]
async fn main() -> Result<(), Error> {
let client_id = env::var("SFDC_CLIENT_ID").unwrap();
let client_secret = env::var("SFDC_CLIENT_SECRET").unwrap();
let username = env::var("SFDC_USERNAME").unwrap();
let password = env::var("SFDC_PASSWORD").unwrap();

let mut client = Client::new(client_id, client_secret);
client.login_with_credential(username, password).await?;

let res = client.describe_global().await?;
println!("{:?}", res);

Ok(())
}
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ extern crate reqwest;

use crate::errors::Error;
use crate::response::{
AccessToken, CreateResponse, DescribeGlobalResponse, DescribeResponse, ErrorResponse,
QueryResponse, SearchResponse, TokenResponse, VersionResponse,
AccessToken, CreateResponse, DescribeGlobalResponse, ErrorResponse, QueryResponse,
SearchResponse, TokenResponse, VersionResponse,
};
use crate::utils::substring_before;
use regex::Regex;
Expand Down
20 changes: 10 additions & 10 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ pub struct AccessToken {
pub issued_at: String,
}

#[serde(rename_all = "camelCase")]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct DescribeResponse {
pub activateable: bool,
// pub action_overrides: ActionOverride[],
Expand Down Expand Up @@ -93,8 +93,8 @@ pub struct DescribeResponse {
pub urls: Urls,
}

#[serde(rename_all = "camelCase")]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Field {
pub aggregatable: bool,
pub ai_prediction_field: bool,
Expand Down Expand Up @@ -156,8 +156,8 @@ pub struct Field {
pub write_requires_master_read: bool,
}

#[serde(rename_all = "camelCase")]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct ChildRelationship {
pub cascade_delete: bool,
#[serde(rename = "childSObject")]
Expand All @@ -170,8 +170,8 @@ pub struct ChildRelationship {
pub restricted_delete: bool,
}

#[serde(rename_all = "camelCase")]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Urls {
pub compact_layouts: String,
pub row_template: String,
Expand All @@ -187,16 +187,16 @@ pub struct Urls {
pub sobject: String,
}

#[serde(rename_all = "camelCase")]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct DescribeGlobalResponse {
pub encoding: String,
pub max_batch_size: u16,
pub sobjects: Vec<DescribeGlobalSObjectResponse>,
}

#[serde(rename_all = "camelCase")]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct DescribeGlobalSObjectResponse {
pub activateable: bool,
pub createable: bool,
Expand Down Expand Up @@ -224,31 +224,31 @@ pub struct DescribeGlobalSObjectResponse {
pub urls: HashMap<String, String>,
}

#[serde(rename_all = "camelCase")]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct SearchResponse {
pub search_records: Vec<SearchRecord>,
// pub metadata: Metadata,
}

#[serde(rename_all = "camelCase")]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct SearchRecord {
#[serde(rename = "Id")]
pub id: String,
pub attributes: SObjectAttribute,
}

#[serde(rename_all = "camelCase")]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct SObjectAttribute {
#[serde(rename = "type")]
pub sobject_type: String,
pub url: String,
}

#[serde(rename_all = "camelCase")]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct VersionResponse {
pub label: String,
pub url: String,
Expand Down

0 comments on commit ad25c34

Please sign in to comment.