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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
use anyhow::Result;

use crate::Client;

pub struct Benefits {
    client: Client,
}

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

    /**
     * Get all benefits supported by Gusto.
     *
     * This function performs a `GET` to the `/v1/benefits` endpoint.
     *
     * Returns all benefits supported by Gusto.
     *
     * The benefit object in Gusto contains high level information about a particular benefit type and its tax considerations. When companies choose to offer a benefit, they are creating a Company Benefit object associated with a particular benefit.
     */
    pub async fn get_benefits(&self) -> Result<Vec<crate::types::SupportedBenefit>> {
        let url = "/v1/benefits".to_string();
        self.client.get(&url, None).await
    }

    /**
     * Get all benefits supported by Gusto.
     *
     * This function performs a `GET` to the `/v1/benefits` endpoint.
     *
     * As opposed to `get_benefits`, this function returns all the pages of the request at once.
     *
     * Returns all benefits supported by Gusto.
     *
     * The benefit object in Gusto contains high level information about a particular benefit type and its tax considerations. When companies choose to offer a benefit, they are creating a Company Benefit object associated with a particular benefit.
     */
    pub async fn get_all_benefits(&self) -> Result<Vec<crate::types::SupportedBenefit>> {
        let url = "/v1/benefits".to_string();
        self.client.get_all_pages(&url, None).await
    }

    /**
     * Get a supported benefit by ID.
     *
     * This function performs a `GET` to the `/v1/benefits/{benefit_id}` endpoint.
     *
     * Returns a benefit supported by Gusto.
     *
     * The benefit object in Gusto contains high level information about a particular benefit type and its tax considerations. When companies choose to offer a benefit, they are creating a Company Benefit object associated with a particular benefit.
     */
    pub async fn get_benefit(&self, benefit_id: &str) -> Result<crate::types::SupportedBenefit> {
        let url = format!(
            "/v1/benefits/{}",
            crate::progenitor_support::encode_path(&benefit_id.to_string()),
        );

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

    /**
     * Get benefits for a company.
     *
     * This function performs a `GET` to the `/v1/companies/{company_id}/company_benefits` endpoint.
     *
     * Company benefits represent the benefits that a company is offering to employees. This ties together a particular supported benefit with the company-specific information for the offering of that benefit.
     *
     * Note that company benefits can be deactivated only when no employees are enrolled.
     */
    pub async fn get_company_benefits(
        &self,
        company_id: &str,
    ) -> Result<Vec<crate::types::CompanyBenefit>> {
        let url = format!(
            "/v1/companies/{}/company_benefits",
            crate::progenitor_support::encode_path(&company_id.to_string()),
        );

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

    /**
     * Get benefits for a company.
     *
     * This function performs a `GET` to the `/v1/companies/{company_id}/company_benefits` endpoint.
     *
     * As opposed to `get_company_benefits`, this function returns all the pages of the request at once.
     *
     * Company benefits represent the benefits that a company is offering to employees. This ties together a particular supported benefit with the company-specific information for the offering of that benefit.
     *
     * Note that company benefits can be deactivated only when no employees are enrolled.
     */
    pub async fn get_all_company_benefits(
        &self,
        company_id: &str,
    ) -> Result<Vec<crate::types::CompanyBenefit>> {
        let url = format!(
            "/v1/companies/{}/company_benefits",
            crate::progenitor_support::encode_path(&company_id.to_string()),
        );

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

    /**
     * Create a company benefit.
     *
     * This function performs a `POST` to the `/v1/companies/{company_id}/company_benefits` endpoint.
     *
     * Company benefits represent the benefits that a company is offering to employees. This ties together a particular supported benefit with the company-specific information for the offering of that benefit.
     *
     * Note that company benefits can be deactivated only when no employees are enrolled.
     */
    pub async fn post_company_benefit(
        &self,
        company_id: &str,
        body: &crate::types::PostCompanyBenefitRequest,
    ) -> Result<crate::types::CompanyBenefit> {
        let url = format!(
            "/v1/companies/{}/company_benefits",
            crate::progenitor_support::encode_path(&company_id.to_string()),
        );

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

    /**
     * Get a company benefit.
     *
     * This function performs a `GET` to the `/v1/company_benefits/{company_benefit_id}` endpoint.
     *
     * Company benefits represent the benefits that a company is offering to employees. This ties together a particular supported benefit with the company-specific information for the offering of that benefit.
     *
     * Note that company benefits can be deactivated only when no employees are enrolled.
     */
    pub async fn get_company_benefit(
        &self,
        company_benefit_id: &str,
    ) -> Result<crate::types::CompanyBenefit> {
        let url = format!(
            "/v1/company_benefits/{}",
            crate::progenitor_support::encode_path(&company_benefit_id.to_string()),
        );

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

    /**
     * Update a company benefit.
     *
     * This function performs a `PUT` to the `/v1/company_benefits/{company_benefit_id}` endpoint.
     *
     * Company benefits represent the benefits that a company is offering to employees. This ties together a particular supported benefit with the company-specific information for the offering of that benefit.
     *
     * Note that company benefits can be deactivated only when no employees are enrolled.
     */
    pub async fn put_company_benefit(
        &self,
        company_benefit_id: &str,
        body: &crate::types::PutCompanyBenefitRequest,
    ) -> Result<crate::types::CompanyBenefit> {
        let url = format!(
            "/v1/company_benefits/{}",
            crate::progenitor_support::encode_path(&company_benefit_id.to_string()),
        );

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

    /**
     * Get an employee's benefits.
     *
     * This function performs a `GET` to the `/v1/employees/{employee_id}/employee_benefits` endpoint.
     *
     * Employee benefits represent an employee enrolled in a particular company benefit. It includes information specific to that employee’s enrollment.
     *
     * Returns an array of all employee benefits for this employee
     */
    pub async fn get_employee_benefits(
        &self,
        employee_id: &str,
    ) -> Result<Vec<crate::types::EmployeeBenefit>> {
        let url = format!(
            "/v1/employees/{}/employee_benefits",
            crate::progenitor_support::encode_path(&employee_id.to_string()),
        );

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

    /**
     * Get an employee's benefits.
     *
     * This function performs a `GET` to the `/v1/employees/{employee_id}/employee_benefits` endpoint.
     *
     * As opposed to `get_employee_benefits`, this function returns all the pages of the request at once.
     *
     * Employee benefits represent an employee enrolled in a particular company benefit. It includes information specific to that employee’s enrollment.
     *
     * Returns an array of all employee benefits for this employee
     */
    pub async fn get_all_employee_benefits(
        &self,
        employee_id: &str,
    ) -> Result<Vec<crate::types::EmployeeBenefit>> {
        let url = format!(
            "/v1/employees/{}/employee_benefits",
            crate::progenitor_support::encode_path(&employee_id.to_string()),
        );

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

    /**
     * Create an employee benefit.
     *
     * This function performs a `POST` to the `/v1/employees/{employee_id}/employee_benefits` endpoint.
     *
     * Employee benefits represent an employee enrolled in a particular company benefit. It includes information specific to that employee’s enrollment.
     */
    pub async fn post_employee_benefit(
        &self,
        employee_id: &str,
        body: &crate::types::PostEmployeeBenefitRequest,
    ) -> Result<crate::types::EmployeeBenefit> {
        let url = format!(
            "/v1/employees/{}/employee_benefits",
            crate::progenitor_support::encode_path(&employee_id.to_string()),
        );

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

    /**
     * Year-to-date Benefit Amounts from Different Company.
     *
     * This function performs a `POST` to the `/v1/employees/{employee_id}/ytd_benefit_amounts_from_different_company` endpoint.
     *
     * Year-to-date benefit amounts from a different company represents the amount of money added to an employees plan during a current year, made outside of the current contribution when they were employed at a different company.
     */
    pub async fn post_employee_ytd_benefit_amounts_from_different_company(
        &self,
        employee_id: &str,
        body: &crate::types::PostEmployeeYtdBenefitAmountsFromDifferentCompanyRequest,
    ) -> Result<()> {
        let url = format!(
            "/v1/employees/{}/ytd_benefit_amounts_from_different_company",
            crate::progenitor_support::encode_path(&employee_id.to_string()),
        );

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

    /**
     * Get an employee benefit.
     *
     * This function performs a `GET` to the `/v1/employee_benefits/{employee_benefit_id}` endpoint.
     *
     * Employee benefits represent an employee enrolled in a particular company benefit. It includes information specific to that employee’s enrollment.
     */
    pub async fn get_employee_benefit(
        &self,
        employee_benefit_id: &str,
    ) -> Result<crate::types::EmployeeBenefit> {
        let url = format!(
            "/v1/employee_benefits/{}",
            crate::progenitor_support::encode_path(&employee_benefit_id.to_string()),
        );

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

    /**
     * Update an employee benefit.
     *
     * This function performs a `PUT` to the `/v1/employee_benefits/{employee_benefit_id}` endpoint.
     *
     * Employee benefits represent an employee enrolled in a particular company benefit. It includes information specific to that employee’s enrollment.
     */
    pub async fn put_employee_benefit(
        &self,
        employee_benefit_id: &str,
        body: &crate::types::PutEmployeeBenefitRequest,
    ) -> Result<crate::types::EmployeeBenefit> {
        let url = format!(
            "/v1/employee_benefits/{}",
            crate::progenitor_support::encode_path(&employee_benefit_id.to_string()),
        );

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

    /**
     * Delete an employee benefit.
     *
     * This function performs a `DELETE` to the `/v1/employee_benefits/{employee_benefit_id}` endpoint.
     *
     * Employee benefits represent an employee enrolled in a particular company benefit. It includes information specific to that employee’s enrollment.
     */
    pub async fn delete_employee_benefit(&self, employee_benefit_id: &str) -> Result<()> {
        let url = format!(
            "/v1/employee_benefits/{}",
            crate::progenitor_support::encode_path(&employee_benefit_id.to_string()),
        );

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