1#![allow(unused_imports, clippy::too_many_arguments)]
6
7use reqwest::Method;
8use serde::{Deserialize, Serialize};
9
10use crate::client::{Client, Request, NO_BODY, NO_QUERY};
11use crate::error::Result;
12use crate::generated::models;
13use crate::multipart::{field_text, FilePart};
14use crate::util::encode_path;
15
16#[derive(Debug, Clone)]
18pub struct CompaniesApi {
19 pub(crate) client: Client,
20}
21
22impl Client {
23 pub fn companies(&self) -> CompaniesApi {
25 CompaniesApi { client: self.clone() }
26 }
27}
28
29impl CompaniesApi {
30 pub async fn create(&self, body: &models::CompanyCreate) -> Result<models::Company> {
36 self.client
37 .request_json(Request {
38 method: Method::POST,
39 path: "/api/v1/companies".to_string(),
40 query: NO_QUERY,
41 body: Some(body),
42 headers: Vec::new(),
43 idempotent: true,
44 })
45 .await
46 }
47
48 pub async fn delete(&self, id: &str) -> Result<models::DeleteCompanyResponse> {
54 self.client
55 .request_json(Request {
56 method: Method::DELETE,
57 path: format!("/api/v1/companies/{}", encode_path(id)),
58 query: NO_QUERY,
59 body: NO_BODY,
60 headers: Vec::new(),
61 idempotent: true,
62 })
63 .await
64 }
65
66 pub async fn get(&self, id: &str) -> Result<models::Company> {
72 self.client
73 .request_json(Request {
74 method: Method::GET,
75 path: format!("/api/v1/companies/{}", encode_path(id)),
76 query: NO_QUERY,
77 body: NO_BODY,
78 headers: Vec::new(),
79 idempotent: false,
80 })
81 .await
82 }
83
84 pub async fn get_company_activity(&self, company_id: &str) -> Result<models::GetCompanyActivityResponse> {
90 self.client
91 .request_json(Request {
92 method: Method::GET,
93 path: format!("/api/v1/companies/{}/activity", encode_path(company_id)),
94 query: NO_QUERY,
95 body: NO_BODY,
96 headers: Vec::new(),
97 idempotent: false,
98 })
99 .await
100 }
101
102 pub async fn get_company_budget(&self, company_id: &str) -> Result<models::GetCompanyBudgetResponse> {
108 self.client
109 .request_json(Request {
110 method: Method::GET,
111 path: format!("/api/v1/companies/{}/budget", encode_path(company_id)),
112 query: NO_QUERY,
113 body: NO_BODY,
114 headers: Vec::new(),
115 idempotent: false,
116 })
117 .await
118 }
119
120 pub async fn get_company_objectives(&self, company_id: &str) -> Result<models::GetCompanyObjectivesResponse> {
126 self.client
127 .request_json(Request {
128 method: Method::GET,
129 path: format!("/api/v1/companies/{}/objectives", encode_path(company_id)),
130 query: NO_QUERY,
131 body: NO_BODY,
132 headers: Vec::new(),
133 idempotent: false,
134 })
135 .await
136 }
137
138 pub async fn list(&self) -> Result<models::ListCompaniesResponse> {
144 self.client
145 .request_json(Request {
146 method: Method::GET,
147 path: "/api/v1/companies".to_string(),
148 query: NO_QUERY,
149 body: NO_BODY,
150 headers: Vec::new(),
151 idempotent: false,
152 })
153 .await
154 }
155
156 pub async fn pause_company(&self, company_id: &str) -> Result<models::PauseCompanyResponse> {
162 self.client
163 .request_json(Request {
164 method: Method::POST,
165 path: format!("/api/v1/companies/{}/pause", encode_path(company_id)),
166 query: NO_QUERY,
167 body: NO_BODY,
168 headers: Vec::new(),
169 idempotent: true,
170 })
171 .await
172 }
173
174 pub async fn resume(&self, company_id: &str) -> Result<models::ResumeCompanyResponse> {
180 self.client
181 .request_json(Request {
182 method: Method::POST,
183 path: format!("/api/v1/companies/{}/resume", encode_path(company_id)),
184 query: NO_QUERY,
185 body: NO_BODY,
186 headers: Vec::new(),
187 idempotent: true,
188 })
189 .await
190 }
191
192 pub async fn update(&self, id: &str, body: &models::CompanyUpdate) -> Result<models::Company> {
198 self.client
199 .request_json(Request {
200 method: Method::PUT,
201 path: format!("/api/v1/companies/{}", encode_path(id)),
202 query: NO_QUERY,
203 body: Some(body),
204 headers: Vec::new(),
205 idempotent: true,
206 })
207 .await
208 }
209}