1use anyhow::Result;
2
3use crate::Client;
4#[derive(Clone, Debug)]
5pub struct Sandbox {
6 pub client: Client,
7}
8
9impl Sandbox {
10 #[doc(hidden)]
11 pub fn new(client: Client) -> Self {
12 Self { client }
13 }
14
15 #[doc = "Update employment in the Sandbox Environment\n\nUpdates an employment. Use this endpoint to modify employment states for testing\nin the Sandbox environment. This endpoint will respond with a 404 outside of the\nSandbox environment.\n\nFor updating an employment's parameters outside of testing purposes, use [this\nEmployment update endpoint](#operation/patch_update_employment).\n\n\n**Parameters:**\n\n- `employment_id: &'astr`: Employment ID (required)\n\n```rust,no_run\nasync fn example_sandbox_patch_update_employment_4() -> anyhow::Result<()> {\n let client = remote_api::Client::new_from_env();\n let result: remote_api::types::EmploymentResponse = client\n .sandbox()\n .patch_update_employment_4(\n \"some-string\",\n &remote_api::types::EmploymentUpdateParams {\n status: Some(remote_api::types::EmploymentStatus::Deleted),\n },\n )\n .await?;\n println!(\"{:?}\", result);\n Ok(())\n}\n```"]
16 #[tracing::instrument]
17 pub async fn patch_update_employment_4<'a>(
18 &'a self,
19 employment_id: &'a str,
20 body: &crate::types::EmploymentUpdateParams,
21 ) -> Result<crate::types::EmploymentResponse, crate::types::error::Error> {
22 let mut req = self.client.client.request(
23 http::Method::PUT,
24 format!(
25 "{}/{}",
26 self.client.base_url,
27 "v1/sandbox/employments/{employment_id}".replace("{employment_id}", employment_id)
28 ),
29 );
30 req = req.bearer_auth(&self.client.token);
31 req = req.json(body);
32 let resp = req.send().await?;
33 let status = resp.status();
34 if status.is_success() {
35 let text = resp.text().await.unwrap_or_default();
36 serde_json::from_str(&text).map_err(|err| {
37 crate::types::error::Error::from_serde_error(
38 format_serde_error::SerdeError::new(text.to_string(), err),
39 status,
40 )
41 })
42 } else {
43 let text = resp.text().await.unwrap_or_default();
44 Err(crate::types::error::Error::Server {
45 body: text.to_string(),
46 status,
47 })
48 }
49 }
50
51 #[doc = "Update employment in the Sandbox Environment\n\nUpdates an employment. Use this endpoint to modify employment states for testing\nin the Sandbox environment. This endpoint will respond with a 404 outside of the\nSandbox environment.\n\nFor updating an employment's parameters outside of testing purposes, use [this\nEmployment update endpoint](#operation/patch_update_employment).\n\n\n**Parameters:**\n\n- `employment_id: &'astr`: Employment ID (required)\n\n```rust,no_run\nasync fn example_sandbox_patch_update_employment_3() -> anyhow::Result<()> {\n let client = remote_api::Client::new_from_env();\n let result: remote_api::types::EmploymentResponse = client\n .sandbox()\n .patch_update_employment_3(\n \"some-string\",\n &remote_api::types::EmploymentUpdateParams {\n status: Some(remote_api::types::EmploymentStatus::Deleted),\n },\n )\n .await?;\n println!(\"{:?}\", result);\n Ok(())\n}\n```"]
52 #[tracing::instrument]
53 pub async fn patch_update_employment_3<'a>(
54 &'a self,
55 employment_id: &'a str,
56 body: &crate::types::EmploymentUpdateParams,
57 ) -> Result<crate::types::EmploymentResponse, crate::types::error::Error> {
58 let mut req = self.client.client.request(
59 http::Method::PATCH,
60 format!(
61 "{}/{}",
62 self.client.base_url,
63 "v1/sandbox/employments/{employment_id}".replace("{employment_id}", employment_id)
64 ),
65 );
66 req = req.bearer_auth(&self.client.token);
67 req = req.json(body);
68 let resp = req.send().await?;
69 let status = resp.status();
70 if status.is_success() {
71 let text = resp.text().await.unwrap_or_default();
72 serde_json::from_str(&text).map_err(|err| {
73 crate::types::error::Error::from_serde_error(
74 format_serde_error::SerdeError::new(text.to_string(), err),
75 status,
76 )
77 })
78 } else {
79 let text = resp.text().await.unwrap_or_default();
80 Err(crate::types::error::Error::Server {
81 body: text.to_string(),
82 status,
83 })
84 }
85 }
86}