fizzy_sdk/generated/services/
reactions.rs1use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7
8pub struct ReactionsService<'a> {
10 scope: Scope<'a>,
11}
12
13impl<'a> ReactionsService<'a> {
14 pub(crate) fn new(scope: Scope<'a>) -> Self {
15 Self { scope }
16 }
17
18 pub fn scope(&self) -> &Scope<'a> {
20 &self.scope
21 }
22
23 pub async fn create_card(
27 &self,
28 card_number: i32,
29 body: &CreateCardReactionRequestContent,
30 ) -> Result<Reaction, Error> {
31 let mut operation = self
32 .scope
33 .operation(&routes::CREATE_CARD_REACTION, &[&card_number])?;
34 operation.resource_id(card_number);
35 operation.json(body)?;
36 self.scope.client().send(operation).await
37 }
38
39 pub async fn create_comment(
43 &self,
44 card_number: i32,
45 comment_id: &str,
46 body: &CreateCommentReactionRequestContent,
47 ) -> Result<Reaction, Error> {
48 let mut operation = self.scope.operation(
49 &routes::CREATE_COMMENT_REACTION,
50 &[&card_number, &comment_id],
51 )?;
52 operation.resource_id(card_number);
53 operation.json(body)?;
54 self.scope.client().send(operation).await
55 }
56
57 pub async fn delete_card(&self, card_number: i32, reaction_id: &str) -> Result<(), Error> {
61 let mut operation = self
62 .scope
63 .operation(&routes::DELETE_CARD_REACTION, &[&card_number, &reaction_id])?;
64 operation.resource_id(reaction_id);
65 self.scope.client().send_unit(operation).await
66 }
67
68 pub async fn delete_comment(
72 &self,
73 card_number: i32,
74 comment_id: &str,
75 reaction_id: &str,
76 ) -> Result<(), Error> {
77 let mut operation = self.scope.operation(
78 &routes::DELETE_COMMENT_REACTION,
79 &[&card_number, &comment_id, &reaction_id],
80 )?;
81 operation.resource_id(reaction_id);
82 self.scope.client().send_unit(operation).await
83 }
84
85 pub async fn list_card(&self, card_number: i32) -> Result<Vec<Reaction>, Error> {
89 let mut operation = self
90 .scope
91 .operation(&routes::LIST_CARD_REACTIONS, &[&card_number])?;
92 operation.resource_id(card_number);
93 self.scope.client().send(operation).await
94 }
95
96 pub async fn list_comment(
100 &self,
101 card_number: i32,
102 comment_id: &str,
103 ) -> Result<Vec<Reaction>, Error> {
104 let mut operation = self.scope.operation(
105 &routes::LIST_COMMENT_REACTIONS,
106 &[&card_number, &comment_id],
107 )?;
108 operation.resource_id(card_number);
109 self.scope.client().send(operation).await
110 }
111}