use reqwest::Method;
use crate::client::Client;
use crate::error::VynFiError;
use crate::types::*;
pub struct Credits<'a> {
client: &'a Client,
}
impl<'a> Credits<'a> {
pub(crate) fn new(client: &'a Client) -> Self {
Self { client }
}
pub async fn purchase(
&self,
req: &PurchaseCreditsRequest,
) -> Result<PurchaseCreditsResponse, VynFiError> {
self.client
.request_with_body(Method::POST, "/v1/credits/purchase", Some(req))
.await
}
pub async fn balance(&self) -> Result<PrepaidBalanceResponse, VynFiError> {
self.client
.request(Method::GET, "/v1/credits/balance")
.await
}
pub async fn history(&self) -> Result<PrepaidHistoryResponse, VynFiError> {
self.client
.request(Method::GET, "/v1/credits/history")
.await
}
}