use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;
pub struct PartnersClient {
pub http_client: HttpClient,
}
impl PartnersClient {
pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
Ok(Self {
http_client: HttpClient::new(config.clone())?,
})
}
pub async fn get_available_funding(
&self,
options: Option<RequestOptions>,
) -> Result<Vec<AvailableFunding>, ApiError> {
self.http_client
.execute_request(
Method::GET,
"v2/partners/available-funding",
None,
None,
options,
)
.await
}
pub async fn create_partner_data(
&self,
request: &PartnerDataCreatePayload,
options: Option<RequestOptions>,
) -> Result<PartnerDataResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"v2/partners/data",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
pub async fn list_partner_waterfalls(
&self,
request: &ListPartnerWaterfallsQueryRequest,
options: Option<RequestOptions>,
) -> Result<PaginatedResponseWaterfallResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
"v2/partners/waterfalls",
None,
QueryBuilder::new()
.serialize("page", request.page.clone())
.serialize("page_size", request.page_size.clone())
.serialize("order_by", request.order_by.clone())
.serialize("q", request.q.clone())
.build(),
options,
)
.await
}
}