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::*;
use crate::pagination::Page;

/// Optional query parameters for `ListCards`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListCardsParams {
    /// `board_ids[]`.
    pub board_ids: Option<Vec<String>>,
    /// `tag_ids[]`.
    pub tag_ids: Option<Vec<String>>,
    /// `assignee_ids[]`.
    pub assignee_ids: Option<Vec<String>>,
    /// `creator_ids[]`.
    pub creator_ids: Option<Vec<String>>,
    /// `closer_ids[]`.
    pub closer_ids: Option<Vec<String>>,
    /// `card_ids[]`.
    pub card_ids: Option<Vec<String>>,
    /// `column_ids[]`.
    pub column_ids: Option<Vec<String>>,
    /// `indexed_by`.
    pub indexed_by: Option<String>,
    /// `sorted_by`.
    pub sorted_by: Option<String>,
    /// `assignment_status`.
    pub assignment_status: Option<String>,
    /// `creation`.
    pub creation: Option<String>,
    /// `closure`.
    pub closure: Option<String>,
    /// `terms[]`.
    pub terms: Option<Vec<String>>,
}

/// Optional query parameters for `ListActivities`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct ListActivitiesParams {
    /// `creator_ids[]`.
    pub creator_ids: Option<Vec<String>>,
    /// `board_ids[]`.
    pub board_ids: Option<Vec<String>>,
}

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

