wuapi 0.5.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 linked number's privacy settings.
#[derive(Clone, Debug)]
pub struct PrivacyResource {
    http: HttpClient,
}

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

    /// Get privacy settings
    ///
    /// The account's privacy settings, read live from WhatsApp.
    ///
    /// `GET /v1/accounts/{accountId}/privacy`
    ///
    /// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
    pub fn get(&self, account_id: &str) -> Request<types::PrivacySettings> {
        let parts = RequestParts::new(Method::Get, format!("/v1/accounts/{}/privacy", encode_path(account_id)))
            .retryable();
        self.http.request(parts)
    }

    /// Change privacy settings
    ///
    /// Change one or more settings. Each setting is one change on WhatsApp. Returns every setting after the change.
    ///
    /// `PATCH /v1/accounts/{accountId}/privacy`
    ///
    /// Not idempotent: retried only when the request never reached the API or was refused with `429`.
    pub fn update(
        &self,
        account_id: &str,
        params: types::PrivacyUpdateParams,
    ) -> Request<types::PrivacySettings> {
        let parts = RequestParts::new(Method::Patch, format!("/v1/accounts/{}/privacy", encode_path(account_id)))
            .body(&params);
        self.http.request(parts)
    }

    /// Get story privacy
    ///
    /// Who sees the account's stories.
    ///
    /// `GET /v1/accounts/{accountId}/privacy/stories`
    ///
    /// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
    pub fn get_story_privacy(&self, account_id: &str) -> Request<types::StoryPrivacy> {
        let parts = RequestParts::new(Method::Get, format!("/v1/accounts/{}/privacy/stories", encode_path(account_id)))
            .retryable();
        self.http.request(parts)
    }
}