highlevel-api 0.2.0

Unofficial Rust SDK for the GoHighLevel (HighLevel) API
Documentation
use super::types::*;
use crate::{error::Result, http::HttpClient};
use std::sync::Arc;

pub struct PaymentsApi {
    http: Arc<HttpClient>,
}

impl PaymentsApi {
    pub fn new(http: Arc<HttpClient>) -> Self {
        Self { http }
    }

    pub async fn list_orders(&self, params: &GetOrdersParams) -> Result<GetOrdersResponse> {
        self.http.get_with_query("/payments/orders", params).await
    }

    pub async fn get_order(&self, order_id: &str) -> Result<GetOrderResponse> {
        self.http.get(&format!("/payments/orders/{order_id}")).await
    }

    pub async fn list_transactions(
        &self,
        params: &GetTransactionsParams,
    ) -> Result<GetTransactionsResponse> {
        self.http
            .get_with_query("/payments/transactions", params)
            .await
    }

    pub async fn get_transaction(&self, transaction_id: &str) -> Result<GetTransactionResponse> {
        self.http
            .get(&format!("/payments/transactions/{transaction_id}"))
            .await
    }

    pub async fn list_subscriptions(
        &self,
        params: &GetSubscriptionsParams,
    ) -> Result<GetSubscriptionsResponse> {
        self.http
            .get_with_query("/payments/subscriptions", params)
            .await
    }

    pub async fn get_subscription(&self, subscription_id: &str) -> Result<serde_json::Value> {
        self.http
            .get(&format!("/payments/subscriptions/{subscription_id}"))
            .await
    }
}