impl<'a> CardsService<'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
    }

    /// `AssignCard` — `POST /{accountId}/cards/{cardNumber}/assignments.json`.
    ///
    /// Sent once and never resent.
    pub async fn assign(
        &self,
        card_number: i32,
        body: &AssignCardRequestContent,
    ) -> Result<(), Error> {
        let mut operation = self
            .scope
            .operation(&routes::ASSIGN_CARD, &[&card_number])?;
        operation.resource_id(card_number);
        operation.json(body)?;
        self.scope.client().send_unit(operation).await
    }

    /// `CloseCard` — `POST /{accountId}/cards/{cardNumber}/closure.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
    pub async fn close(&self, card_number: i32) -> Result<(), Error> {
        let mut operation = self.scope.operation(&routes::CLOSE_CARD, &[&card_number])?;
        operation.resource_id(card_number);
        self.scope.client().send_unit(operation).await
    }

    /// `CreateCard` — `POST /{accountId}/cards.json`.
    ///
    /// Sent once and never resent.
    pub async fn create(&self, body: &CreateCardRequestContent) -> Result<Card, Error> {
        let mut operation = self.scope.operation(&routes::CREATE_CARD, &[])?;
        operation.json(body)?;
        self.scope.client().send(operation).await
    }

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

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

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

    /// `GoldCard` — `POST /{accountId}/cards/{cardNumber}/goldness.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
    pub async fn gold(&self, card_number: i32) -> Result<(), Error> {
        let mut operation = self.scope.operation(&routes::GOLD_CARD, &[&card_number])?;
        operation.resource_id(card_number);
        self.scope.client().send_unit(operation).await
    }

    /// `ListCards` — `GET /{accountId}/cards.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    ///
    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
    pub async fn list(&self, params: &ListCardsParams) -> Result<Page<Vec<Card>>, Error> {
        let mut operation = self.scope.operation(&routes::LIST_CARDS, &[])?;
        operation.query_all_optional("board_ids[]", params.board_ids.as_deref());
        operation.query_all_optional("tag_ids[]", params.tag_ids.as_deref());
        operation.query_all_optional("assignee_ids[]", params.assignee_ids.as_deref());
        operation.query_all_optional("creator_ids[]", params.creator_ids.as_deref());
        operation.query_all_optional("closer_ids[]", params.closer_ids.as_deref());
        operation.query_all_optional("card_ids[]", params.card_ids.as_deref());
        operation.query_all_optional("column_ids[]", params.column_ids.as_deref());
        operation.query_optional("indexed_by", params.indexed_by.as_ref());
        operation.query_optional("sorted_by", params.sorted_by.as_ref());
        operation.query_optional("assignment_status", params.assignment_status.as_ref());
        operation.query_optional("creation", params.creation.as_ref());
        operation.query_optional("closure", params.closure.as_ref());
        operation.query_all_optional("terms[]", params.terms.as_deref());
        self.scope.client().send_page(operation).await
    }

    /// `ListActivities` — `GET /{accountId}/activities.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    ///
    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
    pub async fn list_activities(
        &self,
        params: &ListActivitiesParams,
    ) -> Result<Page<Vec<Activity>>, Error> {
        let mut operation = self.scope.operation(&routes::LIST_ACTIVITIES, &[])?;
        operation.query_all_optional("creator_ids[]", params.creator_ids.as_deref());
        operation.query_all_optional("board_ids[]", params.board_ids.as_deref());
        self.scope.client().send_page(operation).await
    }

    /// `ListColumnCards` — `GET /{accountId}/boards/{boardId}/columns/{columnId}/cards.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    ///
    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
    pub async fn list_column_cards(
        &self,
        board_id: &str,
        column_id: &str,
    ) -> Result<Page<Vec<Card>>, Error> {
        let mut operation = self
            .scope
            .operation(&routes::LIST_COLUMN_CARDS, &[&board_id, &column_id])?;
        operation.resource_id(board_id);
        self.scope.client().send_page(operation).await
    }

    /// `MarkCardRead` — `POST /{accountId}/cards/{cardNumber}/reading.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
    pub async fn mark_read(&self, card_number: i32) -> Result<(), Error> {
        let mut operation = self
            .scope
            .operation(&routes::MARK_CARD_READ, &[&card_number])?;
        operation.resource_id(card_number);
        self.scope.client().send_unit(operation).await
    }

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

    /// `MoveCard` — `PATCH /{accountId}/cards/{cardNumber}/board.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn move_to_board(
        &self,
        card_number: i32,
        body: &MoveCardRequestContent,
    ) -> Result<Card, Error> {
        let mut operation = self.scope.operation(&routes::MOVE_CARD, &[&card_number])?;
        operation.resource_id(card_number);
        operation.json(body)?;
        self.scope.client().send(operation).await
    }

    /// `PinCard` — `POST /{accountId}/cards/{cardNumber}/pin.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
    pub async fn pin(&self, card_number: i32) -> Result<(), Error> {
        let mut operation = self.scope.operation(&routes::PIN_CARD, &[&card_number])?;
        operation.resource_id(card_number);
        self.scope.client().send_unit(operation).await
    }

    /// `PostponeCard` — `POST /{accountId}/cards/{cardNumber}/not_now.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
    pub async fn postpone(&self, card_number: i32) -> Result<(), Error> {
        let mut operation = self
            .scope
            .operation(&routes::POSTPONE_CARD, &[&card_number])?;
        operation.resource_id(card_number);
        self.scope.client().send_unit(operation).await
    }

    /// `PublishCard` — `POST /{accountId}/cards/{cardNumber}/publish.json`.
    ///
    /// Sent once and never resent.
    pub async fn publish(&self, card_number: i32) -> Result<(), Error> {
        let mut operation = self
            .scope
            .operation(&routes::PUBLISH_CARD, &[&card_number])?;
        operation.resource_id(card_number);
        self.scope.client().send_unit(operation).await
    }

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

    /// `SelfAssignCard` — `POST /{accountId}/cards/{cardNumber}/self_assignment.json`.
    ///
    /// Sent once and never resent.
    pub async fn self_assign(&self, card_number: i32) -> Result<(), Error> {
        let mut operation = self
            .scope
            .operation(&routes::SELF_ASSIGN_CARD, &[&card_number])?;
        operation.resource_id(card_number);
        self.scope.client().send_unit(operation).await
    }

    /// `TagCard` — `POST /{accountId}/cards/{cardNumber}/taggings.json`.
    ///
    /// Sent once and never resent.
    pub async fn tag(&self, card_number: i32, body: &TagCardRequestContent) -> Result<(), Error> {
        let mut operation = self.scope.operation(&routes::TAG_CARD, &[&card_number])?;
        operation.resource_id(card_number);
        operation.json(body)?;
        self.scope.client().send_unit(operation).await
    }

    /// `TriageCard` — `POST /{accountId}/cards/{cardNumber}/triage.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
    pub async fn triage(
        &self,
        card_number: i32,
        body: &TriageCardRequestContent,
    ) -> Result<(), Error> {
        let mut operation = self
            .scope
            .operation(&routes::TRIAGE_CARD, &[&card_number])?;
        operation.resource_id(card_number);
        operation.json(body)?;
        self.scope.client().send_unit(operation).await
    }

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

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

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

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

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

    /// `WatchCard` — `POST /{accountId}/cards/{cardNumber}/watch.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
    pub async fn watch(&self, card_number: i32) -> Result<(), Error> {
        let mut operation = self.scope.operation(&routes::WATCH_CARD, &[&card_number])?;
        operation.resource_id(card_number);
        self.scope.client().send_unit(operation).await
    }
}