busbar_sf_tooling/client/
mod.rs1use busbar_sf_client::{ClientConfig, SalesforceClient};
7
8use crate::error::Result;
9
10mod apex;
11mod code_intelligence;
12mod collections;
13mod composite;
14mod coverage;
15#[cfg(feature = "dependencies")]
16mod dependencies;
17mod describe;
18mod execute;
19mod logs;
20mod query;
21mod sobject;
22mod test_execution;
23mod trace_flags;
24
25#[derive(Debug, Clone)]
52pub struct ToolingClient {
53 client: SalesforceClient,
54}
55
56impl ToolingClient {
57 pub fn new(instance_url: impl Into<String>, access_token: impl Into<String>) -> Result<Self> {
59 let client = SalesforceClient::new(instance_url, access_token)?;
60 Ok(Self { client })
61 }
62
63 pub fn with_config(
65 instance_url: impl Into<String>,
66 access_token: impl Into<String>,
67 config: ClientConfig,
68 ) -> Result<Self> {
69 let client = SalesforceClient::with_config(instance_url, access_token, config)?;
70 Ok(Self { client })
71 }
72
73 pub fn from_client(client: SalesforceClient) -> Self {
75 Self { client }
76 }
77
78 pub fn inner(&self) -> &SalesforceClient {
80 &self.client
81 }
82
83 pub fn instance_url(&self) -> &str {
85 self.client.instance_url()
86 }
87
88 pub fn api_version(&self) -> &str {
90 self.client.api_version()
91 }
92
93 pub fn with_api_version(mut self, version: impl Into<String>) -> Self {
95 self.client = self.client.with_api_version(version);
96 self
97 }
98}
99
100#[cfg(test)]
101mod tests {
102 use super::*;
103
104 #[test]
105 fn test_client_creation() {
106 let client = ToolingClient::new("https://na1.salesforce.com", "token123").unwrap();
107
108 assert_eq!(client.instance_url(), "https://na1.salesforce.com");
109 assert_eq!(client.api_version(), "62.0");
110 }
111
112 #[test]
113 fn test_api_version_override() {
114 let client = ToolingClient::new("https://na1.salesforce.com", "token")
115 .unwrap()
116 .with_api_version("60.0");
117
118 assert_eq!(client.api_version(), "60.0");
119 }
120}