ehelply/apis/
notes_api.rs

1/*
2 * eHelply SDK - 1.1.118
3 *
4 * eHelply SDK for SuperStack Services
5 *
6 * The version of the OpenAPI document: 1.1.118
7 * Contact: support@ehelply.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13
14use crate::apis::ResponseContent;
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`create_note`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateNoteError {
22    Status400(crate::models::GetAppointment403Response),
23    Status403(crate::models::GetAppointment403Response),
24    Status404(),
25    Status422(crate::models::HttpValidationError),
26    UnknownValue(serde_json::Value),
27}
28
29/// struct for typed errors of method [`delete_note`]
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum DeleteNoteError {
33    Status400(crate::models::GetAppointment403Response),
34    Status403(crate::models::GetAppointment403Response),
35    Status404(),
36    Status422(crate::models::HttpValidationError),
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`get_note`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum GetNoteError {
44    Status403(crate::models::GetAppointment403Response),
45    Status404(crate::models::GetAppointment403Response),
46    Status422(crate::models::HttpValidationError),
47    UnknownValue(serde_json::Value),
48}
49
50/// struct for typed errors of method [`update_note`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum UpdateNoteError {
54    Status400(crate::models::GetAppointment403Response),
55    Status403(crate::models::GetAppointment403Response),
56    Status404(crate::models::GetAppointment403Response),
57    Status422(crate::models::HttpValidationError),
58    UnknownValue(serde_json::Value),
59}
60
61
62pub async fn create_note(configuration: &configuration::Configuration, note_base: crate::models::NoteBase, x_access_token: Option<&str>, x_secret_token: Option<&str>, authorization: Option<&str>, ehelply_active_participant: Option<&str>, ehelply_project: Option<&str>, ehelply_data: Option<&str>) -> Result<crate::models::CreateNoteResponse, Error<CreateNoteError>> {
63    let local_var_configuration = configuration;
64
65    let local_var_client = &local_var_configuration.client;
66
67    let local_var_uri_str = format!("{}/notes/notes", local_var_configuration.base_path);
68    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
69
70    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
71        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
72    }
73    if let Some(local_var_param_value) = x_access_token {
74        local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_param_value.to_string());
75    }
76    if let Some(local_var_param_value) = x_secret_token {
77        local_var_req_builder = local_var_req_builder.header("x-secret-token", local_var_param_value.to_string());
78    }
79    if let Some(local_var_param_value) = authorization {
80        local_var_req_builder = local_var_req_builder.header("authorization", local_var_param_value.to_string());
81    }
82    if let Some(local_var_param_value) = ehelply_active_participant {
83        local_var_req_builder = local_var_req_builder.header("ehelply-active-participant", local_var_param_value.to_string());
84    }
85    if let Some(local_var_param_value) = ehelply_project {
86        local_var_req_builder = local_var_req_builder.header("ehelply-project", local_var_param_value.to_string());
87    }
88    if let Some(local_var_param_value) = ehelply_data {
89        local_var_req_builder = local_var_req_builder.header("ehelply-data", local_var_param_value.to_string());
90    }
91    local_var_req_builder = local_var_req_builder.json(&note_base);
92
93    let local_var_req = local_var_req_builder.build()?;
94    let local_var_resp = local_var_client.execute(local_var_req).await?;
95
96    let local_var_status = local_var_resp.status();
97    let local_var_content = local_var_resp.text().await?;
98
99    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
100        serde_json::from_str(&local_var_content).map_err(Error::from)
101    } else {
102        let local_var_entity: Option<CreateNoteError> = serde_json::from_str(&local_var_content).ok();
103        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
104        Err(Error::ResponseError(local_var_error))
105    }
106}
107
108pub async fn delete_note(configuration: &configuration::Configuration, note_id: &str, method: Option<&str>, x_access_token: Option<&str>, x_secret_token: Option<&str>, authorization: Option<&str>, ehelply_active_participant: Option<&str>, ehelply_project: Option<&str>, ehelply_data: Option<&str>) -> Result<crate::models::DeleteNote200Response, Error<DeleteNoteError>> {
109    let local_var_configuration = configuration;
110
111    let local_var_client = &local_var_configuration.client;
112
113    let local_var_uri_str = format!("{}/notes/notes/{note_id}", local_var_configuration.base_path, note_id=crate::apis::urlencode(note_id));
114    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
115
116    if let Some(ref local_var_str) = method {
117        local_var_req_builder = local_var_req_builder.query(&[("method", &local_var_str.to_string())]);
118    }
119    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
120        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
121    }
122    if let Some(local_var_param_value) = x_access_token {
123        local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_param_value.to_string());
124    }
125    if let Some(local_var_param_value) = x_secret_token {
126        local_var_req_builder = local_var_req_builder.header("x-secret-token", local_var_param_value.to_string());
127    }
128    if let Some(local_var_param_value) = authorization {
129        local_var_req_builder = local_var_req_builder.header("authorization", local_var_param_value.to_string());
130    }
131    if let Some(local_var_param_value) = ehelply_active_participant {
132        local_var_req_builder = local_var_req_builder.header("ehelply-active-participant", local_var_param_value.to_string());
133    }
134    if let Some(local_var_param_value) = ehelply_project {
135        local_var_req_builder = local_var_req_builder.header("ehelply-project", local_var_param_value.to_string());
136    }
137    if let Some(local_var_param_value) = ehelply_data {
138        local_var_req_builder = local_var_req_builder.header("ehelply-data", local_var_param_value.to_string());
139    }
140
141    let local_var_req = local_var_req_builder.build()?;
142    let local_var_resp = local_var_client.execute(local_var_req).await?;
143
144    let local_var_status = local_var_resp.status();
145    let local_var_content = local_var_resp.text().await?;
146
147    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
148        serde_json::from_str(&local_var_content).map_err(Error::from)
149    } else {
150        let local_var_entity: Option<DeleteNoteError> = serde_json::from_str(&local_var_content).ok();
151        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
152        Err(Error::ResponseError(local_var_error))
153    }
154}
155
156pub async fn get_note(configuration: &configuration::Configuration, note_id: &str, history: Option<i32>, history_content: Option<bool>, x_access_token: Option<&str>, x_secret_token: Option<&str>, authorization: Option<&str>, ehelply_active_participant: Option<&str>, ehelply_project: Option<&str>, ehelply_data: Option<&str>) -> Result<crate::models::NoteDynamoHistoryResponse, Error<GetNoteError>> {
157    let local_var_configuration = configuration;
158
159    let local_var_client = &local_var_configuration.client;
160
161    let local_var_uri_str = format!("{}/notes/notes/{note_id}", local_var_configuration.base_path, note_id=crate::apis::urlencode(note_id));
162    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
163
164    if let Some(ref local_var_str) = history {
165        local_var_req_builder = local_var_req_builder.query(&[("history", &local_var_str.to_string())]);
166    }
167    if let Some(ref local_var_str) = history_content {
168        local_var_req_builder = local_var_req_builder.query(&[("history_content", &local_var_str.to_string())]);
169    }
170    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
171        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
172    }
173    if let Some(local_var_param_value) = x_access_token {
174        local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_param_value.to_string());
175    }
176    if let Some(local_var_param_value) = x_secret_token {
177        local_var_req_builder = local_var_req_builder.header("x-secret-token", local_var_param_value.to_string());
178    }
179    if let Some(local_var_param_value) = authorization {
180        local_var_req_builder = local_var_req_builder.header("authorization", local_var_param_value.to_string());
181    }
182    if let Some(local_var_param_value) = ehelply_active_participant {
183        local_var_req_builder = local_var_req_builder.header("ehelply-active-participant", local_var_param_value.to_string());
184    }
185    if let Some(local_var_param_value) = ehelply_project {
186        local_var_req_builder = local_var_req_builder.header("ehelply-project", local_var_param_value.to_string());
187    }
188    if let Some(local_var_param_value) = ehelply_data {
189        local_var_req_builder = local_var_req_builder.header("ehelply-data", local_var_param_value.to_string());
190    }
191
192    let local_var_req = local_var_req_builder.build()?;
193    let local_var_resp = local_var_client.execute(local_var_req).await?;
194
195    let local_var_status = local_var_resp.status();
196    let local_var_content = local_var_resp.text().await?;
197
198    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
199        serde_json::from_str(&local_var_content).map_err(Error::from)
200    } else {
201        let local_var_entity: Option<GetNoteError> = serde_json::from_str(&local_var_content).ok();
202        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
203        Err(Error::ResponseError(local_var_error))
204    }
205}
206
207pub async fn update_note(configuration: &configuration::Configuration, note_id: &str, note_base: crate::models::NoteBase, x_access_token: Option<&str>, x_secret_token: Option<&str>, authorization: Option<&str>, ehelply_active_participant: Option<&str>, ehelply_project: Option<&str>, ehelply_data: Option<&str>) -> Result<crate::models::UpdateNote200Response, Error<UpdateNoteError>> {
208    let local_var_configuration = configuration;
209
210    let local_var_client = &local_var_configuration.client;
211
212    let local_var_uri_str = format!("{}/notes/notes/{note_id}", local_var_configuration.base_path, note_id=crate::apis::urlencode(note_id));
213    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
214
215    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
216        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
217    }
218    if let Some(local_var_param_value) = x_access_token {
219        local_var_req_builder = local_var_req_builder.header("x-access-token", local_var_param_value.to_string());
220    }
221    if let Some(local_var_param_value) = x_secret_token {
222        local_var_req_builder = local_var_req_builder.header("x-secret-token", local_var_param_value.to_string());
223    }
224    if let Some(local_var_param_value) = authorization {
225        local_var_req_builder = local_var_req_builder.header("authorization", local_var_param_value.to_string());
226    }
227    if let Some(local_var_param_value) = ehelply_active_participant {
228        local_var_req_builder = local_var_req_builder.header("ehelply-active-participant", local_var_param_value.to_string());
229    }
230    if let Some(local_var_param_value) = ehelply_project {
231        local_var_req_builder = local_var_req_builder.header("ehelply-project", local_var_param_value.to_string());
232    }
233    if let Some(local_var_param_value) = ehelply_data {
234        local_var_req_builder = local_var_req_builder.header("ehelply-data", local_var_param_value.to_string());
235    }
236    local_var_req_builder = local_var_req_builder.json(&note_base);
237
238    let local_var_req = local_var_req_builder.build()?;
239    let local_var_resp = local_var_client.execute(local_var_req).await?;
240
241    let local_var_status = local_var_resp.status();
242    let local_var_content = local_var_resp.text().await?;
243
244    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
245        serde_json::from_str(&local_var_content).map_err(Error::from)
246    } else {
247        let local_var_entity: Option<UpdateNoteError> = serde_json::from_str(&local_var_content).ok();
248        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
249        Err(Error::ResponseError(local_var_error))
250    }
251}
252