hey-sdk 0.30.0

Rust client for the HEY API, generated from a Smithy model of the API
Documentation
// Generated by hey-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.

#![allow(clippy::too_many_arguments)]

use crate::client::Client;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;
use crate::pagination::Page;

/// Optional query parameters for `GetBox`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetBoxParams {
    pub page: Option<String>,
}

/// Optional query parameters for `GetAsidebox`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetAsideboxParams {
    pub page: Option<String>,
}

/// Optional query parameters for `GetBubblebox`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetBubbleboxParams {
    pub page: Option<String>,
}

/// Optional query parameters for `GetFeedbox`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetFeedboxParams {
    pub page: Option<String>,
}

/// Optional query parameters for `GetBoxGroup`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetBoxGroupParams {
    pub page: Option<String>,
}

/// Optional query parameters for `GetImbox`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetImboxParams {
    pub page: Option<String>,
}

/// Optional query parameters for `GetImboxSeen`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetImboxSeenParams {
    pub page: Option<String>,
}

/// Optional query parameters for `GetLaterbox`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetLaterboxParams {
    pub page: Option<String>,
}

/// Optional query parameters for `GetTrailbox`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetTrailboxParams {
    pub page: Option<String>,
}

pub struct Boxes<'a> {
    client: &'a Client,
}

impl<'a> Boxes<'a> {
    pub(crate) fn new(client: &'a Client) -> Self {
        Self { client }
    }

    /// The client this service sends through.
    pub fn client(&self) -> &'a Client {
        self.client
    }

    /// Create a Set Aside group out of a selection of postings.
    ///
    /// This endpoint does not split a comma-joined posting_ids string — send an array.
    pub async fn create_group(
        &self,
        box_id: i64,
        body: &CreateBoxGroupRequestContent,
    ) -> Result<CreateBoxGroupResponseContent, Error> {
        let mut operation = self.client.operation(&routes::CREATE_BOX_GROUP, &[&box_id]);
        operation.resource_id(box_id);
        operation.json(body)?;
        self.client.send(operation).await
    }

    /// Break up a Set Aside group, moving its postings back to Previously Seen
    pub async fn delete_group(&self, box_id: i64, group_id: i64) -> Result<(), Error> {
        let mut operation = self
            .client
            .operation(&routes::DELETE_BOX_GROUP, &[&box_id, &group_id]);
        operation.resource_id(group_id);
        self.client.send_unit(operation).await
    }

    /// Get a specific box
    pub async fn get(
        &self,
        box_id: i64,
        params: &GetBoxParams,
    ) -> Result<Page<GetBoxResponseContent>, Error> {
        let mut operation = self.client.operation(&routes::GET_BOX, &[&box_id]);
        operation.resource_id(box_id);
        operation.query_optional("page", params.page.as_ref());
        self.client.send_page(operation).await
    }

    /// Get the Set Aside box
    pub async fn get_asidebox(
        &self,
        params: &GetAsideboxParams,
    ) -> Result<GetAsideboxResponseContent, Error> {
        let mut operation = self.client.operation(&routes::GET_ASIDEBOX, &[]);
        operation.query_optional("page", params.page.as_ref());
        self.client.send(operation).await
    }

    /// Get the Bubble Up box
    pub async fn get_bubblebox(
        &self,
        params: &GetBubbleboxParams,
    ) -> Result<GetBubbleboxResponseContent, Error> {
        let mut operation = self.client.operation(&routes::GET_BUBBLEBOX, &[]);
        operation.query_optional("page", params.page.as_ref());
        self.client.send(operation).await
    }

    /// Get the Feed
    pub async fn get_feedbox(
        &self,
        params: &GetFeedboxParams,
    ) -> Result<GetFeedboxResponseContent, Error> {
        let mut operation = self.client.operation(&routes::GET_FEEDBOX, &[]);
        operation.query_optional("page", params.page.as_ref());
        self.client.send(operation).await
    }

    /// Read one Set Aside group with the postings in it.
    ///
    /// The postings are paged like a folder's: newest observed first, 30 to a page, with the
    /// next page in the Link header and the total in X-Total-Count.
    pub async fn get_group(
        &self,
        box_id: i64,
        group_id: i64,
        params: &GetBoxGroupParams,
    ) -> Result<Page<GetBoxGroupResponseContent>, Error> {
        let mut operation = self
            .client
            .operation(&routes::GET_BOX_GROUP, &[&box_id, &group_id]);
        operation.resource_id(group_id);
        operation.query_optional("page", params.page.as_ref());
        self.client.send_page(operation).await
    }

    /// Get the Imbox
    pub async fn get_imbox(
        &self,
        params: &GetImboxParams,
    ) -> Result<GetImboxResponseContent, Error> {
        let mut operation = self.client.operation(&routes::GET_IMBOX, &[]);
        operation.query_optional("page", params.page.as_ref());
        self.client.send(operation).await
    }

    /// Get the Imbox's Previously Seen postings
    pub async fn get_imbox_seen(
        &self,
        params: &GetImboxSeenParams,
    ) -> Result<GetImboxSeenResponseContent, Error> {
        let mut operation = self.client.operation(&routes::GET_IMBOX_SEEN, &[]);
        operation.query_optional("page", params.page.as_ref());
        self.client.send(operation).await
    }

    /// Get the Reply Later box
    pub async fn get_laterbox(
        &self,
        params: &GetLaterboxParams,
    ) -> Result<GetLaterboxResponseContent, Error> {
        let mut operation = self.client.operation(&routes::GET_LATERBOX, &[]);
        operation.query_optional("page", params.page.as_ref());
        self.client.send(operation).await
    }

    /// Get the Paper Trail
    pub async fn get_trailbox(
        &self,
        params: &GetTrailboxParams,
    ) -> Result<GetTrailboxResponseContent, Error> {
        let mut operation = self.client.operation(&routes::GET_TRAILBOX, &[]);
        operation.query_optional("page", params.page.as_ref());
        self.client.send(operation).await
    }

    /// List all boxes
    pub async fn list(&self) -> Result<Page<ListBoxesResponseContent>, Error> {
        let operation = self.client.operation(&routes::LIST_BOXES, &[]);
        self.client.send_page(operation).await
    }

    /// List the Set Aside groups in a box
    pub async fn list_groups(&self, box_id: i64) -> Result<ListBoxGroupsResponseContent, Error> {
        let mut operation = self.client.operation(&routes::LIST_BOX_GROUPS, &[&box_id]);
        operation.resource_id(box_id);
        self.client.send(operation).await
    }

    /// Mark everything in a box as seen. The work is queued, so the effect is eventually consistent.
    pub async fn mark_seen(&self, box_id: i64) -> Result<(), Error> {
        let mut operation = self.client.operation(&routes::MARK_BOX_SEEN, &[&box_id]);
        operation.resource_id(box_id);
        self.client.send_unit(operation).await
    }
}