misardev 1.0.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 `organizations` resource — 9 operation(s).
///
/// Organizations, members and invitations.
///
/// Reached through [`crate::MisarDev::organizations`].
#[derive(Debug, Clone, Copy)]
pub struct OrganizationsResource<'a> {
    pub(crate) t: &'a Transport,
}

impl OrganizationsResource<'_> {
    /// `POST /invitations/accept`
    ///
    /// misardev:method organizations.acceptInvitation
    pub async fn accept_invitation(self, body: Option<Value>) -> Result<Value, MisarDevError> {
        self.t.request(Method::POST, "/invitations/accept", "", Some(body_or_empty(body))).await
    }

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

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

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

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

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

    /// `DELETE /organizations/:id/members`
    ///
    /// misardev:method organizations.removeMember
    pub async fn remove_member(self, id: &str, user_id: &str) -> Result<Value, MisarDevError> {
        self.t.request(Method::DELETE, &format!("/organizations/{}/members", encode_path(id)), &build_query(None, &[("userId", user_id)]), None).await
    }

    /// `DELETE /organizations/:id/invitations`
    ///
    /// misardev:method organizations.revokeInvitation
    pub async fn revoke_invitation(self, id: &str, invitation_id: &str) -> Result<Value, MisarDevError> {
        self.t.request(Method::DELETE, &format!("/organizations/{}/invitations", encode_path(id)), &build_query(None, &[("invitationId", invitation_id)]), None).await
    }

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