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
use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;
pub struct LedgersClient {
pub http_client: HttpClient,
}
impl LedgersClient {
pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
Ok(Self {
http_client: HttpClient::new(config.clone())?,
})
}
/// Returns a financial report — balance activity, income statement, or balance summary — for an account over a date range.
///
/// # Arguments
///
/// * `account_id` - The owning account ID (a biz_ identifier), or `global` for a platform-wide report across all ledger accounts (requires internal admin access).
/// * `report_type` - The type of financial report to generate.
/// * `currency` - Filter rows to this currency, for example `usd`. Defaults to `usd` unless `in_currency` is provided.
/// * `in_currency` - Aggregate all activity into this display currency via FX conversion.
/// * `from_date` - Start of the report window as an ISO 8601 timestamp (UTC). Required for platform-wide (global) reports.
/// * `to_date` - End of the report window as an ISO 8601 timestamp (UTC). Required for platform-wide (global) reports.
/// * `group_by` - Grouping granularity for report rows.
/// * `timezone` - IANA timezone (for example `America/New_York`) used to bucket report periods and to interpret calendar-day boundaries for balance snapshots. Defaults to UTC. from_date/to_date remain exact instants regardless of this setting.
/// * `cumulative` - Platform-wide (global) reports only: when true, return cumulative balances as of to_date (all history, no lower bound) instead of activity within the period.
/// * `scope_account_id` - Platform-wide (global) reports only: narrow the report to ledger lines on the ledger account owned by this account ID (a biz_ identifier). Ignored unless account_id is `global`.
/// * `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
/// .ledgers
/// .get_financial_report(
/// &GetFinancialReportQueryRequest {
/// account_id: "account_id".to_string(),
/// report_type: GetFinancialReportRequestReportType::BalanceSummary,
/// currency: None,
/// in_currency: None,
/// from_date: None,
/// to_date: None,
/// group_by: None,
/// timezone: None,
/// cumulative: None,
/// scope_account_id: None,
/// },
/// None,
/// )
/// .await;
/// }
/// ```
pub async fn get_financial_report(
&self,
request: &GetFinancialReportQueryRequest,
options: Option<RequestOptions>,
) -> Result<GetFinancialReportResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
"financial_reports",
None,
QueryBuilder::new()
.string("account_id", request.account_id.clone())
.serialize("report_type", Some(request.report_type.clone()))
.string("currency", request.currency.clone())
.string("in_currency", request.in_currency.clone())
.string("from_date", request.from_date.clone())
.string("to_date", request.to_date.clone())
.serialize("group_by", request.group_by.clone())
.string("timezone", request.timezone.clone())
.bool("cumulative", request.cumulative.clone())
.string("scope_account_id", request.scope_account_id.clone())
.build(),
options,
)
.await
}
}