wuapi 0.15.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`.

use crate::http::{HttpClient, Method, Request, RequestParts};
use crate::types;

/// Billable usage, and the per-project export for rebilling.
#[derive(Clone, Debug)]
pub struct UsageResource {
    http: HttpClient,
}

impl UsageResource {
    pub(crate) fn new(http: HttpClient) -> Self {
        Self { http }
    }

    /// Get usage
    ///
    /// Billable usage for the current calendar month (UTC). Organization keys only (project keys get `403 forbidden`); the `Wuapi-Project` header does not change the result.
    ///
    /// `GET /v1/usage`
    ///
    /// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
    pub fn get(&self) -> Request<types::Usage> {
        let parts = RequestParts::new(Method::Get, "/v1/usage").retryable();
        self.http.request(parts)
    }

    /// Get usage by project
    ///
    /// The rebilling export for `month` (default the current month): one line per project, plus unassigned resources and totals. Organization keys only (project keys get `403 forbidden`); the `Wuapi-Project` header does not change the result.
    ///
    /// `GET /v1/usage/by-project`
    ///
    /// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
    pub fn by_project(&self, params: types::UsageByProjectParams) -> Request<types::UsageReport> {
        let parts = RequestParts::new(Method::Get, "/v1/usage/by-project")
            .query_opt("month", params.month.as_ref())
            .retryable();
        self.http.request(parts)
    }
}