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::{CreditResponse, IntoBody, Result};

device_service! {
    /// API de SMS (device-based): `POST /sms/{action}`. Exige
    /// `Authorization: Bearer` + `DeviceToken`.
    ///
    /// Campos aceitos por [`send`](SmsService::send) e
    /// [`send_with_credits`](SmsService::send_with_credits): `number`,
    /// `message`, `operator` (padrão do gateway: `claro`), `user_reply` e
    /// `webhook_url`.
    SmsService("sms") {
        /// Envia um SMS pelo device: `POST /sms/send`.
        send => "send",
    }
}

impl SmsService {
    /// Envia um SMS debitando créditos da conta (sem `DeviceToken`):
    /// `POST /sms/send/credits`.
    pub async fn send_with_credits(&self, body: impl IntoBody) -> Result<CreditResponse> {
        Ok(CreditResponse(
            self.base.post("sms/send/credits", body).await?,
        ))
    }
}