polyoxide_data/api/accounting.rs
1use polyoxide_core::HttpClient;
2
3use crate::error::DataApiError;
4
5/// Accounting namespace — `GET /v1/accounting/snapshot`.
6///
7/// Downloads a ZIP archive containing `positions.csv` and `equity.csv` for a
8/// given user. The response is returned as raw bytes so callers can hand the
9/// archive off to their own zip/CSV tooling.
10#[derive(Clone)]
11pub struct AccountingApi {
12 pub(crate) http_client: HttpClient,
13}
14
15impl AccountingApi {
16 /// Download an accounting snapshot ZIP for `user_address`.
17 ///
18 /// The returned `Vec<u8>` is the `application/zip` body verbatim; this
19 /// method does not parse or validate the archive contents.
20 pub async fn snapshot(&self, user_address: impl Into<String>) -> Result<Vec<u8>, DataApiError> {
21 let query = [("user".to_string(), user_address.into())];
22 self.http_client
23 .get_bytes("/v1/accounting/snapshot", &query)
24 .await
25 .map_err(DataApiError::from)
26 }
27}