apibrasil 1.0.0

SDK oficial Rust da plataforma APIBrasil: WhatsApp, SMS, consultas de CPF/CNPJ, veiculos, CEP, correios, pagamentos PIX/boleto e mais.
Documentation
use crate::core::{DeviceResponse, IntoBody, Result};

platform_service! {
    /// Evolution API (device-based):
    /// `POST /evolution/{controller}/{action}`. Exige
    /// `Authorization: Bearer` + `DeviceToken`.
    ///
    /// Exemplos de `controller/action`: `instance/create`,
    /// `message/sendText`. Os caminhos documentados estão em
    /// [`EVOLUTION_PATHS`](crate::generated::EVOLUTION_PATHS).
    EvolutionService
}

impl EvolutionService {
    /// Executa `POST /evolution/{controller}/{action}`.
    pub async fn request(
        &self,
        controller: &str,
        action: &str,
        body: impl IntoBody,
    ) -> Result<DeviceResponse> {
        self.call(&format!("{controller}/{action}"), body).await
    }

    /// Executa um caminho completo do catálogo: `POST /evolution/{path}`.
    pub async fn call(&self, path: &str, body: impl IntoBody) -> Result<DeviceResponse> {
        let path = format!("evolution/{}", path.trim_matches('/'));
        Ok(DeviceResponse(self.base.post(&path, body).await?))
    }

    /// Executa a mesma chamada de forma assíncrona via fila.
    pub async fn queue(
        &self,
        controller: &str,
        action: &str,
        body: impl IntoBody,
    ) -> Result<DeviceResponse> {
        self.call(&format!("{controller}/{action}/queue"), body)
            .await
    }
}