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
// 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;
/// A hosted page you send to someone else, your customer, a store manager or a sales rep, so they link their own WhatsApp into one of your projects without an account, a dashboard or an API key. The page is public at `https://wuapi.dev/invite/{token}`, `noindex`, and shows nothing about your other projects, accounts or invitations.
#[derive(Clone, Debug)]
pub struct InvitationsResource {
http: HttpClient,
}
impl InvitationsResource {
pub(crate) fn new(http: HttpClient) -> Self {
Self { http }
}
/// Create an invitation
///
/// A hosted page (`url`) where someone else links their own WhatsApp into your project: they pick where the number's proxy exits (unless you set `proxyLocation`), then scan a QR code or type a pairing code. The account is created in the project when they start, and `invitation.status_changed` fires at each step. With `inviteeEmail`, the invitation is emailed when email is enabled (`emailSentAt`).
///
/// `POST /v1/invitations`
///
/// 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 create(&self, params: types::InvitationsCreateParams) -> Request<types::Invitation> {
let parts = RequestParts::new(Method::Post, "/v1/invitations").body(¶ms).keyed();
self.http.request(parts)
}
/// List invitations
///
/// Invitations in scope, newest first. `url` is always `null` here.
///
/// `GET /v1/invitations`
///
/// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
pub fn list(&self, params: types::InvitationsListParams) -> Paginator<types::InvitationList> {
let parts = RequestParts::new(Method::Get, "/v1/invitations")
.query_opt("status", params.status.as_ref())
.query_opt("limit", params.limit.as_ref())
.query_opt("projectId", params.project_id.as_ref())
.retryable();
Paginator::new(self.http.clone(), parts, "cursor", params.cursor)
}
/// Get an invitation
///
/// `url` is always `null` here.
///
/// `GET /v1/invitations/{invitationId}`
///
/// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
pub fn get(&self, invitation_id: &str) -> Request<types::Invitation> {
let parts = RequestParts::new(Method::Get, format!("/v1/invitations/{}", encode_path(invitation_id)))
.retryable();
self.http.request(parts)
}
/// Cancel an invitation
///
/// The link stops working. Cancelling a cancelled invitation changes nothing. An account the invitee already started stays in the project, unlinked.
///
/// `POST /v1/invitations/{invitationId}/cancel`
///
/// 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 cancel(&self, invitation_id: &str) -> Request<types::Invitation> {
let parts = RequestParts::new(Method::Post, format!("/v1/invitations/{}/cancel", encode_path(invitation_id)))
.keyed();
self.http.request(parts)
}
/// Resend an invitation
///
/// Rotates the token (the old `url` stops working), moves the invitation back to `pending` with a new expiry of the same length, and emails it again when it has an `inviteeEmail`. An account the invitee started is kept, so they resume where they left off.
///
/// `POST /v1/invitations/{invitationId}/resend`
///
/// 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 resend(&self, invitation_id: &str) -> Request<types::Invitation> {
let parts = RequestParts::new(Method::Post, format!("/v1/invitations/{}/resend", encode_path(invitation_id)))
.keyed();
self.http.request(parts)
}
}