gusto_api/admins_beta.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct AdminsBeta {
5 pub client: Client,
6}
7
8impl AdminsBeta {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 AdminsBeta { client }
12 }
13
14 /**
15 * Get all the admins at a company.
16 *
17 * This function performs a `GET` to the `/v1/companies/{company_id}/admins` endpoint.
18 *
19 * This endpoint is in beta and intended for **[Gusto Embedded Payroll](https://gusto.com/embedded-payroll)** customers. Please [apply for early access](https://gusto-embedded-payroll.typeform.com/to/iomAQIj3?utm_source=docs) if you’d like to learn more and use it for production. Note, this endpoint will require you to enter a different agreement with Gusto.
20 *
21 * Returns a list of all the admins at a company
22 */
23 pub async fn get_company_admins(
24 &self,
25 company_id: &str,
26 ) -> ClientResult<crate::Response<Vec<crate::types::Admin>>> {
27 let url = self.client.url(
28 &format!(
29 "/v1/companies/{}/admins",
30 crate::progenitor_support::encode_path(company_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 all the admins at a company.
46 *
47 * This function performs a `GET` to the `/v1/companies/{company_id}/admins` endpoint.
48 *
49 * As opposed to `get_company_admins`, this function returns all the pages of the request at once.
50 *
51 * This endpoint is in beta and intended for **[Gusto Embedded Payroll](https://gusto.com/embedded-payroll)** customers. Please [apply for early access](https://gusto-embedded-payroll.typeform.com/to/iomAQIj3?utm_source=docs) if you’d like to learn more and use it for production. Note, this endpoint will require you to enter a different agreement with Gusto.
52 *
53 * Returns a list of all the admins at a company
54 */
55 pub async fn get_all_company_admins(
56 &self,
57 company_id: &str,
58 ) -> ClientResult<crate::Response<Vec<crate::types::Admin>>> {
59 let url = self.client.url(
60 &format!(
61 "/v1/companies/{}/admins",
62 crate::progenitor_support::encode_path(company_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 admin for the company.
78 *
79 * This function performs a `POST` to the `/v1/companies/{company_id}/admins` endpoint.
80 *
81 * This endpoint is in beta and intended for **[Gusto Embedded Payroll](https://gusto.com/embedded-payroll)** customers. Please [apply for early access](https://gusto-embedded-payroll.typeform.com/to/iomAQIj3?utm_source=docs) if you’d like to learn more and use it for production. Note, this endpoint will require you to enter a different agreement with Gusto.
82 *
83 * Creates a new admin for a company. If the email matches an existing user, this will create an admin account for the current user. Otherwise, this will create a new user.
84 */
85 pub async fn post_company_admin(
86 &self,
87 company_id: &str,
88 body: &crate::types::PostCompanyAdminsRequest,
89 ) -> ClientResult<crate::Response<crate::types::Admin>> {
90 let url = self.client.url(
91 &format!(
92 "/v1/companies/{}/admins",
93 crate::progenitor_support::encode_path(company_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}