camunda_client/apis/
task_comment_api.rs

1/*
2 * Camunda BPM REST API
3 *
4 * OpenApi Spec for Camunda BPM REST API.
5 *
6 * The version of the OpenAPI document: 7.13.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use std::rc::Rc;
12use std::borrow::Borrow;
13#[allow(unused_imports)]
14use std::option::Option;
15
16use reqwest;
17
18use super::{Error, configuration};
19
20pub struct TaskCommentApiClient {
21    configuration: Rc<configuration::Configuration>,
22}
23
24impl TaskCommentApiClient {
25    pub fn new(configuration: Rc<configuration::Configuration>) -> TaskCommentApiClient {
26        TaskCommentApiClient {
27            configuration,
28        }
29    }
30}
31
32pub trait TaskCommentApi {
33    fn create_comment(&self, id: &str, comment_dto: Option<crate::models::CommentDto>) -> Result<crate::models::CommentDto, Error>;
34    fn get_comment(&self, id: &str, comment_id: &str) -> Result<crate::models::CommentDto, Error>;
35    fn get_comments(&self, id: &str) -> Result<Vec<crate::models::CommentDto>, Error>;
36}
37
38impl TaskCommentApi for TaskCommentApiClient {
39    fn create_comment(&self, id: &str, comment_dto: Option<crate::models::CommentDto>) -> Result<crate::models::CommentDto, Error> {
40        let configuration: &configuration::Configuration = self.configuration.borrow();
41        let client = &configuration.client;
42
43        let uri_str = format!("{}/task/{id}/comment/create", configuration.base_path, id=crate::apis::urlencode(id));
44        let mut req_builder = client.post(uri_str.as_str());
45
46        if let Some(ref user_agent) = configuration.user_agent {
47            req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
48        }
49        req_builder = req_builder.json(&comment_dto);
50
51        // send request
52        let req = req_builder.build()?;
53
54        Ok(client.execute(req)?.error_for_status()?.json()?)
55    }
56
57    fn get_comment(&self, id: &str, comment_id: &str) -> Result<crate::models::CommentDto, Error> {
58        let configuration: &configuration::Configuration = self.configuration.borrow();
59        let client = &configuration.client;
60
61        let uri_str = format!("{}/task/{id}/comment/{commentId}", configuration.base_path, id=crate::apis::urlencode(id), commentId=crate::apis::urlencode(comment_id));
62        let mut req_builder = client.get(uri_str.as_str());
63
64        if let Some(ref user_agent) = configuration.user_agent {
65            req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
66        }
67
68        // send request
69        let req = req_builder.build()?;
70
71        Ok(client.execute(req)?.error_for_status()?.json()?)
72    }
73
74    fn get_comments(&self, id: &str) -> Result<Vec<crate::models::CommentDto>, Error> {
75        let configuration: &configuration::Configuration = self.configuration.borrow();
76        let client = &configuration.client;
77
78        let uri_str = format!("{}/task/{id}/comment", configuration.base_path, id=crate::apis::urlencode(id));
79        let mut req_builder = client.get(uri_str.as_str());
80
81        if let Some(ref user_agent) = configuration.user_agent {
82            req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
83        }
84
85        // send request
86        let req = req_builder.build()?;
87
88        Ok(client.execute(req)?.error_for_status()?.json()?)
89    }
90
91}