gusto_api/
terminations.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct Terminations {
5    pub client: Client,
6}
7
8impl Terminations {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        Terminations { client }
12    }
13
14    /**
15     * Get terminations for an employee.
16     *
17     * This function performs a `GET` to the `/v1/employees/{employee_id}/terminations` endpoint.
18     *
19     * Terminations are created whenever an employee is scheduled to leave the company. The only things required are an effective date (their last day of work) and whether they should receive their wages in a one-off termination payroll or with the rest of the company.
20     *
21     * Note that some states require employees to receive their final wages within 24 hours (unless they consent otherwise,) in which case running a one-off payroll may be the only option.
22     */
23    pub async fn get_employee(
24        &self,
25        employee_id: &str,
26    ) -> ClientResult<crate::Response<Vec<crate::types::Termination>>> {
27        let url = self.client.url(
28            &format!(
29                "/v1/employees/{}/terminations",
30                crate::progenitor_support::encode_path(employee_id),
31            ),
32            None,
33        );
34        self.client
35            .get(
36                &url,
37                crate::Message {
38                    body: None,
39                    content_type: None,
40                },
41            )
42            .await
43    }
44    /**
45     * Get terminations for an employee.
46     *
47     * This function performs a `GET` to the `/v1/employees/{employee_id}/terminations` endpoint.
48     *
49     * As opposed to `get_employee`, this function returns all the pages of the request at once.
50     *
51     * Terminations are created whenever an employee is scheduled to leave the company. The only things required are an effective date (their last day of work) and whether they should receive their wages in a one-off termination payroll or with the rest of the company.
52     *
53     * Note that some states require employees to receive their final wages within 24 hours (unless they consent otherwise,) in which case running a one-off payroll may be the only option.
54     */
55    pub async fn get_all_employee(
56        &self,
57        employee_id: &str,
58    ) -> ClientResult<crate::Response<Vec<crate::types::Termination>>> {
59        let url = self.client.url(
60            &format!(
61                "/v1/employees/{}/terminations",
62                crate::progenitor_support::encode_path(employee_id),
63            ),
64            None,
65        );
66        self.client
67            .get_all_pages(
68                &url,
69                crate::Message {
70                    body: None,
71                    content_type: None,
72                },
73            )
74            .await
75    }
76    /**
77     * Create an employee termination.
78     *
79     * This function performs a `POST` to the `/v1/employees/{employee_id}/terminations` endpoint.
80     *
81     * Terminations are created whenever an employee is scheduled to leave the company. The only things required are an effective date (their last day of work) and whether they should receive their wages in a one-off termination payroll or with the rest of the company.
82     *
83     * Note that some states require employees to receive their final wages within 24 hours (unless they consent otherwise,) in which case running a one-off payroll may be the only option.
84     */
85    pub async fn post_employee(
86        &self,
87        employee_id: &str,
88        body: &crate::types::PostEmployeeTerminationsRequest,
89    ) -> ClientResult<crate::Response<crate::types::Termination>> {
90        let url = self.client.url(
91            &format!(
92                "/v1/employees/{}/terminations",
93                crate::progenitor_support::encode_path(employee_id),
94            ),
95            None,
96        );
97        self.client
98            .post(
99                &url,
100                crate::Message {
101                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
102                    content_type: Some("application/json".to_string()),
103                },
104            )
105            .await
106    }
107}