remote_api/
employments.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
use anyhow::Result;

use crate::Client;
#[derive(Clone, Debug)]
pub struct Employments {
    pub client: Client,
}

impl Employments {
    #[doc(hidden)]
    pub fn new(client: Client) -> Self {
        Self { client }
    }

    #[doc = "List employments\n\nLists all employments, except for the deleted ones.\n\nThis endpoint requires and returns country-specific data. The exact required and returned fields will\nvary depending on which country the employment is in. To see the list of parameters for each country,\nsee the **Show form schema** endpoint under the [Countries](#tag/Countries) category.\n\nPlease note that the compliance requirements for each country are subject to change, which will result\nin required and optional parameters being added and deleted without notice.\n\nIf you are using this endpoint to build an integration, make sure you are dynamically collecting or\ndisplaying the latest parameters for each country by querying the _\"Show form schema\"_ endpoint.\n\nFor more information on JSON Schemas, see the **How JSON Schemas work** documentation.\n\nTo learn how you can dynamically generate forms to display in your UI, see the documentation for\nthe [json-schema-form](https://www.notion.so/remotecom/json-schema-form-Documentation-4f390236948b4b2e8b7350ebcd488ca6) tool.\n\n\n\n**Parameters:**\n\n- `company_id: Option<String>`: Company ID\n- `page: Option<i64>`: Starts fetching records after the given page\n- `page_size: Option<i64>`: Change the amount of records returned per page, defaults to 20, limited to 100\n\n```rust,no_run\nasync fn example_employments_get_index() -> anyhow::Result<()> {\n    let client = remote_api::Client::new_from_env();\n    let result: remote_api::types::ListEmploymentsResponse = client\n        .employments()\n        .get_index(\n            Some(\"some-string\".to_string()),\n            Some(4 as i64),\n            Some(4 as i64),\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
    #[tracing::instrument]
    pub async fn get_index<'a>(
        &'a self,
        company_id: Option<String>,
        page: Option<i64>,
        page_size: Option<i64>,
    ) -> Result<crate::types::ListEmploymentsResponse, crate::types::error::Error> {
        let mut req = self.client.client.request(
            http::Method::GET,
            format!("{}/{}", self.client.base_url, "v1/employments"),
        );
        req = req.bearer_auth(&self.client.token);
        let mut query_params = vec![];
        if let Some(p) = company_id {
            query_params.push(("company_id", p));
        }

        if let Some(p) = page {
            query_params.push(("page", format!("{}", p)));
        }

        if let Some(p) = page_size {
            query_params.push(("page_size", format!("{}", p)));
        }

        req = req.query(&query_params);
        let resp = req.send().await?;
        let status = resp.status();
        if status.is_success() {
            let text = resp.text().await.unwrap_or_default();
            serde_json::from_str(&text).map_err(|err| {
                crate::types::error::Error::from_serde_error(
                    format_serde_error::SerdeError::new(text.to_string(), err),
                    status,
                )
            })
        } else {
            let text = resp.text().await.unwrap_or_default();
            Err(crate::types::error::Error::Server {
                body: text.to_string(),
                status,
            })
        }
    }

    #[doc = "Create employment\n\nCreates an employment. We support creating employees and contractors.\n\nThis endpoint requires and returns country-specific data. The exact required and returned fields will\nvary depending on which country the employment is in. To see the list of parameters for each country,\nsee the **Show form schema** endpoint under the [Countries](#tag/Countries) category.\n\nPlease note that the compliance requirements for each country are subject to change, which will result\nin required and optional parameters being added and deleted without notice.\n\nIf you are using this endpoint to build an integration, make sure you are dynamically collecting or\ndisplaying the latest parameters for each country by querying the _\"Show form schema\"_ endpoint.\n\nFor more information on JSON Schemas, see the **How JSON Schemas work** documentation.\n\nTo learn how you can dynamically generate forms to display in your UI, see the documentation for\nthe [json-schema-form](https://www.notion.so/remotecom/json-schema-form-Documentation-4f390236948b4b2e8b7350ebcd488ca6) tool.\n\n\n\n```rust,no_run\nasync fn example_employments_post_create() -> anyhow::Result<()> {\n    let client = remote_api::Client::new_from_env();\n    let result: remote_api::types::EmploymentResponse = client\n        .employments()\n        .post_create(&remote_api::types::EmploymentBasicParams {\n            company_id: \"some-string\".to_string(),\n            country_code: Some(\"some-string\".to_string()),\n            full_name: \"some-string\".to_string(),\n            job_title: Some(\"some-string\".to_string()),\n            personal_email: \"email@example.com\".to_string(),\n            provisional_start_date: Some(chrono::Utc::now().date_naive()),\n            type_: remote_api::types::EmploymentBasicParamsType::Contractor,\n        })\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
    #[tracing::instrument]
    pub async fn post_create<'a>(
        &'a self,
        body: &crate::types::EmploymentBasicParams,
    ) -> Result<crate::types::EmploymentResponse, crate::types::error::Error> {
        let mut req = self.client.client.request(
            http::Method::POST,
            format!("{}/{}", self.client.base_url, "v1/employments"),
        );
        req = req.bearer_auth(&self.client.token);
        req = req.json(body);
        let resp = req.send().await?;
        let status = resp.status();
        if status.is_success() {
            let text = resp.text().await.unwrap_or_default();
            serde_json::from_str(&text).map_err(|err| {
                crate::types::error::Error::from_serde_error(
                    format_serde_error::SerdeError::new(text.to_string(), err),
                    status,
                )
            })
        } else {
            let text = resp.text().await.unwrap_or_default();
            Err(crate::types::error::Error::Server {
                body: text.to_string(),
                status,
            })
        }
    }

    #[doc = "Show employment\n\nShows all the information of an employment.\n\nThis endpoint requires and returns country-specific data. The exact required and returned fields will\nvary depending on which country the employment is in. To see the list of parameters for each country,\nsee the **Show form schema** endpoint under the [Countries](#tag/Countries) category.\n\nPlease note that the compliance requirements for each country are subject to change, which will result\nin required and optional parameters being added and deleted without notice.\n\nIf you are using this endpoint to build an integration, make sure you are dynamically collecting or\ndisplaying the latest parameters for each country by querying the _\"Show form schema\"_ endpoint.\n\nFor more information on JSON Schemas, see the **How JSON Schemas work** documentation.\n\nTo learn how you can dynamically generate forms to display in your UI, see the documentation for\nthe [json-schema-form](https://www.notion.so/remotecom/json-schema-form-Documentation-4f390236948b4b2e8b7350ebcd488ca6) tool.\n\n\n\n**Parameters:**\n\n- `employment_id: &'astr`: Employment ID (required)\n\n```rust,no_run\nasync fn example_employments_get_show() -> anyhow::Result<()> {\n    let client = remote_api::Client::new_from_env();\n    let result: remote_api::types::EmploymentResponse =\n        client.employments().get_show(\"some-string\").await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
    #[tracing::instrument]
    pub async fn get_show<'a>(
        &'a self,
        employment_id: &'a str,
    ) -> Result<crate::types::EmploymentResponse, crate::types::error::Error> {
        let mut req = self.client.client.request(
            http::Method::GET,
            format!(
                "{}/{}",
                self.client.base_url,
                "v1/employments/{employment_id}".replace("{employment_id}", employment_id)
            ),
        );
        req = req.bearer_auth(&self.client.token);
        let resp = req.send().await?;
        let status = resp.status();
        if status.is_success() {
            let text = resp.text().await.unwrap_or_default();
            serde_json::from_str(&text).map_err(|err| {
                crate::types::error::Error::from_serde_error(
                    format_serde_error::SerdeError::new(text.to_string(), err),
                    status,
                )
            })
        } else {
            let text = resp.text().await.unwrap_or_default();
            Err(crate::types::error::Error::Server {
                body: text.to_string(),
                status,
            })
        }
    }

    #[doc = "Update employment\n\nUpdates an employment.\n\n**For `created` employments:** You can change all basic params and onboarding tasks or perform a per onboarding task update.\n\n**For `active` employments:** At this stage, it is only allowed to update the manager (`manager_id` field).\n\nThis endpoint requires and returns country-specific data. The exact required and returned fields will\nvary depending on which country the employment is in. To see the list of parameters for each country,\nsee the **Show form schema** endpoint under the [Countries](#tag/Countries) category.\n\nPlease note that the compliance requirements for each country are subject to change, which will result\nin required and optional parameters being added and deleted without notice.\n\nIf you are using this endpoint to build an integration, make sure you are dynamically collecting or\ndisplaying the latest parameters for each country by querying the _\"Show form schema\"_ endpoint.\n\nFor more information on JSON Schemas, see the **How JSON Schemas work** documentation.\n\nTo learn how you can dynamically generate forms to display in your UI, see the documentation for\nthe [json-schema-form](https://www.notion.so/remotecom/json-schema-form-Documentation-4f390236948b4b2e8b7350ebcd488ca6) tool.\n\n\nPlease contact Remote if you need to update contractors via API since it's currently not supported.\n\n\n**Parameters:**\n\n- `employment_id: &'astr`: Employment ID (required)\n\n```rust,no_run\nasync fn example_employments_patch_update_2() -> anyhow::Result<()> {\n    let client = remote_api::Client::new_from_env();\n    let result: remote_api::types::EmploymentResponse = client\n        .employments()\n        .patch_update_2(\n            \"some-string\",\n            &remote_api::types::EmploymentFullParams {\n                address_details: Some(serde_json::Value::String(\"some-string\".to_string())),\n                administrative_details: Some(serde_json::Value::String(\"some-string\".to_string())),\n                bank_account_details: Some(serde_json::Value::String(\"some-string\".to_string())),\n                billing_address_details: Some(serde_json::Value::String(\"some-string\".to_string())),\n                company_id: \"some-string\".to_string(),\n                contract_details: Some(serde_json::Value::String(\"some-string\".to_string())),\n                country: Some(remote_api::types::Country {\n                    code: \"some-string\".to_string(),\n                    country_subdivisions: Some(vec![remote_api::types::CountrySubdivision {\n                        code: Some(\"some-string\".to_string()),\n                        name: \"some-string\".to_string(),\n                        subdivision_type: Some(\"some-string\".to_string()),\n                    }]),\n                    name: \"some-string\".to_string(),\n                }),\n                emergency_contact_details: Some(serde_json::Value::String(\n                    \"some-string\".to_string(),\n                )),\n                full_name: \"some-string\".to_string(),\n                job_title: \"some-string\".to_string(),\n                manager_id: Some(\"some-string\".to_string()),\n                personal_details: Some(serde_json::Value::String(\"some-string\".to_string())),\n                personal_email: \"some-string\".to_string(),\n                pricing_plan_details: Some(remote_api::types::PricingPlanDetails {\n                    frequency: \"some-string\".to_string(),\n                }),\n                provisional_start_date: Some(chrono::Utc::now().date_naive()),\n            },\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
    #[tracing::instrument]
    pub async fn patch_update_2<'a>(
        &'a self,
        employment_id: &'a str,
        body: &crate::types::EmploymentFullParams,
    ) -> Result<crate::types::EmploymentResponse, crate::types::error::Error> {
        let mut req = self.client.client.request(
            http::Method::PUT,
            format!(
                "{}/{}",
                self.client.base_url,
                "v1/employments/{employment_id}".replace("{employment_id}", employment_id)
            ),
        );
        req = req.bearer_auth(&self.client.token);
        req = req.json(body);
        let resp = req.send().await?;
        let status = resp.status();
        if status.is_success() {
            let text = resp.text().await.unwrap_or_default();
            serde_json::from_str(&text).map_err(|err| {
                crate::types::error::Error::from_serde_error(
                    format_serde_error::SerdeError::new(text.to_string(), err),
                    status,
                )
            })
        } else {
            let text = resp.text().await.unwrap_or_default();
            Err(crate::types::error::Error::Server {
                body: text.to_string(),
                status,
            })
        }
    }

    #[doc = "Update employment\n\nUpdates an employment.\n\n**For `created` employments:** You can change all basic params and onboarding tasks or perform a per onboarding task update.\n\n**For `active` employments:** At this stage, it is only allowed to update the manager (`manager_id` field).\n\nThis endpoint requires and returns country-specific data. The exact required and returned fields will\nvary depending on which country the employment is in. To see the list of parameters for each country,\nsee the **Show form schema** endpoint under the [Countries](#tag/Countries) category.\n\nPlease note that the compliance requirements for each country are subject to change, which will result\nin required and optional parameters being added and deleted without notice.\n\nIf you are using this endpoint to build an integration, make sure you are dynamically collecting or\ndisplaying the latest parameters for each country by querying the _\"Show form schema\"_ endpoint.\n\nFor more information on JSON Schemas, see the **How JSON Schemas work** documentation.\n\nTo learn how you can dynamically generate forms to display in your UI, see the documentation for\nthe [json-schema-form](https://www.notion.so/remotecom/json-schema-form-Documentation-4f390236948b4b2e8b7350ebcd488ca6) tool.\n\n\nPlease contact Remote if you need to update contractors via API since it's currently not supported.\n\n\n**Parameters:**\n\n- `employment_id: &'astr`: Employment ID (required)\n\n```rust,no_run\nasync fn example_employments_patch_update() -> anyhow::Result<()> {\n    let client = remote_api::Client::new_from_env();\n    let result: remote_api::types::EmploymentResponse = client\n        .employments()\n        .patch_update(\n            \"some-string\",\n            &remote_api::types::EmploymentFullParams {\n                address_details: Some(serde_json::Value::String(\"some-string\".to_string())),\n                administrative_details: Some(serde_json::Value::String(\"some-string\".to_string())),\n                bank_account_details: Some(serde_json::Value::String(\"some-string\".to_string())),\n                billing_address_details: Some(serde_json::Value::String(\"some-string\".to_string())),\n                company_id: \"some-string\".to_string(),\n                contract_details: Some(serde_json::Value::String(\"some-string\".to_string())),\n                country: Some(remote_api::types::Country {\n                    code: \"some-string\".to_string(),\n                    country_subdivisions: Some(vec![remote_api::types::CountrySubdivision {\n                        code: Some(\"some-string\".to_string()),\n                        name: \"some-string\".to_string(),\n                        subdivision_type: Some(\"some-string\".to_string()),\n                    }]),\n                    name: \"some-string\".to_string(),\n                }),\n                emergency_contact_details: Some(serde_json::Value::String(\n                    \"some-string\".to_string(),\n                )),\n                full_name: \"some-string\".to_string(),\n                job_title: \"some-string\".to_string(),\n                manager_id: Some(\"some-string\".to_string()),\n                personal_details: Some(serde_json::Value::String(\"some-string\".to_string())),\n                personal_email: \"some-string\".to_string(),\n                pricing_plan_details: Some(remote_api::types::PricingPlanDetails {\n                    frequency: \"some-string\".to_string(),\n                }),\n                provisional_start_date: Some(chrono::Utc::now().date_naive()),\n            },\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
    #[tracing::instrument]
    pub async fn patch_update<'a>(
        &'a self,
        employment_id: &'a str,
        body: &crate::types::EmploymentFullParams,
    ) -> Result<crate::types::EmploymentResponse, crate::types::error::Error> {
        let mut req = self.client.client.request(
            http::Method::PATCH,
            format!(
                "{}/{}",
                self.client.base_url,
                "v1/employments/{employment_id}".replace("{employment_id}", employment_id)
            ),
        );
        req = req.bearer_auth(&self.client.token);
        req = req.json(body);
        let resp = req.send().await?;
        let status = resp.status();
        if status.is_success() {
            let text = resp.text().await.unwrap_or_default();
            serde_json::from_str(&text).map_err(|err| {
                crate::types::error::Error::from_serde_error(
                    format_serde_error::SerdeError::new(text.to_string(), err),
                    status,
                )
            })
        } else {
            let text = resp.text().await.unwrap_or_default();
            Err(crate::types::error::Error::Server {
                body: text.to_string(),
                status,
            })
        }
    }
}