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
//! Fees API endpoints.
use crate::client::RestClient;
use crate::error::Result;
use crate::models::{TransactionSummary, TransactionSummaryParams};
/// API for retrieving fee information.
///
/// This API provides endpoints for querying fee tiers and transaction summaries.
pub struct FeesApi<'a> {
client: &'a RestClient,
}
impl<'a> FeesApi<'a> {
/// Create a new Fees API instance.
pub(crate) fn new(client: &'a RestClient) -> Self {
Self { client }
}
/// Get the transaction summary including fee tier information.
///
/// # Example
///
/// ```no_run
/// # use coinbase_advanced::{RestClient, Credentials};
/// # async fn example() -> coinbase_advanced::Result<()> {
/// let client = RestClient::builder()
/// .credentials(Credentials::from_env()?)
/// .build()?;
///
/// let summary = client.fees().get_transaction_summary().await?;
/// println!("Fee tier: {}", summary.fee_tier.pricing_tier);
/// println!("Maker fee rate: {}", summary.fee_tier.maker_fee_rate);
/// println!("Taker fee rate: {}", summary.fee_tier.taker_fee_rate);
/// # Ok(())
/// # }
/// ```
pub async fn get_transaction_summary(&self) -> Result<TransactionSummary> {
self.get_transaction_summary_with_params(TransactionSummaryParams::default())
.await
}
/// Get the transaction summary with custom parameters.
///
/// # Example
///
/// ```no_run
/// # use coinbase_advanced::{RestClient, Credentials, models::TransactionSummaryParams};
/// # async fn example() -> coinbase_advanced::Result<()> {
/// let client = RestClient::builder()
/// .credentials(Credentials::from_env()?)
/// .build()?;
///
/// let params = TransactionSummaryParams::new()
/// .product_type("SPOT");
///
/// let summary = client.fees()
/// .get_transaction_summary_with_params(params)
/// .await?;
/// # Ok(())
/// # }
/// ```
pub async fn get_transaction_summary_with_params(
&self,
params: TransactionSummaryParams,
) -> Result<TransactionSummary> {
self.client
.get_with_query("/transaction_summary", ¶ms)
.await
}
}