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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// 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::pagination::Paginator;
use crate::types;
/// The `contacts` methods.
#[derive(Clone, Debug)]
pub struct ContactsResource {
http: HttpClient,
}
impl ContactsResource {
pub(crate) fn new(http: HttpClient) -> Self {
Self { http }
}
/// Check numbers on WhatsApp
///
/// Which numbers have WhatsApp. Read-only: works for a suspended project.
///
/// `POST /v1/accounts/{accountId}/contacts/check`
///
/// Sends `Idempotency-Key` (a random key, or your own with `.idempotency_key(..)`), so it is retried on timeouts, network errors, `429` and `5xx` without repeating its effect.
pub fn check(
&self,
account_id: &str,
params: types::ContactsCheckParams,
) -> Request<types::ContactCheckList> {
let parts = RequestParts::new(Method::Post, format!("/v1/accounts/{}/contacts/check", encode_path(account_id)))
.body(¶ms)
.keyed();
self.http.request(parts)
}
/// Look up contacts
///
/// About text, picture id, verified business name and device count. Read-only.
///
/// `POST /v1/accounts/{accountId}/contacts/lookup`
///
/// Sends `Idempotency-Key` (a random key, or your own with `.idempotency_key(..)`), so it is retried on timeouts, network errors, `429` and `5xx` without repeating its effect.
pub fn lookup(
&self,
account_id: &str,
params: types::ContactsLookupParams,
) -> Request<types::ContactList> {
let parts = RequestParts::new(Method::Post, format!("/v1/accounts/{}/contacts/lookup", encode_path(account_id)))
.body(¶ms)
.keyed();
self.http.request(parts)
}
/// Get a profile picture
///
/// The contact's profile picture, if this account can see it.
///
/// `GET /v1/accounts/{accountId}/contacts/{contactId}/picture`
///
/// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
pub fn get_picture(
&self,
account_id: &str,
contact_id: &str,
params: types::ContactsGetPictureParams,
) -> Request<types::Picture> {
let parts = RequestParts::new(Method::Get, format!("/v1/accounts/{}/contacts/{}/picture", encode_path(account_id), encode_path(contact_id)))
.query_opt("preview", params.preview.as_ref())
.retryable();
self.http.request(parts)
}
/// Get a business profile
///
/// The WhatsApp Business profile of a contact.
///
/// `GET /v1/accounts/{accountId}/contacts/{contactId}/business-profile`
///
/// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
pub fn get_business_profile(
&self,
account_id: &str,
contact_id: &str,
) -> Request<types::BusinessProfile> {
let parts = RequestParts::new(Method::Get, format!("/v1/accounts/{}/contacts/{}/business-profile", encode_path(account_id), encode_path(contact_id)))
.retryable();
self.http.request(parts)
}
/// Subscribe to a contact's presence
///
/// Receive `contact.presence_updated` events for the contact. Needs the engine's extended events; otherwise `400 not_supported`.
///
/// `POST /v1/accounts/{accountId}/contacts/{contactId}/subscribe-presence`
///
/// Sends `Idempotency-Key` (a random key, or your own with `.idempotency_key(..)`), so it is retried on timeouts, network errors, `429` and `5xx` without repeating its effect.
pub fn subscribe_presence(&self, account_id: &str, contact_id: &str) -> Request<()> {
let parts = RequestParts::new(Method::Post, format!("/v1/accounts/{}/contacts/{}/subscribe-presence", encode_path(account_id), encode_path(contact_id)))
.keyed()
.no_content();
self.http.request(parts)
}
/// Block a contact
///
/// The contact can no longer message or call the account.
///
/// `POST /v1/accounts/{accountId}/contacts/{contactId}/block`
///
/// Sends `Idempotency-Key` (a random key, or your own with `.idempotency_key(..)`), so it is retried on timeouts, network errors, `429` and `5xx` without repeating its effect.
pub fn block(&self, account_id: &str, contact_id: &str) -> Request<()> {
let parts = RequestParts::new(Method::Post, format!("/v1/accounts/{}/contacts/{}/block", encode_path(account_id), encode_path(contact_id)))
.keyed()
.no_content();
self.http.request(parts)
}
/// Unblock a contact
///
/// Remove the contact from the blocklist.
///
/// `POST /v1/accounts/{accountId}/contacts/{contactId}/unblock`
///
/// Sends `Idempotency-Key` (a random key, or your own with `.idempotency_key(..)`), so it is retried on timeouts, network errors, `429` and `5xx` without repeating its effect.
pub fn unblock(&self, account_id: &str, contact_id: &str) -> Request<()> {
let parts = RequestParts::new(Method::Post, format!("/v1/accounts/{}/contacts/{}/unblock", encode_path(account_id), encode_path(contact_id)))
.keyed()
.no_content();
self.http.request(parts)
}
/// List blocked contacts
///
/// The account's blocklist, read live from WhatsApp. `contactId` is the contact as WhatsApp lists it (often a LID); `phone` and `lid` add the number and the LID when the account knows them.
///
/// `GET /v1/accounts/{accountId}/blocklist`
///
/// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
pub fn list_blocked(
&self,
account_id: &str,
params: types::ContactsListBlockedParams,
) -> Paginator<types::BlockedContactList> {
let parts = RequestParts::new(Method::Get, format!("/v1/accounts/{}/blocklist", encode_path(account_id)))
.query_opt("limit", params.limit.as_ref())
.retryable();
Paginator::new(self.http.clone(), parts, "cursor", params.cursor)
}
/// Get the account's contact link
///
/// The account's own contact QR link.
///
/// `GET /v1/accounts/{accountId}/contact-link`
///
/// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
pub fn get_link(&self, account_id: &str) -> Request<types::ContactLink> {
let parts = RequestParts::new(Method::Get, format!("/v1/accounts/{}/contact-link", encode_path(account_id)))
.retryable();
self.http.request(parts)
}
/// Reset the account's contact link
///
/// Revoke the current contact link and return a new one.
///
/// `POST /v1/accounts/{accountId}/contact-link/reset`
///
/// Sends `Idempotency-Key` (a random key, or your own with `.idempotency_key(..)`), so it is retried on timeouts, network errors, `429` and `5xx` without repeating its effect.
pub fn reset_link(&self, account_id: &str) -> Request<types::ContactLink> {
let parts = RequestParts::new(Method::Post, format!("/v1/accounts/{}/contact-link/reset", encode_path(account_id)))
.keyed();
self.http.request(parts)
}
/// Resolve a contact or business link
///
/// Who a contact QR link or a business message link points to. Read-only. `400 not_supported` when WhatsApp does not offer link resolution to this account.
///
/// `POST /v1/accounts/{accountId}/links/resolve`
///
/// Sends `Idempotency-Key` (a random key, or your own with `.idempotency_key(..)`), so it is retried on timeouts, network errors, `429` and `5xx` without repeating its effect.
pub fn resolve_link(
&self,
account_id: &str,
params: types::ContactsResolveLinkParams,
) -> Request<types::ResolvedLink> {
let parts = RequestParts::new(Method::Post, format!("/v1/accounts/{}/links/resolve", encode_path(account_id)))
.body(¶ms)
.keyed();
self.http.request(parts)
}
}