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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;
pub struct MethodsClient {
pub http_client: HttpClient,
}
impl MethodsClient {
pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
Ok(Self {
http_client: HttpClient::new(config.clone())?,
})
}
/// Lists the bank accounts, wallets, and crypto addresses an account or user can withdraw to, newest first.
///
/// # Arguments
///
/// * `account_id` - The owning account ID (a biz_ identifier). Provide this or user_id.
/// * `user_id` - The owning user ID (a user_ identifier). Provide this or account_id.
/// * `status` - Optional status filter. `created` means saved but unused, `active` means a payout through it succeeded, `broken` means the last payout failed and the method needs fixing.
/// * `amount` - Optional withdrawal amount in whole currency units, for example `250.00`. When provided, each method includes a quote with the estimated fee, amount received, and delivery date for that amount.
/// * `currency` - Currency code of the amount, for example `usd`. Only meaningful with amount or include_limits.
/// * `include_limits` - When true, the response also carries limits — the live per-speed payout caps the account's payout requests are validated against, in the requested currency. Requires the payout:withdrawal:read scope.
/// * `first` - Number of payout methods to return from the start of the window.
/// * `after` - Cursor to fetch the page after (from page_info.end_cursor).
/// * `last` - Number of payout methods to return from the end of the window.
/// * `before` - Cursor to fetch the page before (from page_info.start_cursor).
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
///
/// # Examples
///
/// ```no_run
/// use whop_sdk::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// token: Some("<token>".to_string()),
/// ..Default::default()
/// };
/// let client = Whop::new(config).expect("Failed to build client");
/// client
/// .payouts
/// .methods
/// .list(
/// &PayoutsMethodsListQueryRequest {
/// ..Default::default()
/// },
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn list(
&self,
request: &PayoutsMethodsListQueryRequest,
options: Option<RequestOptions>,
) -> Result<ListMethodsResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
"payouts/methods",
None,
QueryBuilder::new()
.string("account_id", request.account_id.clone())
.string("user_id", request.user_id.clone())
.serialize("status", request.status.clone())
.float("amount", request.amount.clone())
.string("currency", request.currency.clone())
.bool("include_limits", request.include_limits.clone())
.int("first", request.first.clone())
.string("after", request.after.clone())
.int("last", request.last.clone())
.string("before", request.before.clone())
.build(),
options,
)
.await
}
/// Saves a new place an account or user can withdraw to. Sensitive details are vaulted in transit and never stored raw.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
///
/// # Examples
///
/// ```no_run
/// use whop_sdk::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// token: Some("<token>".to_string()),
/// ..Default::default()
/// };
/// let client = Whop::new(config).expect("Failed to build client");
/// client
/// .payouts
/// .methods
/// .create(
/// &CreateMethodsRequest {
/// supported_payout_method_id: "podst_xxxxxxxxxxxxxx".to_string(),
/// account_id: None,
/// destination_currency: None,
/// fields: None,
/// is_default: None,
/// nickname: None,
/// user_id: None,
/// },
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn create(
&self,
request: &CreateMethodsRequest,
options: Option<RequestOptions>,
) -> Result<CreateMethodsResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"payouts/methods",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Deletes a saved payout method so it can no longer receive payouts.
///
/// # Arguments
///
/// * `id` - Payout method ID, prefixed `potk_`.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
///
/// # Examples
///
/// ```no_run
/// use whop_sdk::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// token: Some("<token>".to_string()),
/// ..Default::default()
/// };
/// let client = Whop::new(config).expect("Failed to build client");
/// client.payouts.methods.delete(&"id".to_string(), None).await;
/// }
/// ```
pub async fn delete(
&self,
id: &str,
options: Option<RequestOptions>,
) -> Result<DeleteMethodsResponse, ApiError> {
self.http_client
.execute_request(
Method::DELETE,
&format!("payouts/methods/{}", id),
None,
None,
options,
)
.await
}
/// Changes the label used to identify a saved payout method.
///
/// # Arguments
///
/// * `id` - Payout method ID, prefixed `potk_`.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
///
/// # Examples
///
/// ```no_run
/// use whop_sdk::prelude::*;
///
/// #[tokio::main]
/// async fn main() {
/// let config = ClientConfig {
/// token: Some("<token>".to_string()),
/// ..Default::default()
/// };
/// let client = Whop::new(config).expect("Failed to build client");
/// client
/// .payouts
/// .methods
/// .update(
/// &"id".to_string(),
/// &UpdateMethodsRequest {
/// nickname: "Primary checking".to_string(),
/// },
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn update(
&self,
id: &str,
request: &UpdateMethodsRequest,
options: Option<RequestOptions>,
) -> Result<UpdateMethodsResponse, ApiError> {
self.http_client
.execute_request(
Method::PATCH,
&format!("payouts/methods/{}", id),
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
}