1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum Get1Error {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum MeError {
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum Save1Error {
34 UnknownValue(serde_json::Value),
35}
36
37pub async fn get1(
38 configuration: &configuration::Configuration,
39) -> Result<models::PersonalInfo, Error<Get1Error>> {
40 let uri_str = format!("{}/api/personal-info", configuration.base_path);
41 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
42
43 if let Some(ref user_agent) = configuration.user_agent {
44 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
45 }
46 if let Some(ref token) = configuration.bearer_access_token {
47 req_builder = req_builder.bearer_auth(token.to_owned());
48 };
49
50 let req = req_builder.build()?;
51 let resp = configuration.client.execute(req).await?;
52
53 let status = resp.status();
54 let content_type = resp
55 .headers()
56 .get("content-type")
57 .and_then(|v| v.to_str().ok())
58 .unwrap_or("application/octet-stream");
59 let content_type = super::ContentType::from(content_type);
60
61 if !status.is_client_error() && !status.is_server_error() {
62 let content = resp.text().await?;
63 match content_type {
64 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
65 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PersonalInfo`"))),
66 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PersonalInfo`")))),
67 }
68 } else {
69 let content = resp.text().await?;
70 let entity: Option<Get1Error> = serde_json::from_str(&content).ok();
71 Err(Error::ResponseError(ResponseContent {
72 status,
73 content,
74 entity,
75 }))
76 }
77}
78
79pub async fn me(
80 configuration: &configuration::Configuration,
81) -> Result<models::User, Error<MeError>> {
82 let uri_str = format!("{}/api/personal-info/@me", configuration.base_path);
83 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
84
85 if let Some(ref user_agent) = configuration.user_agent {
86 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
87 }
88 if let Some(ref token) = configuration.bearer_access_token {
89 req_builder = req_builder.bearer_auth(token.to_owned());
90 };
91
92 let req = req_builder.build()?;
93 let resp = configuration.client.execute(req).await?;
94
95 let status = resp.status();
96 let content_type = resp
97 .headers()
98 .get("content-type")
99 .and_then(|v| v.to_str().ok())
100 .unwrap_or("application/octet-stream");
101 let content_type = super::ContentType::from(content_type);
102
103 if !status.is_client_error() && !status.is_server_error() {
104 let content = resp.text().await?;
105 match content_type {
106 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
107 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::User`"))),
108 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::User`")))),
109 }
110 } else {
111 let content = resp.text().await?;
112 let entity: Option<MeError> = serde_json::from_str(&content).ok();
113 Err(Error::ResponseError(ResponseContent {
114 status,
115 content,
116 entity,
117 }))
118 }
119}
120
121pub async fn save1(
122 configuration: &configuration::Configuration,
123 ceo_full_name: &str,
124 note: &str,
125 organization_address: &str,
126 demo_mode: bool,
127 finance_charge: f64,
128 organization_city: &str,
129 organization_name: &str,
130 organization_bank_account: &str,
131 organization_bank_bic: &str,
132 organization_email_address: &str,
133 organization_post_code: &str,
134 country_code: &str,
135 max_days_to_pay: i32,
136 organization_phone_number: &str,
137 accountants: &str,
138 vat_number: &str,
139 signature: Option<std::path::PathBuf>,
140 logo: Option<std::path::PathBuf>,
141 initial: Option<std::path::PathBuf>,
142) -> Result<models::PersonalInfo, Error<Save1Error>> {
143 let p_query_ceo_full_name = ceo_full_name;
145 let p_query_note = note;
146 let p_query_organization_address = organization_address;
147 let p_query_demo_mode = demo_mode;
148 let p_query_finance_charge = finance_charge;
149 let p_query_organization_city = organization_city;
150 let p_query_organization_name = organization_name;
151 let p_query_organization_bank_account = organization_bank_account;
152 let p_query_organization_bank_bic = organization_bank_bic;
153 let p_query_organization_email_address = organization_email_address;
154 let p_query_organization_post_code = organization_post_code;
155 let p_query_country_code = country_code;
156 let p_query_max_days_to_pay = max_days_to_pay;
157 let p_query_organization_phone_number = organization_phone_number;
158 let p_query_accountants = accountants;
159 let p_query_vat_number = vat_number;
160 let p_form_signature = signature;
161 let p_form_logo = logo;
162 let p_form_initial = initial;
163
164 let uri_str = format!("{}/api/personal-info/submit", configuration.base_path);
165 let mut req_builder = configuration
166 .client
167 .request(reqwest::Method::POST, &uri_str);
168
169 req_builder = req_builder.query(&[("ceoFullName", &p_query_ceo_full_name.to_string())]);
170 req_builder = req_builder.query(&[("note", &p_query_note.to_string())]);
171 req_builder = req_builder.query(&[(
172 "organizationAddress",
173 &p_query_organization_address.to_string(),
174 )]);
175 req_builder = req_builder.query(&[("demoMode", &p_query_demo_mode.to_string())]);
176 req_builder = req_builder.query(&[("financeCharge", &p_query_finance_charge.to_string())]);
177 req_builder =
178 req_builder.query(&[("organizationCity", &p_query_organization_city.to_string())]);
179 req_builder =
180 req_builder.query(&[("organizationName", &p_query_organization_name.to_string())]);
181 req_builder = req_builder.query(&[(
182 "organizationBankAccount",
183 &p_query_organization_bank_account.to_string(),
184 )]);
185 req_builder = req_builder.query(&[(
186 "organizationBankBIC",
187 &p_query_organization_bank_bic.to_string(),
188 )]);
189 req_builder = req_builder.query(&[(
190 "organizationEmailAddress",
191 &p_query_organization_email_address.to_string(),
192 )]);
193 req_builder = req_builder.query(&[(
194 "organizationPostCode",
195 &p_query_organization_post_code.to_string(),
196 )]);
197 req_builder = req_builder.query(&[("countryCode", &p_query_country_code.to_string())]);
198 req_builder = req_builder.query(&[("maxDaysToPay", &p_query_max_days_to_pay.to_string())]);
199 req_builder = req_builder.query(&[(
200 "organizationPhoneNumber",
201 &p_query_organization_phone_number.to_string(),
202 )]);
203 req_builder = req_builder.query(&[("accountants", &p_query_accountants.to_string())]);
204 req_builder = req_builder.query(&[("vatNumber", &p_query_vat_number.to_string())]);
205 if let Some(ref user_agent) = configuration.user_agent {
206 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
207 }
208 if let Some(ref token) = configuration.bearer_access_token {
209 req_builder = req_builder.bearer_auth(token.to_owned());
210 };
211 let multipart_form = reqwest::multipart::Form::new();
212 req_builder = req_builder.multipart(multipart_form);
216
217 let req = req_builder.build()?;
218 let resp = configuration.client.execute(req).await?;
219
220 let status = resp.status();
221 let content_type = resp
222 .headers()
223 .get("content-type")
224 .and_then(|v| v.to_str().ok())
225 .unwrap_or("application/octet-stream");
226 let content_type = super::ContentType::from(content_type);
227
228 if !status.is_client_error() && !status.is_server_error() {
229 let content = resp.text().await?;
230 match content_type {
231 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
232 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PersonalInfo`"))),
233 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PersonalInfo`")))),
234 }
235 } else {
236 let content = resp.text().await?;
237 let entity: Option<Save1Error> = serde_json::from_str(&content).ok();
238 Err(Error::ResponseError(ResponseContent {
239 status,
240 content,
241 entity,
242 }))
243 }
244}