granthe 0.6.0

Official Rust SDK for Granthe — institutional liquidity rail for crypto settlement
Documentation
use std::sync::Arc;

use crate::error::GrantheResult;
use crate::http::HttpClient;

pub struct TeamService {
    pub(crate) http: Arc<HttpClient>,
}

impl TeamService {
    pub async fn get(&self) -> GrantheResult<serde_json::Value> {
        let data = self.http.get("/merchants/me/team", None).await?;
        Ok(serde_json::from_slice(&data).map_err(|e| crate::error::GrantheError::Other(e.to_string()))?)
    }

    pub async fn my_role(&self) -> GrantheResult<serde_json::Value> {
        let data = self.http.get("/merchants/me/team/my-role", None).await?;
        Ok(serde_json::from_slice(&data).map_err(|e| crate::error::GrantheError::Other(e.to_string()))?)
    }

    pub async fn invite(&self, email: &str, role: &str) -> GrantheResult<serde_json::Value> {
        let body = serde_json::json!({"email": email, "role": role});
        let data = self.http.post("/merchants/me/team/invite", Some(&body)).await?;
        Ok(serde_json::from_slice(&data).map_err(|e| crate::error::GrantheError::Other(e.to_string()))?)
    }

    pub async fn revoke_invite(&self, invite_id: &str) -> GrantheResult<serde_json::Value> {
        let data = self.http.post::<()>(&format!("/merchants/me/team/invite/{}/revoke", invite_id), None).await?;
        Ok(serde_json::from_slice(&data).map_err(|e| crate::error::GrantheError::Other(e.to_string()))?)
    }

    pub async fn update_role(&self, member_id: &str, role: &str) -> GrantheResult<serde_json::Value> {
        let body = serde_json::json!({"role": role});
        let data = self.http.patch(&format!("/merchants/me/team/{}/role", member_id), Some(&body)).await?;
        Ok(serde_json::from_slice(&data).map_err(|e| crate::error::GrantheError::Other(e.to_string()))?)
    }

    pub async fn remove(&self, member_id: &str) -> GrantheResult<()> {
        self.http.delete(&format!("/merchants/me/team/{}", member_id)).await?;
        Ok(())
    }
}