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
use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;
pub mod methods;
pub use methods::MethodsClient;
pub mod supported_methods;
pub use supported_methods::SupportedMethodsClient;
pub struct PayoutsClient {
pub http_client: HttpClient,
pub methods: MethodsClient,
pub supported_methods: SupportedMethodsClient,
}
impl PayoutsClient {
pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
Ok(Self {
http_client: HttpClient::new(config.clone())?,
methods: MethodsClient::new(config.clone())?,
supported_methods: SupportedMethodsClient::new(config.clone())?,
})
}
/// Lists an account's or user's payouts, 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.
/// * `currency` - Optional currency code filter, for example `usd`.
/// * `status` - Filter to payouts whose `status` reads this word, matching exactly what this version displays — `reversed` finds settled payouts the bank later returned. Requires Api-Version-Date 2026-08-21 or later.
/// * `source` - Filter by how the payout was created. Payouts created before source tracking or through internal tooling carry no source and never match.
/// * `payout_method_id` - Filter to payouts sent to one saved payout method (a pytk_ identifier). An unknown id matches nothing.
/// * `created_before` - Only payouts created before this ISO 8601 time (exclusive).
/// * `created_after` - Only payouts created at or after this ISO 8601 time (inclusive).
/// * `first` - Number of payouts to return from the start of the window.
/// * `after` - Cursor to fetch the page after (from page_info.end_cursor).
/// * `last` - Number of payouts 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
/// .list(
/// &PayoutsListQueryRequest {
/// ..Default::default()
/// },
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn list(
&self,
request: &PayoutsListQueryRequest,
options: Option<RequestOptions>,
) -> Result<ListPayoutsResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
"payouts",
None,
QueryBuilder::new()
.string("account_id", request.account_id.clone())
.string("user_id", request.user_id.clone())
.string("currency", request.currency.clone())
.serialize("status", request.status.clone())
.serialize("source", request.source.clone())
.string("payout_method_id", request.payout_method_id.clone())
.datetime("created_before", request.created_before.clone())
.datetime("created_after", request.created_after.clone())
.int("first", request.first.clone())
.string("after", request.after.clone())
.int("last", request.last.clone())
.string("before", request.before.clone())
.build(),
options,
)
.await
}
/// Sends money from an account or user balance to a saved payout method for that owner.
///
/// # 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
/// .create(
/// &CreatePayoutsRequestBody::Unknown(serde_json::json!({"key":"value"})),
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn create(
&self,
request: &CreatePayoutsRequestBody,
options: Option<RequestOptions>,
) -> Result<CreatePayoutsResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"payouts",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Fetches one payout by its `wdrl_` ID, or by the `cofr_` conversion request ID a stablecoin payout carries as `payout_request_id` — both ids answer with the same payout object.
///
/// # Arguments
///
/// * `id` - Payout ID, prefixed `wdrl_` for a payout returned by `GET /payouts` or `cofr_` for the payout request returned by `POST /payouts`.
/// * `account_id` - Owning account ID, prefixed `biz_`. Provide exactly one of `account_id` or `user_id`.
/// * `user_id` - Owning user ID, prefixed `user_`. Provide exactly one of `account_id` or `user_id`.
/// * `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
/// .retrieve(
/// &"id".to_string(),
/// &PayoutsRetrieveQueryRequest {
/// ..Default::default()
/// },
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn retrieve(
&self,
id: &str,
request: &PayoutsRetrieveQueryRequest,
options: Option<RequestOptions>,
) -> Result<RetrievePayoutsResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
&format!("payouts/{}", id),
None,
QueryBuilder::new()
.string("account_id", request.account_id.clone())
.string("user_id", request.user_id.clone())
.build(),
options,
)
.await
}
}