Skip to main content

fizzy_sdk/generated/services/
reactions.rs

1// Generated by fizzy-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
2
3use crate::client::Scope;
4use crate::error::Error;
5use crate::generated::routes;
6use crate::generated::types::*;
7
8/// The `Reactions` operations.
9pub 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    /// The client and account these operations send through.
19    pub fn scope(&self) -> &Scope<'a> {
20        &self.scope
21    }
22
23    /// `CreateCardReaction` — `POST /{accountId}/cards/{cardNumber}/reactions.json`.
24    ///
25    /// Sent once and never resent.
26    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    /// `CreateCommentReaction` — `POST /{accountId}/cards/{cardNumber}/comments/{commentId}/reactions.json`.
40    ///
41    /// Sent once and never resent.
42    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    /// `DeleteCardReaction` — `DELETE /{accountId}/cards/{cardNumber}/reactions/{reactionId}`.
58    ///
59    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
60    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    /// `DeleteCommentReaction` — `DELETE /{accountId}/cards/{cardNumber}/comments/{commentId}/reactions/{reactionId}`.
69    ///
70    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
71    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    /// `ListCardReactions` — `GET /{accountId}/cards/{cardNumber}/reactions.json`.
86    ///
87    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
88    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    /// `ListCommentReactions` — `GET /{accountId}/cards/{cardNumber}/comments/{commentId}/reactions.json`.
97    ///
98    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
99    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}