fizzy-sdk 0.2.4

Official Fizzy API client, generated from the Smithy model in spec/
Documentation
// Generated by fizzy-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.

use crate::client::Scope;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;

/// The `Reactions` operations.
pub struct ReactionsService<'a> {
    scope: Scope<'a>,
}

impl<'a> ReactionsService<'a> {
    pub(crate) fn new(scope: Scope<'a>) -> Self {
        Self { scope }
    }

    /// The client and account these operations send through.
    pub fn scope(&self) -> &Scope<'a> {
        &self.scope
    }

    /// `CreateCardReaction` — `POST /{accountId}/cards/{cardNumber}/reactions.json`.
    ///
    /// Sent once and never resent.
    pub async fn create_card(
        &self,
        card_number: i32,
        body: &CreateCardReactionRequestContent,
    ) -> Result<Reaction, Error> {
        let mut operation = self
            .scope
            .operation(&routes::CREATE_CARD_REACTION, &[&card_number])?;
        operation.resource_id(card_number);
        operation.json(body)?;
        self.scope.client().send(operation).await
    }

    /// `CreateCommentReaction` — `POST /{accountId}/cards/{cardNumber}/comments/{commentId}/reactions.json`.
    ///
    /// Sent once and never resent.
    pub async fn create_comment(
        &self,
        card_number: i32,
        comment_id: &str,
        body: &CreateCommentReactionRequestContent,
    ) -> Result<Reaction, Error> {
        let mut operation = self.scope.operation(
            &routes::CREATE_COMMENT_REACTION,
            &[&card_number, &comment_id],
        )?;
        operation.resource_id(card_number);
        operation.json(body)?;
        self.scope.client().send(operation).await
    }

    /// `DeleteCardReaction` — `DELETE /{accountId}/cards/{cardNumber}/reactions/{reactionId}`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn delete_card(&self, card_number: i32, reaction_id: &str) -> Result<(), Error> {
        let mut operation = self
            .scope
            .operation(&routes::DELETE_CARD_REACTION, &[&card_number, &reaction_id])?;
        operation.resource_id(reaction_id);
        self.scope.client().send_unit(operation).await
    }

    /// `DeleteCommentReaction` — `DELETE /{accountId}/cards/{cardNumber}/comments/{commentId}/reactions/{reactionId}`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn delete_comment(
        &self,
        card_number: i32,
        comment_id: &str,
        reaction_id: &str,
    ) -> Result<(), Error> {
        let mut operation = self.scope.operation(
            &routes::DELETE_COMMENT_REACTION,
            &[&card_number, &comment_id, &reaction_id],
        )?;
        operation.resource_id(reaction_id);
        self.scope.client().send_unit(operation).await
    }

    /// `ListCardReactions` — `GET /{accountId}/cards/{cardNumber}/reactions.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn list_card(&self, card_number: i32) -> Result<Vec<Reaction>, Error> {
        let mut operation = self
            .scope
            .operation(&routes::LIST_CARD_REACTIONS, &[&card_number])?;
        operation.resource_id(card_number);
        self.scope.client().send(operation).await
    }

    /// `ListCommentReactions` — `GET /{accountId}/cards/{cardNumber}/comments/{commentId}/reactions.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn list_comment(
        &self,
        card_number: i32,
        comment_id: &str,
    ) -> Result<Vec<Reaction>, Error> {
        let mut operation = self.scope.operation(
            &routes::LIST_COMMENT_REACTIONS,
            &[&card_number, &comment_id],
        )?;
        operation.resource_id(card_number);
        self.scope.client().send(operation).await
    }
}