printnanny_api_client/apis/
demos_api.rs1use reqwest;
13
14use bytes::Bytes;
15use crate::apis::ResponseContent;
16use super::{Error, configuration};
17
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
21#[serde(untagged)]
22pub enum DemosCreateError {
23 Status409(crate::models::ErrorDetail),
24 Status400(crate::models::ErrorDetail),
25 Status401(crate::models::ErrorDetail),
26 Status403(crate::models::ErrorDetail),
27 Status500(crate::models::ErrorDetail),
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum DemosFeedbackPartialUpdateError {
35 Status409(crate::models::ErrorDetail),
36 Status400(crate::models::ErrorDetail),
37 Status401(crate::models::ErrorDetail),
38 Status403(crate::models::ErrorDetail),
39 Status500(crate::models::ErrorDetail),
40 UnknownValue(serde_json::Value),
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum DemosFeedbackRetrieveError {
47 UnknownValue(serde_json::Value),
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum DemosFeedbackUpdateError {
54 Status409(crate::models::ErrorDetail),
55 Status400(crate::models::ErrorDetail),
56 Status401(crate::models::ErrorDetail),
57 Status403(crate::models::ErrorDetail),
58 Status500(crate::models::ErrorDetail),
59 UnknownValue(serde_json::Value),
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(untagged)]
65pub enum DemosRetrieveError {
66 Status404(crate::models::ErrorDetail),
67 Status400(crate::models::ErrorDetail),
68 Status401(crate::models::ErrorDetail),
69 Status403(crate::models::ErrorDetail),
70 Status500(crate::models::ErrorDetail),
71 UnknownValue(serde_json::Value),
72}
73
74
75pub async fn demos_create(configuration: &configuration::Configuration, email: &str, submission: std::path::PathBuf) -> Result<crate::models::DemoSubmission, Error<DemosCreateError>> {
76 let local_var_configuration = configuration;
77
78 let local_var_client = &local_var_configuration.client;
79
80 let local_var_uri_str = format!("{}/api/demos/", local_var_configuration.base_path);
81 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
82
83 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
84 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
85 }
86 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
87 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
88 };
89 let mut local_var_form = reqwest::multipart::Form::new();
90 local_var_form = local_var_form.text("email", email.to_string());
91 let local_var_param_value = submission;
92 let kind = infer::get_from_path(&local_var_param_value)?.map(|v| v.mime_type().to_string()).unwrap_or_else(|| "application/octet-stream".to_string());
93 let filebytes = tokio::fs::read(&local_var_param_value).await?;
94 let file_part = reqwest::multipart::Part::bytes(filebytes)
95 .file_name(local_var_param_value.display().to_string())
96 .mime_str(&kind)?;
97 local_var_form = local_var_form.part("submission", file_part);
98 local_var_req_builder = local_var_req_builder.multipart(local_var_form);
99
100 let local_var_req = local_var_req_builder.build()?;
101 let local_var_resp = local_var_client.execute(local_var_req).await?;
102
103 let local_var_status = local_var_resp.status();
104 let local_var_content = local_var_resp.text().await?;
105
106 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
107 serde_json::from_str(&local_var_content).map_err(Error::from)
108 } else {
109 let local_var_entity: Option<DemosCreateError> = serde_json::from_str(&local_var_content).ok();
110 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
111 Err(Error::ResponseError(local_var_error))
112 }
113}
114
115pub async fn demos_feedback_partial_update(configuration: &configuration::Configuration, id: &str, patched_demo_submission_feedback_request: Option<crate::models::PatchedDemoSubmissionFeedbackRequest>) -> Result<crate::models::DemoSubmission, Error<DemosFeedbackPartialUpdateError>> {
116 let local_var_configuration = configuration;
117
118 let local_var_client = &local_var_configuration.client;
119
120 let local_var_uri_str = format!("{}/api/demos/feedback/{id}/", local_var_configuration.base_path, id=crate::apis::urlencode(id));
121 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
122
123 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
124 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
125 }
126 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
127 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
128 };
129 local_var_req_builder = local_var_req_builder.json(&patched_demo_submission_feedback_request);
130
131 let local_var_req = local_var_req_builder.build()?;
132 let local_var_resp = local_var_client.execute(local_var_req).await?;
133
134 let local_var_status = local_var_resp.status();
135 let local_var_content = local_var_resp.text().await?;
136
137 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
138 serde_json::from_str(&local_var_content).map_err(Error::from)
139 } else {
140 let local_var_entity: Option<DemosFeedbackPartialUpdateError> = serde_json::from_str(&local_var_content).ok();
141 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
142 Err(Error::ResponseError(local_var_error))
143 }
144}
145
146pub async fn demos_feedback_retrieve(configuration: &configuration::Configuration, id: &str) -> Result<crate::models::DemoSubmission, Error<DemosFeedbackRetrieveError>> {
147 let local_var_configuration = configuration;
148
149 let local_var_client = &local_var_configuration.client;
150
151 let local_var_uri_str = format!("{}/api/demos/feedback/{id}/", local_var_configuration.base_path, id=crate::apis::urlencode(id));
152 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
153
154 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
155 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
156 }
157 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
158 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
159 };
160
161 let local_var_req = local_var_req_builder.build()?;
162 let local_var_resp = local_var_client.execute(local_var_req).await?;
163
164 let local_var_status = local_var_resp.status();
165 let local_var_content = local_var_resp.text().await?;
166
167 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
168 serde_json::from_str(&local_var_content).map_err(Error::from)
169 } else {
170 let local_var_entity: Option<DemosFeedbackRetrieveError> = serde_json::from_str(&local_var_content).ok();
171 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
172 Err(Error::ResponseError(local_var_error))
173 }
174}
175
176pub async fn demos_feedback_update(configuration: &configuration::Configuration, id: &str, demo_submission_feedback_request: Option<crate::models::DemoSubmissionFeedbackRequest>) -> Result<crate::models::DemoSubmission, Error<DemosFeedbackUpdateError>> {
177 let local_var_configuration = configuration;
178
179 let local_var_client = &local_var_configuration.client;
180
181 let local_var_uri_str = format!("{}/api/demos/feedback/{id}/", local_var_configuration.base_path, id=crate::apis::urlencode(id));
182 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
183
184 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
185 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
186 }
187 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
188 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
189 };
190 local_var_req_builder = local_var_req_builder.json(&demo_submission_feedback_request);
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<DemosFeedbackUpdateError> = 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 demos_retrieve(configuration: &configuration::Configuration, id: &str) -> Result<crate::models::DemoSubmission, Error<DemosRetrieveError>> {
208 let local_var_configuration = configuration;
209
210 let local_var_client = &local_var_configuration.client;
211
212 let local_var_uri_str = format!("{}/api/demos/{id}/", local_var_configuration.base_path, id=crate::apis::urlencode(id));
213 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, 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(ref local_var_token) = local_var_configuration.bearer_access_token {
219 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
220 };
221
222 let local_var_req = local_var_req_builder.build()?;
223 let local_var_resp = local_var_client.execute(local_var_req).await?;
224
225 let local_var_status = local_var_resp.status();
226 let local_var_content = local_var_resp.text().await?;
227
228 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
229 serde_json::from_str(&local_var_content).map_err(Error::from)
230 } else {
231 let local_var_entity: Option<DemosRetrieveError> = serde_json::from_str(&local_var_content).ok();
232 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
233 Err(Error::ResponseError(local_var_error))
234 }
235}
236