metaculus/apis/
comments_api.rs

1/*
2 * Metaculus API
3 *
4 * Welcome to the unofficial Rust client for the Metaculus API
5 *
6 * The version of the OpenAPI document: 1.0
7 * Contact: Benjamin Manns <opensource@benmanns.com>
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12
13use super::{configuration, Error};
14use crate::apis::ResponseContent;
15
16/// struct for passing parameters to the method [`comments_create`]
17#[derive(Clone, Debug)]
18pub struct CommentsCreateParams {
19    pub comment: crate::models::Comment,
20}
21
22/// struct for passing parameters to the method [`comments_destroy`]
23#[derive(Clone, Debug)]
24pub struct CommentsDestroyParams {
25    /// A unique integer value identifying this comment.
26    pub id: i32,
27}
28
29/// struct for passing parameters to the method [`comments_like_create`]
30#[derive(Clone, Debug)]
31pub struct CommentsLikeCreateParams {
32    /// A unique integer value identifying this comment.
33    pub id: i32,
34    pub comment: crate::models::Comment,
35}
36
37/// struct for passing parameters to the method [`comments_list`]
38#[derive(Clone, Debug)]
39pub struct CommentsListParams {
40    pub author: Option<i32>,
41    pub created_time__gt: Option<String>,
42    pub created_time__lt: Option<String>,
43    /// The pagination cursor value.
44    pub cursor: Option<String>,
45    pub id: Option<i32>,
46    /// Number of results to return per page.
47    pub limit: Option<i32>,
48    /// Which field to use when ordering the results.
49    pub order_by: Option<String>,
50    pub question: Option<i32>,
51}
52
53/// struct for passing parameters to the method [`comments_partial_update`]
54#[derive(Clone, Debug)]
55pub struct CommentsPartialUpdateParams {
56    /// A unique integer value identifying this comment.
57    pub id: i32,
58    pub patched_comment_update: Option<crate::models::PatchedCommentUpdate>,
59}
60
61/// struct for passing parameters to the method [`comments_report_create`]
62#[derive(Clone, Debug)]
63pub struct CommentsReportCreateParams {
64    /// A unique integer value identifying this comment.
65    pub id: i32,
66    pub comment: crate::models::Comment,
67}
68
69/// struct for passing parameters to the method [`comments_retrieve`]
70#[derive(Clone, Debug)]
71pub struct CommentsRetrieveParams {
72    /// A unique integer value identifying this comment.
73    pub id: i32,
74}
75
76/// struct for passing parameters to the method [`comments_update`]
77#[derive(Clone, Debug)]
78pub struct CommentsUpdateParams {
79    /// A unique integer value identifying this comment.
80    pub id: i32,
81    pub comment_update: crate::models::CommentUpdate,
82}
83
84/// struct for typed errors of method [`comments_create`]
85#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum CommentsCreateError {
88    UnknownValue(serde_json::Value),
89}
90
91/// struct for typed errors of method [`comments_destroy`]
92#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum CommentsDestroyError {
95    UnknownValue(serde_json::Value),
96}
97
98/// struct for typed errors of method [`comments_like_create`]
99#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum CommentsLikeCreateError {
102    UnknownValue(serde_json::Value),
103}
104
105/// struct for typed errors of method [`comments_list`]
106#[derive(Debug, Clone, Serialize, Deserialize)]
107#[serde(untagged)]
108pub enum CommentsListError {
109    UnknownValue(serde_json::Value),
110}
111
112/// struct for typed errors of method [`comments_partial_update`]
113#[derive(Debug, Clone, Serialize, Deserialize)]
114#[serde(untagged)]
115pub enum CommentsPartialUpdateError {
116    UnknownValue(serde_json::Value),
117}
118
119/// struct for typed errors of method [`comments_report_create`]
120#[derive(Debug, Clone, Serialize, Deserialize)]
121#[serde(untagged)]
122pub enum CommentsReportCreateError {
123    UnknownValue(serde_json::Value),
124}
125
126/// struct for typed errors of method [`comments_retrieve`]
127#[derive(Debug, Clone, Serialize, Deserialize)]
128#[serde(untagged)]
129pub enum CommentsRetrieveError {
130    UnknownValue(serde_json::Value),
131}
132
133/// struct for typed errors of method [`comments_update`]
134#[derive(Debug, Clone, Serialize, Deserialize)]
135#[serde(untagged)]
136pub enum CommentsUpdateError {
137    UnknownValue(serde_json::Value),
138}
139
140pub async fn comments_create(
141    configuration: &configuration::Configuration,
142    params: CommentsCreateParams,
143) -> Result<crate::models::Comment, Error<CommentsCreateError>> {
144    let local_var_configuration = configuration;
145
146    // unbox the parameters
147    let comment = params.comment;
148
149    let local_var_client = &local_var_configuration.client;
150
151    let local_var_uri_str = format!("{}/api2/comments/", local_var_configuration.base_path);
152    let mut local_var_req_builder =
153        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
154
155    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
156        local_var_req_builder =
157            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
158    }
159    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
160        local_var_req_builder = local_var_req_builder
161            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
162    };
163    if let Some(ref local_var_cookie) = local_var_configuration.cookie {
164        local_var_req_builder =
165            local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
166    };
167    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
168        let local_var_key = local_var_apikey.key.clone();
169        let local_var_value = match local_var_apikey.prefix {
170            Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
171            None => local_var_key,
172        };
173        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
174    };
175    local_var_req_builder = local_var_req_builder.json(&comment);
176
177    let local_var_req = local_var_req_builder.build()?;
178    let local_var_resp = local_var_client.execute(local_var_req).await?;
179
180    let local_var_status = local_var_resp.status();
181    let local_var_content = local_var_resp.text().await?;
182
183    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
184        serde_json::from_str(&local_var_content).map_err(Error::from)
185    } else {
186        let local_var_entity: Option<CommentsCreateError> =
187            serde_json::from_str(&local_var_content).ok();
188        let local_var_error = ResponseContent {
189            status: local_var_status,
190            content: local_var_content,
191            entity: local_var_entity,
192        };
193        Err(Error::ResponseError(local_var_error))
194    }
195}
196
197pub async fn comments_destroy(
198    configuration: &configuration::Configuration,
199    params: CommentsDestroyParams,
200) -> Result<(), Error<CommentsDestroyError>> {
201    let local_var_configuration = configuration;
202
203    // unbox the parameters
204    let id = params.id;
205
206    let local_var_client = &local_var_configuration.client;
207
208    let local_var_uri_str = format!(
209        "{}/api2/comments/{id}/",
210        local_var_configuration.base_path,
211        id = id
212    );
213    let mut local_var_req_builder =
214        local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
215
216    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
217        local_var_req_builder =
218            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
219    }
220    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
221        local_var_req_builder = local_var_req_builder
222            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
223    };
224    if let Some(ref local_var_cookie) = local_var_configuration.cookie {
225        local_var_req_builder =
226            local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
227    };
228    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
229        let local_var_key = local_var_apikey.key.clone();
230        let local_var_value = match local_var_apikey.prefix {
231            Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
232            None => local_var_key,
233        };
234        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
235    };
236
237    let local_var_req = local_var_req_builder.build()?;
238    let local_var_resp = local_var_client.execute(local_var_req).await?;
239
240    let local_var_status = local_var_resp.status();
241    let local_var_content = local_var_resp.text().await?;
242
243    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
244        Ok(())
245    } else {
246        let local_var_entity: Option<CommentsDestroyError> =
247            serde_json::from_str(&local_var_content).ok();
248        let local_var_error = ResponseContent {
249            status: local_var_status,
250            content: local_var_content,
251            entity: local_var_entity,
252        };
253        Err(Error::ResponseError(local_var_error))
254    }
255}
256
257pub async fn comments_like_create(
258    configuration: &configuration::Configuration,
259    params: CommentsLikeCreateParams,
260) -> Result<crate::models::Comment, Error<CommentsLikeCreateError>> {
261    let local_var_configuration = configuration;
262
263    // unbox the parameters
264    let id = params.id;
265    let comment = params.comment;
266
267    let local_var_client = &local_var_configuration.client;
268
269    let local_var_uri_str = format!(
270        "{}/api2/comments/{id}/like/",
271        local_var_configuration.base_path,
272        id = id
273    );
274    let mut local_var_req_builder =
275        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
276
277    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
278        local_var_req_builder =
279            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
280    }
281    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
282        local_var_req_builder = local_var_req_builder
283            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
284    };
285    if let Some(ref local_var_cookie) = local_var_configuration.cookie {
286        local_var_req_builder =
287            local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
288    };
289    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
290        let local_var_key = local_var_apikey.key.clone();
291        let local_var_value = match local_var_apikey.prefix {
292            Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
293            None => local_var_key,
294        };
295        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
296    };
297    local_var_req_builder = local_var_req_builder.json(&comment);
298
299    let local_var_req = local_var_req_builder.build()?;
300    let local_var_resp = local_var_client.execute(local_var_req).await?;
301
302    let local_var_status = local_var_resp.status();
303    let local_var_content = local_var_resp.text().await?;
304
305    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
306        serde_json::from_str(&local_var_content).map_err(Error::from)
307    } else {
308        let local_var_entity: Option<CommentsLikeCreateError> =
309            serde_json::from_str(&local_var_content).ok();
310        let local_var_error = ResponseContent {
311            status: local_var_status,
312            content: local_var_content,
313            entity: local_var_entity,
314        };
315        Err(Error::ResponseError(local_var_error))
316    }
317}
318
319pub async fn comments_list(
320    configuration: &configuration::Configuration,
321    params: CommentsListParams,
322) -> Result<crate::models::PaginatedCommentList, Error<CommentsListError>> {
323    let local_var_configuration = configuration;
324
325    // unbox the parameters
326    let author = params.author;
327    let created_time__gt = params.created_time__gt;
328    let created_time__lt = params.created_time__lt;
329    let cursor = params.cursor;
330    let id = params.id;
331    let limit = params.limit;
332    let order_by = params.order_by;
333    let question = params.question;
334
335    let local_var_client = &local_var_configuration.client;
336
337    let local_var_uri_str = format!("{}/api2/comments/", local_var_configuration.base_path);
338    let mut local_var_req_builder =
339        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
340
341    if let Some(ref local_var_str) = author {
342        local_var_req_builder =
343            local_var_req_builder.query(&[("author", &local_var_str.to_string())]);
344    }
345    if let Some(ref local_var_str) = created_time__gt {
346        local_var_req_builder =
347            local_var_req_builder.query(&[("created_time__gt", &local_var_str.to_string())]);
348    }
349    if let Some(ref local_var_str) = created_time__lt {
350        local_var_req_builder =
351            local_var_req_builder.query(&[("created_time__lt", &local_var_str.to_string())]);
352    }
353    if let Some(ref local_var_str) = cursor {
354        local_var_req_builder =
355            local_var_req_builder.query(&[("cursor", &local_var_str.to_string())]);
356    }
357    if let Some(ref local_var_str) = id {
358        local_var_req_builder = local_var_req_builder.query(&[("id", &local_var_str.to_string())]);
359    }
360    if let Some(ref local_var_str) = limit {
361        local_var_req_builder =
362            local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
363    }
364    if let Some(ref local_var_str) = order_by {
365        local_var_req_builder =
366            local_var_req_builder.query(&[("order_by", &local_var_str.to_string())]);
367    }
368    if let Some(ref local_var_str) = question {
369        local_var_req_builder =
370            local_var_req_builder.query(&[("question", &local_var_str.to_string())]);
371    }
372    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
373        local_var_req_builder =
374            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
375    }
376    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
377        local_var_req_builder = local_var_req_builder
378            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
379    };
380    if let Some(ref local_var_cookie) = local_var_configuration.cookie {
381        local_var_req_builder =
382            local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
383    };
384    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
385        let local_var_key = local_var_apikey.key.clone();
386        let local_var_value = match local_var_apikey.prefix {
387            Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
388            None => local_var_key,
389        };
390        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
391    };
392
393    let local_var_req = local_var_req_builder.build()?;
394    let local_var_resp = local_var_client.execute(local_var_req).await?;
395
396    let local_var_status = local_var_resp.status();
397    let local_var_content = local_var_resp.text().await?;
398
399    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
400        serde_json::from_str(&local_var_content).map_err(Error::from)
401    } else {
402        let local_var_entity: Option<CommentsListError> =
403            serde_json::from_str(&local_var_content).ok();
404        let local_var_error = ResponseContent {
405            status: local_var_status,
406            content: local_var_content,
407            entity: local_var_entity,
408        };
409        Err(Error::ResponseError(local_var_error))
410    }
411}
412
413pub async fn comments_partial_update(
414    configuration: &configuration::Configuration,
415    params: CommentsPartialUpdateParams,
416) -> Result<crate::models::CommentUpdate, Error<CommentsPartialUpdateError>> {
417    let local_var_configuration = configuration;
418
419    // unbox the parameters
420    let id = params.id;
421    let patched_comment_update = params.patched_comment_update;
422
423    let local_var_client = &local_var_configuration.client;
424
425    let local_var_uri_str = format!(
426        "{}/api2/comments/{id}/",
427        local_var_configuration.base_path,
428        id = id
429    );
430    let mut local_var_req_builder =
431        local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
432
433    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
434        local_var_req_builder =
435            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
436    }
437    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
438        local_var_req_builder = local_var_req_builder
439            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
440    };
441    if let Some(ref local_var_cookie) = local_var_configuration.cookie {
442        local_var_req_builder =
443            local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
444    };
445    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
446        let local_var_key = local_var_apikey.key.clone();
447        let local_var_value = match local_var_apikey.prefix {
448            Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
449            None => local_var_key,
450        };
451        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
452    };
453    local_var_req_builder = local_var_req_builder.json(&patched_comment_update);
454
455    let local_var_req = local_var_req_builder.build()?;
456    let local_var_resp = local_var_client.execute(local_var_req).await?;
457
458    let local_var_status = local_var_resp.status();
459    let local_var_content = local_var_resp.text().await?;
460
461    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
462        serde_json::from_str(&local_var_content).map_err(Error::from)
463    } else {
464        let local_var_entity: Option<CommentsPartialUpdateError> =
465            serde_json::from_str(&local_var_content).ok();
466        let local_var_error = ResponseContent {
467            status: local_var_status,
468            content: local_var_content,
469            entity: local_var_entity,
470        };
471        Err(Error::ResponseError(local_var_error))
472    }
473}
474
475pub async fn comments_report_create(
476    configuration: &configuration::Configuration,
477    params: CommentsReportCreateParams,
478) -> Result<crate::models::Comment, Error<CommentsReportCreateError>> {
479    let local_var_configuration = configuration;
480
481    // unbox the parameters
482    let id = params.id;
483    let comment = params.comment;
484
485    let local_var_client = &local_var_configuration.client;
486
487    let local_var_uri_str = format!(
488        "{}/api2/comments/{id}/report/",
489        local_var_configuration.base_path,
490        id = id
491    );
492    let mut local_var_req_builder =
493        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
494
495    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
496        local_var_req_builder =
497            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
498    }
499    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
500        local_var_req_builder = local_var_req_builder
501            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
502    };
503    if let Some(ref local_var_cookie) = local_var_configuration.cookie {
504        local_var_req_builder =
505            local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
506    };
507    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
508        let local_var_key = local_var_apikey.key.clone();
509        let local_var_value = match local_var_apikey.prefix {
510            Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
511            None => local_var_key,
512        };
513        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
514    };
515    local_var_req_builder = local_var_req_builder.json(&comment);
516
517    let local_var_req = local_var_req_builder.build()?;
518    let local_var_resp = local_var_client.execute(local_var_req).await?;
519
520    let local_var_status = local_var_resp.status();
521    let local_var_content = local_var_resp.text().await?;
522
523    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
524        serde_json::from_str(&local_var_content).map_err(Error::from)
525    } else {
526        let local_var_entity: Option<CommentsReportCreateError> =
527            serde_json::from_str(&local_var_content).ok();
528        let local_var_error = ResponseContent {
529            status: local_var_status,
530            content: local_var_content,
531            entity: local_var_entity,
532        };
533        Err(Error::ResponseError(local_var_error))
534    }
535}
536
537pub async fn comments_retrieve(
538    configuration: &configuration::Configuration,
539    params: CommentsRetrieveParams,
540) -> Result<crate::models::CommentChildren, Error<CommentsRetrieveError>> {
541    let local_var_configuration = configuration;
542
543    // unbox the parameters
544    let id = params.id;
545
546    let local_var_client = &local_var_configuration.client;
547
548    let local_var_uri_str = format!(
549        "{}/api2/comments/{id}/",
550        local_var_configuration.base_path,
551        id = id
552    );
553    let mut local_var_req_builder =
554        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
555
556    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
557        local_var_req_builder =
558            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
559    }
560    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
561        local_var_req_builder = local_var_req_builder
562            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
563    };
564    if let Some(ref local_var_cookie) = local_var_configuration.cookie {
565        local_var_req_builder =
566            local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
567    };
568    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
569        let local_var_key = local_var_apikey.key.clone();
570        let local_var_value = match local_var_apikey.prefix {
571            Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
572            None => local_var_key,
573        };
574        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
575    };
576
577    let local_var_req = local_var_req_builder.build()?;
578    let local_var_resp = local_var_client.execute(local_var_req).await?;
579
580    let local_var_status = local_var_resp.status();
581    let local_var_content = local_var_resp.text().await?;
582
583    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
584        serde_json::from_str(&local_var_content).map_err(Error::from)
585    } else {
586        let local_var_entity: Option<CommentsRetrieveError> =
587            serde_json::from_str(&local_var_content).ok();
588        let local_var_error = ResponseContent {
589            status: local_var_status,
590            content: local_var_content,
591            entity: local_var_entity,
592        };
593        Err(Error::ResponseError(local_var_error))
594    }
595}
596
597pub async fn comments_update(
598    configuration: &configuration::Configuration,
599    params: CommentsUpdateParams,
600) -> Result<crate::models::CommentUpdate, Error<CommentsUpdateError>> {
601    let local_var_configuration = configuration;
602
603    // unbox the parameters
604    let id = params.id;
605    let comment_update = params.comment_update;
606
607    let local_var_client = &local_var_configuration.client;
608
609    let local_var_uri_str = format!(
610        "{}/api2/comments/{id}/",
611        local_var_configuration.base_path,
612        id = id
613    );
614    let mut local_var_req_builder =
615        local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
616
617    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
618        local_var_req_builder =
619            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
620    }
621    if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth {
622        local_var_req_builder = local_var_req_builder
623            .basic_auth(local_var_auth_conf.0.clone(), local_var_auth_conf.1.clone());
624    };
625    if let Some(ref local_var_cookie) = local_var_configuration.cookie {
626        local_var_req_builder =
627            local_var_req_builder.header("Cookie", format!("sessionid={}", local_var_cookie.value));
628    };
629    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
630        let local_var_key = local_var_apikey.key.clone();
631        let local_var_value = match local_var_apikey.prefix {
632            Some(ref local_var_prefix) => format!("{local_var_prefix} {local_var_key}"),
633            None => local_var_key,
634        };
635        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
636    };
637    local_var_req_builder = local_var_req_builder.json(&comment_update);
638
639    let local_var_req = local_var_req_builder.build()?;
640    let local_var_resp = local_var_client.execute(local_var_req).await?;
641
642    let local_var_status = local_var_resp.status();
643    let local_var_content = local_var_resp.text().await?;
644
645    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
646        serde_json::from_str(&local_var_content).map_err(Error::from)
647    } else {
648        let local_var_entity: Option<CommentsUpdateError> =
649            serde_json::from_str(&local_var_content).ok();
650        let local_var_error = ResponseContent {
651            status: local_var_status,
652            content: local_var_content,
653            entity: local_var_entity,
654        };
655        Err(Error::ResponseError(local_var_error))
656    }
657}