misardev 1.1.0

Async Rust client for the Misar.Dev API: create projects, write files, build and deploy, start from templates, run OpenAI-compatible chat completions, search code and read usage. Retries, typed plan-limit errors, SSE streaming.
Documentation
// GENERATED by scripts/generate-sdk-resources.mjs from sdks/manifest.json.
// Do not edit by hand — change the route, run `pnpm sdk:sync`, and regenerate.

use crate::error::MisarDevError;
use crate::transport::Transport;
use crate::transport::body_or_empty;
use crate::transport::build_query;
use crate::transport::encode_path;
use reqwest::Method;
use serde_json::Value;

/// The `stories` resource — 8 operation(s).
///
/// Stories: post, the tray, read one, mark seen, viewers, reply, and your posts to share.
///
/// Reached through [`crate::MisarDev::stories`].
#[derive(Debug, Clone, Copy)]
pub struct StoriesResource<'a> {
    pub(crate) t: &'a Transport,
}

impl StoriesResource<'_> {
    /// `POST /stories`
    ///
    /// misardev:method stories.create
    pub async fn create(self, body: Option<Value>) -> Result<Value, MisarDevError> {
        self.t.request(Method::POST, "/stories", "", Some(body_or_empty(body))).await
    }

    /// `DELETE /stories/:id`
    ///
    /// misardev:method stories.delete
    pub async fn delete(self, id: &str) -> Result<Value, MisarDevError> {
        self.t.request(Method::DELETE, &format!("/stories/{}", encode_path(id)), "", None).await
    }

    /// `GET /stories/:id`
    ///
    /// misardev:method stories.get
    pub async fn get(self, id: &str) -> Result<Value, MisarDevError> {
        self.t.request(Method::GET, &format!("/stories/{}", encode_path(id)), "", None).await
    }

    /// `GET /stories/my-posts`
    ///
    /// Optional query: `cursor`, `limit`.
    ///
    /// misardev:method stories.listMyPosts
    pub async fn list_my_posts(self, query: Option<Value>) -> Result<Value, MisarDevError> {
        self.t.request(Method::GET, "/stories/my-posts", &build_query(query.as_ref(), &[]), None).await
    }

    /// `GET /stories/:id/viewers`
    ///
    /// Optional query: `cursor`, `limit`.
    ///
    /// misardev:method stories.listViewers
    pub async fn list_viewers(self, id: &str, query: Option<Value>) -> Result<Value, MisarDevError> {
        self.t.request(Method::GET, &format!("/stories/{}/viewers", encode_path(id)), &build_query(query.as_ref(), &[]), None).await
    }

    /// `POST /stories/:id/view`
    ///
    /// misardev:method stories.markSeen
    pub async fn mark_seen(self, id: &str) -> Result<Value, MisarDevError> {
        self.t.request(Method::POST, &format!("/stories/{}/view", encode_path(id)), "", None).await
    }

    /// `POST /stories/:id/reply`
    ///
    /// misardev:method stories.reply
    pub async fn reply(self, id: &str, body: Option<Value>) -> Result<Value, MisarDevError> {
        self.t.request(Method::POST, &format!("/stories/{}/reply", encode_path(id)), "", Some(body_or_empty(body))).await
    }

    /// `GET /stories/tray`
    ///
    /// misardev:method stories.tray
    pub async fn tray(self) -> Result<Value, MisarDevError> {
        self.t.request(Method::GET, "/stories/tray", "", None).await
    }
}