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
use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;
pub struct FinancialActivityClient {
pub http_client: HttpClient,
}
impl FinancialActivityClient {
pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
Ok(Self {
http_client: HttpClient::new(config.clone())?,
})
}
/// Returns an account's or user's activity feed: every movement of money in or out.
///
/// # 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.
/// * `include_owned_accounts` - When true, aggregates the authenticated user's personal ledger with the businesses they own (owner role with balance read) into one feed. Requires user_id to be the authenticated user; cannot be combined with account_id or the settlement-date filters. Each returned row includes the owning `account`.
/// * `include_resource` - Whether to include the `resource` field in the response or not. Consider passing `false` if you need a fast response without as many rich details.
/// * `line_types` - Optional ledger line categories to include. Some categories (for example `onchain_deposit`, which covers inbound crypto deposits such as MoonPay onramps) are only returned when explicitly requested here.
/// * `currency` - Optional currency code filter, for example `usd`.
/// * `posted_after` - Only include rows posted after this ISO 8601 timestamp.
/// * `posted_before` - Only include rows posted before this ISO 8601 timestamp.
/// * `available_after` - Only include rows whose funds became withdrawable on or after this `YYYY-MM-DD` settlement date (UTC), distinct from posted_at. Requires currency.
/// * `available_before` - Only include rows whose funds became withdrawable on or before this `YYYY-MM-DD` settlement date (UTC). Set equal to available_after for a single day. Requires currency.
/// * `limit` - Maximum number of rows to return.
/// * `cursor` - Cursor returned by the previous page.
/// * `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
/// .financial_activity
/// .list(
/// &FinancialActivityListQueryRequest {
/// account_id: None,
/// user_id: None,
/// include_owned_accounts: None,
/// include_resource: None,
/// line_types: vec![],
/// currency: None,
/// posted_after: None,
/// posted_before: None,
/// available_after: None,
/// available_before: None,
/// limit: None,
/// cursor: None,
/// },
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn list(
&self,
request: &FinancialActivityListQueryRequest,
options: Option<RequestOptions>,
) -> Result<ListFinancialActivityResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
"financial-activity",
None,
QueryBuilder::new()
.string("account_id", request.account_id.clone())
.string("user_id", request.user_id.clone())
.bool(
"include_owned_accounts",
request.include_owned_accounts.clone(),
)
.bool("include_resource", request.include_resource.clone())
.serialize_array("line_types", request.line_types.clone())
.string("currency", request.currency.clone())
.datetime("posted_after", request.posted_after.clone())
.datetime("posted_before", request.posted_before.clone())
.date("available_after", request.available_after.clone())
.date("available_before", request.available_before.clone())
.int("limit", request.limit.clone())
.string("cursor", request.cursor.clone())
.build(),
options,
)
.await
}
}