1use crate::Client;
2use crate::ClientResult;
3
4pub struct Contractors {
5 pub client: Client,
6}
7
8impl Contractors {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 Contractors { client }
12 }
13
14 pub async fn get(
22 &self,
23 contractor_id_or_uuid: &str,
24 ) -> ClientResult<crate::Response<crate::types::Contractor>> {
25 let url = self.client.url(
26 &format!(
27 "/v1/contractors/{}",
28 crate::progenitor_support::encode_path(contractor_id_or_uuid),
29 ),
30 None,
31 );
32 self.client
33 .get(
34 &url,
35 crate::Message {
36 body: None,
37 content_type: None,
38 },
39 )
40 .await
41 }
42 pub async fn put(
50 &self,
51 contractor_id_or_uuid: &str,
52 body: &crate::types::PutComntractorRequest,
53 ) -> ClientResult<crate::Response<crate::types::Contractor>> {
54 let url = self.client.url(
55 &format!(
56 "/v1/contractors/{}",
57 crate::progenitor_support::encode_path(contractor_id_or_uuid),
58 ),
59 None,
60 );
61 self.client
62 .put(
63 &url,
64 crate::Message {
65 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
66 content_type: Some("application/json".to_string()),
67 },
68 )
69 .await
70 }
71 pub async fn get_company(
79 &self,
80 company_id_or_uuid: &str,
81 ) -> ClientResult<crate::Response<Vec<crate::types::Contractor>>> {
82 let url = self.client.url(
83 &format!(
84 "/v1/companies/{}/contractors",
85 crate::progenitor_support::encode_path(company_id_or_uuid),
86 ),
87 None,
88 );
89 self.client
90 .get(
91 &url,
92 crate::Message {
93 body: None,
94 content_type: None,
95 },
96 )
97 .await
98 }
99 pub async fn get_all_company(
109 &self,
110 company_id_or_uuid: &str,
111 ) -> ClientResult<crate::Response<Vec<crate::types::Contractor>>> {
112 let url = self.client.url(
113 &format!(
114 "/v1/companies/{}/contractors",
115 crate::progenitor_support::encode_path(company_id_or_uuid),
116 ),
117 None,
118 );
119 self.client
120 .get_all_pages(
121 &url,
122 crate::Message {
123 body: None,
124 content_type: None,
125 },
126 )
127 .await
128 }
129 pub async fn post_company(
137 &self,
138 company_id_or_uuid: &str,
139 body: &crate::types::PostCompanyContractorsRequest,
140 ) -> ClientResult<crate::Response<crate::types::Contractor>> {
141 let url = self.client.url(
142 &format!(
143 "/v1/companies/{}/contractors",
144 crate::progenitor_support::encode_path(company_id_or_uuid),
145 ),
146 None,
147 );
148 self.client
149 .post(
150 &url,
151 crate::Message {
152 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
153 content_type: Some("application/json".to_string()),
154 },
155 )
156 .await
157 }
158}