rippling_base_api/
ats.rs

1use anyhow::Result;
2
3use crate::Client;
4#[derive(Clone, Debug)]
5pub struct Ats {
6    pub client: Client,
7}
8
9impl Ats {
10    #[doc(hidden)]
11    pub fn new(client: Client) -> Self {
12        Self { client }
13    }
14
15    #[doc = "POST New Candidate\n\nPushes a candidate from an applicant tracking system directly into the Rippling onboarding flow. Please note, this endpoint is only available to applications integrating with OAuth2.0.\n\nNOTE: This endpoint is NOT available for use with Rippling customer API Keys.\n\n```rust,no_run\nasync fn example_ats_post_candidates_push_candidate() -> anyhow::Result<()> {\n    let client = rippling_base_api::Client::new_from_env();\n    let result: rippling_base_api::types::Candidate = client\n        .ats()\n        .post_candidates_push_candidate(&rippling_base_api::types::Candidate {\n            name: Some(\"some-string\".to_string()),\n            email: Some(\"some-string\".to_string()),\n            job_title: Some(\"some-string\".to_string()),\n            phone_number: Some(\"some-string\".to_string()),\n            candidate_id: Some(\"some-string\".to_string()),\n            start_date: Some(chrono::Utc::now().date_naive()),\n            salary_unit: Some(rippling_base_api::types::SalaryUnit::PayPeriod),\n            salary_per_unit: Some(3.14 as f64),\n            signing_bonus: Some(3.14 as f64),\n            currency: Some(\"some-string\".to_string()),\n            equity_shares: Some(4 as i64),\n            department: Some(\"some-string\".to_string()),\n            employment_type: Some(rippling_base_api::types::CandidateEmploymentType::Temp),\n            work_location: Some(\"some-string\".to_string()),\n            attachments: Some(vec![rippling_base_api::types::Attachments {\n                file_name: Some(\"some-string\".to_string()),\n                file_url: Some(\"some-string\".to_string()),\n            }]),\n        })\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
16    #[tracing::instrument]
17    pub async fn post_candidates_push_candidate<'a>(
18        &'a self,
19        body: &crate::types::Candidate,
20    ) -> Result<crate::types::Candidate, crate::types::error::Error> {
21        let mut req = self.client.client.request(
22            http::Method::POST,
23            &format!(
24                "{}/{}",
25                self.client.base_url, "platform/api/ats_candidates/push_candidate"
26            ),
27        );
28        req = req.bearer_auth(&self.client.token);
29        req = req.json(body);
30        let resp = req.send().await?;
31        let status = resp.status();
32        if status.is_success() {
33            let text = resp.text().await.unwrap_or_default();
34            serde_json::from_str(&text).map_err(|err| {
35                crate::types::error::Error::from_serde_error(
36                    format_serde_error::SerdeError::new(text.to_string(), err),
37                    status,
38                )
39            })
40        } else {
41            let text = resp.text().await.unwrap_or_default();
42            return Err(crate::types::error::Error::Server {
43                body: text.to_string(),
44                status,
45            });
46        }
47    }
48}