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::*;

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

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

    /// Add a topic to a workflow. HEY places it in the first stage.
    pub async fn create_staging(&self, topic_id: i64, workflow_id: i64) -> Result<(), Error> {
        let mut operation = self
            .client
            .operation(&routes::CREATE_WORKFLOW_STAGING, &[&topic_id, &workflow_id]);
        operation.resource_id(topic_id);
        self.client.send_unit(operation).await
    }

    /// A workflow with its stages
    pub async fn get(&self, workflow_id: i64) -> Result<GetWorkflowResponseContent, Error> {
        let mut operation = self
            .client
            .operation(&routes::GET_WORKFLOW, &[&workflow_id]);
        operation.resource_id(workflow_id);
        self.client.send(operation).await
    }

    /// A workflow stage and its cards, served as HTML by HEY.
    pub async fn get_stage(
        &self,
        workflow_id: i64,
        stage_id: i64,
    ) -> Result<GetWorkflowStageOutputPayload, Error> {
        let mut operation = self
            .client
            .operation(&routes::GET_WORKFLOW_STAGE, &[&workflow_id, &stage_id]);
        operation.resource_id(stage_id);
        self.client.send_text(operation).await
    }

    /// Move a staged topic to a workflow stage.
    pub async fn move_staging(
        &self,
        topic_id: i64,
        workflow_id: i64,
        body: &MoveWorkflowStagingRequestContent,
    ) -> Result<(), Error> {
        let mut operation = self
            .client
            .operation(&routes::MOVE_WORKFLOW_STAGING, &[&topic_id, &workflow_id]);
        operation.resource_id(topic_id);
        operation.json(body)?;
        self.client.send_unit(operation).await
    }
}