1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// 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(¶ms)
.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)
}
}