Skip to main content

highlevel_api/apis/payments/
client.rs

1use super::types::*;
2use crate::{error::Result, http::HttpClient};
3use std::sync::Arc;
4
5pub struct PaymentsApi {
6    http: Arc<HttpClient>,
7}
8
9impl PaymentsApi {
10    pub fn new(http: Arc<HttpClient>) -> Self {
11        Self { http }
12    }
13
14    pub async fn list_orders(&self, params: &GetOrdersParams) -> Result<GetOrdersResponse> {
15        self.http.get_with_query("/payments/orders", params).await
16    }
17
18    pub async fn get_order(&self, order_id: &str) -> Result<GetOrderResponse> {
19        self.http.get(&format!("/payments/orders/{order_id}")).await
20    }
21
22    pub async fn list_transactions(
23        &self,
24        params: &GetTransactionsParams,
25    ) -> Result<GetTransactionsResponse> {
26        self.http
27            .get_with_query("/payments/transactions", params)
28            .await
29    }
30
31    pub async fn get_transaction(&self, transaction_id: &str) -> Result<GetTransactionResponse> {
32        self.http
33            .get(&format!("/payments/transactions/{transaction_id}"))
34            .await
35    }
36
37    pub async fn list_subscriptions(
38        &self,
39        params: &GetSubscriptionsParams,
40    ) -> Result<GetSubscriptionsResponse> {
41        self.http
42            .get_with_query("/payments/subscriptions", params)
43            .await
44    }
45
46    pub async fn get_subscription(&self, subscription_id: &str) -> Result<serde_json::Value> {
47        self.http
48            .get(&format!("/payments/subscriptions/{subscription_id}"))
49            .await
50    }
51}