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 `templates` resource — 7 operation(s).
///
/// Starter templates: browse, create, remix, and start a project from one.
///
/// Reached through [`crate::MisarDev::templates`].
#[derive(Debug, Clone, Copy)]
pub struct TemplatesResource<'a> {
    pub(crate) t: &'a Transport,
}

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

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

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

    /// `GET /templates`
    ///
    /// Optional query: `category`, `featured`, `limit`, `offset`, `search`.
    ///
    /// misardev:method templates.list
    pub async fn list(self, query: Option<Value>) -> Result<Value, MisarDevError> {
        self.t.request(Method::GET, "/templates", &build_query(query.as_ref(), &[]), None).await
    }

    /// `POST /templates/remix`
    ///
    /// misardev:method templates.remix
    pub async fn remix(self, body: Option<Value>) -> Result<Value, MisarDevError> {
        self.t.request(Method::POST, "/templates/remix", "", Some(body_or_empty(body))).await
    }

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

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