wuapi 0.17.0

Rust SDK for wuapi, a WhatsApp API for developers. Link numbers by QR or pairing code, send and receive messages, manage chats, contacts, groups and channels, split them into projects and verify webhooks.
Documentation
// Generated by wuapi-codegen from the OpenAPI spec. Do not edit: run `bun run codegen`.

#![allow(unused_imports)]

use crate::sdk::{self, types};
use crate::support;

fn signed(body: &str) -> String {
    let now = std::time::SystemTime::now()
        .duration_since(std::time::UNIX_EPOCH)
        .unwrap()
        .as_secs()
        .to_string();
    format!("t={now},v1={}", sdk::compute_signature("whsec_test", &now, body))
}

#[test]
fn event_verifies_and_parses() {
    let body = r#"{
      "id": "id 1",
      "object": "event",
      "type": "account.qr_code_issued",
      "createdAt": "2026-09-24T09:00:00.000Z",
      "organizationId": "organizationId 1",
      "projectId": "projectId 1",
      "data": {
        "object": {
          "object": "account",
          "id": "id 1",
          "projectId": "projectId 1",
          "name": "name 1",
          "status": "initializing",
          "reconnecting": true,
          "phone": "phone 1",
          "profileName": "profileName 1",
          "proxyLocation": {
            "country": "country 1",
            "city": "city 1",
            "strictCity": false
          },
          "qrCodeUrl": "qrCodeUrl 1",
          "pairingCode": "pairingCode 1",
          "pairingCodeExpiresAt": "2026-09-24T09:00:00.000Z",
          "billable": true,
          "disconnectReason": "disconnectReason 1",
          "lastError": "lastError 1",
          "rejectCalls": true,
          "rejectCallsMessage": "rejectCallsMessage 1",
          "pacing": {
            "messagesPerMinute": 0,
            "firstContactPerMinute": 0,
            "typing": {
              "enabled": true,
              "minMs": 0,
              "maxMs": 0,
              "charsPerSecond": 5
            },
            "queueTimeoutMinutes": 1,
            "custom": true
          },
          "historySync": "none",
          "mediaAutoDownload": "none",
          "imageQuality": "standard",
          "contactAutoSave": {
            "enabled": true,
            "trigger": "first_inbound",
            "nameTemplate": "nameTemplate 1",
            "fallbackName": "fallbackName 1",
            "dailyLimit": 1
          },
          "metadata": {
            "key": "value 1"
          },
          "linkedAt": "2026-09-24T09:00:00.000Z",
          "lastConnectedAt": "2026-09-24T09:00:00.000Z",
          "createdAt": "2026-09-24T09:00:00.000Z",
          "updatedAt": "2026-09-24T09:00:00.000Z"
        }
      }
    }"#;
    let event = sdk::verify_webhook(body, &signed(body), "whsec_test").unwrap();
    support::assert_json(&event, &support::json(body));
    let error = sdk::verify_webhook(body, &signed("{}"), "whsec_test").unwrap_err();
    assert!(matches!(error, sdk::WebhookVerificationError::SignatureMismatch));
}