wuapi 0.13.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 own About text, display name and picture.
#[derive(Clone, Debug)]
pub struct ProfileResource {
    http: HttpClient,
}

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

    /// Update the About text or display name
    ///
    /// WhatsApp cannot be read back here, so this answers 204. `about` and `name` are two changes on WhatsApp.
    ///
    /// `PATCH /v1/accounts/{accountId}/profile`
    ///
    /// 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::ProfileUpdateParams) -> Request<()> {
        let parts = RequestParts::new(Method::Patch, format!("/v1/accounts/{}/profile", encode_path(account_id)))
            .body(&params)
            .no_content();
        self.http.request(parts)
    }

    /// Set the profile picture
    ///
    /// JPEG, from an https URL or base64.
    ///
    /// `PUT /v1/accounts/{accountId}/profile/picture`
    ///
    /// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
    pub fn set_picture(
        &self,
        account_id: &str,
        params: impl Into<types::ProfileSetPictureParams>,
    ) -> Request<types::Picture> {
        let params = params.into();
        let parts = RequestParts::new(Method::Put, format!("/v1/accounts/{}/profile/picture", encode_path(account_id)))
            .body(&params)
            .retryable();
        self.http.request(parts)
    }

    /// Delete the profile picture
    ///
    /// Remove the account's profile picture.
    ///
    /// `DELETE /v1/accounts/{accountId}/profile/picture`
    ///
    /// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
    pub fn delete_picture(&self, account_id: &str) -> Request<()> {
        let parts = RequestParts::new(Method::Delete, format!("/v1/accounts/{}/profile/picture", encode_path(account_id)))
            .retryable()
            .no_content();
        self.http.request(parts)
    }
}