wuapi 0.9.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, encode_path};
use crate::types;

/// The `labels` methods.
#[derive(Clone, Debug)]
pub struct LabelsResource {
    http: HttpClient,
}

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

    /// Create or edit a label
    ///
    /// Creates the label with this id, or edits it. WhatsApp Business accounts only; others answer `400 not_supported`.
    ///
    /// `PUT /v1/accounts/{accountId}/labels/{labelId}`
    ///
    /// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
    pub fn upsert(
        &self,
        account_id: &str,
        label_id: &str,
        params: types::LabelsUpsertParams,
    ) -> Request<types::Label> {
        let parts = RequestParts::new(Method::Put, format!("/v1/accounts/{}/labels/{}", encode_path(account_id), encode_path(label_id)))
            .body(&params)
            .retryable();
        self.http.request(parts)
    }

    /// Delete a label
    ///
    /// WhatsApp Business accounts only.
    ///
    /// `DELETE /v1/accounts/{accountId}/labels/{labelId}`
    ///
    /// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
    pub fn delete(&self, account_id: &str, label_id: &str) -> Request<()> {
        let parts = RequestParts::new(Method::Delete, format!("/v1/accounts/{}/labels/{}", encode_path(account_id), encode_path(label_id)))
            .retryable()
            .no_content();
        self.http.request(parts)
    }
}