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 `GetClearances`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetClearancesParams {
    pub include_clearances: Option<bool>,
    pub page: Option<String>,
}

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

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

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

    /// Screen several senders out at once. ids is a comma-separated list.
    pub async fn bulk_update(
        &self,
        body: &BulkUpdateClearancesRequestContent,
    ) -> Result<BulkUpdateClearancesResponseContent, Error> {
        let mut operation = self.client.operation(&routes::BULK_UPDATE_CLEARANCES, &[]);
        operation.json(body)?;
        self.client.send(operation).await
    }

    /// Get the Screener — the pending count, and the senders waiting when asked for them
    pub async fn get(
        &self,
        params: &GetClearancesParams,
    ) -> Result<Page<GetClearancesResponseContent>, Error> {
        let mut operation = self.client.operation(&routes::GET_CLEARANCES, &[]);
        operation.query_optional("include_clearances", params.include_clearances.as_ref());
        operation.query_optional("page", params.page.as_ref());
        self.client.send_page(operation).await
    }

    /// The senders already screened in or out
    pub async fn get_my(
        &self,
        params: &GetMyClearancesParams,
    ) -> Result<Page<GetMyClearancesResponseContent>, Error> {
        let mut operation = self.client.operation(&routes::GET_MY_CLEARANCES, &[]);
        operation.query_optional("page", params.page.as_ref());
        self.client.send_page(operation).await
    }

    /// Clear the Screener — every pending sender is punted and reexamined on their next email
    pub async fn punt(&self) -> Result<(), Error> {
        let operation = self.client.operation(&routes::PUNT_CLEARANCES, &[]);
        self.client.send_unit(operation).await
    }

    /// Screen a sender in or out of the Screener
    ///
    /// designation_box_id files everything they send into that box instead of the Imbox.
    /// spam marks what is already waiting as spam and trains the filter on it.
    pub async fn update(
        &self,
        clearance_id: i64,
        body: &UpdateClearanceRequestContent,
    ) -> Result<UpdateClearanceResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::UPDATE_CLEARANCE, &[&clearance_id]);
        operation.resource_id(clearance_id);
        operation.json(body)?;
        self.client.send(operation).await
    }

    /// Rescreen a sender who was already screened in or out
    pub async fn update_my(
        &self,
        clearance_id: i64,
        body: &UpdateMyClearanceRequestContent,
    ) -> Result<UpdateMyClearanceResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::UPDATE_MY_CLEARANCE, &[&clearance_id]);
        operation.resource_id(clearance_id);
        operation.json(body)?;
        self.client.send(operation).await
    }
}