fizzy_sdk/generated/services/
comments.rs1use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7use crate::pagination::Page;
8
9pub struct CommentsService<'a> {
11 scope: Scope<'a>,
12}
13
14impl<'a> CommentsService<'a> {
15 pub(crate) fn new(scope: Scope<'a>) -> Self {
16 Self { scope }
17 }
18
19 pub fn scope(&self) -> &Scope<'a> {
21 &self.scope
22 }
23
24 pub async fn create(
28 &self,
29 card_number: i32,
30 body: &CreateCommentRequestContent,
31 ) -> Result<Comment, Error> {
32 let mut operation = self
33 .scope
34 .operation(&routes::CREATE_COMMENT, &[&card_number])?;
35 operation.resource_id(card_number);
36 operation.json(body)?;
37 self.scope.client().send(operation).await
38 }
39
40 pub async fn delete(&self, card_number: i32, comment_id: &str) -> Result<(), Error> {
44 let mut operation = self
45 .scope
46 .operation(&routes::DELETE_COMMENT, &[&card_number, &comment_id])?;
47 operation.resource_id(comment_id);
48 self.scope.client().send_unit(operation).await
49 }
50
51 pub async fn get(&self, card_number: i32, comment_id: &str) -> Result<Comment, Error> {
55 let mut operation = self
56 .scope
57 .operation(&routes::GET_COMMENT, &[&card_number, &comment_id])?;
58 operation.resource_id(comment_id);
59 self.scope.client().send(operation).await
60 }
61
62 pub async fn list(&self, card_number: i32) -> Result<Page<Vec<Comment>>, Error> {
68 let mut operation = self
69 .scope
70 .operation(&routes::LIST_COMMENTS, &[&card_number])?;
71 operation.resource_id(card_number);
72 self.scope.client().send_page(operation).await
73 }
74
75 pub async fn update(
79 &self,
80 card_number: i32,
81 comment_id: &str,
82 body: &UpdateCommentRequestContent,
83 ) -> Result<Comment, Error> {
84 let mut operation = self
85 .scope
86 .operation(&routes::UPDATE_COMMENT, &[&card_number, &comment_id])?;
87 operation.resource_id(comment_id);
88 operation.json(body)?;
89 self.scope.client().send(operation).await
90 }
91}