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
use anyhow::Result;

use crate::Client;

pub struct Terminations {
    client: Client,
}

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

    /**
     * Get terminations for an employee.
     *
     * This function performs a `GET` to the `/v1/employees/{employee_id}/terminations` endpoint.
     *
     * 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.
     *
     * 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.
     */
    pub async fn get_employee_terminations(
        &self,
        employee_id: &str,
    ) -> Result<Vec<crate::types::Termination>> {
        let url = format!(
            "/v1/employees/{}/terminations",
            crate::progenitor_support::encode_path(&employee_id.to_string()),
        );

        self.client.get(&url, None).await
    }

    /**
     * Get terminations for an employee.
     *
     * This function performs a `GET` to the `/v1/employees/{employee_id}/terminations` endpoint.
     *
     * As opposed to `get_employee_terminations`, this function returns all the pages of the request at once.
     *
     * 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.
     *
     * 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.
     */
    pub async fn get_all_employee_terminations(
        &self,
        employee_id: &str,
    ) -> Result<Vec<crate::types::Termination>> {
        let url = format!(
            "/v1/employees/{}/terminations",
            crate::progenitor_support::encode_path(&employee_id.to_string()),
        );

        self.client.get_all_pages(&url, None).await
    }

    /**
     * Create an employee termination.
     *
     * This function performs a `POST` to the `/v1/employees/{employee_id}/terminations` endpoint.
     *
     * 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.
     *
     * 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.
     */
    pub async fn post_employee_termination(
        &self,
        employee_id: &str,
        body: &crate::types::PostEmployeeTerminationRequest,
    ) -> Result<crate::types::Termination> {
        let url = format!(
            "/v1/employees/{}/terminations",
            crate::progenitor_support::encode_path(&employee_id.to_string()),
        );

        self.client
            .post(
                &url,
                Some(reqwest::Body::from(serde_json::to_vec(body).unwrap())),
            )
            .await
    }
}