use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, RequestOptions};
use reqwest::Method;
pub struct CheckoutSessionsClient {
pub http_client: HttpClient,
}
impl CheckoutSessionsClient {
pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
Ok(Self {
http_client: HttpClient::new(config.clone())?,
})
}
pub async fn create(
&self,
request: &CheckoutSessionCreateRequest,
options: Option<RequestOptions>,
) -> Result<CheckoutSessionResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"checkout-sessions",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
pub async fn get(
&self,
id: &str,
options: Option<RequestOptions>,
) -> Result<CheckoutSessionResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
&format!("checkout-sessions/{}", id),
None,
None,
options,
)
.await
}
}