use reqwest::Method;
use crate::client::{extract_list, Client};
use crate::error::VynFiError;
use crate::types::*;
pub struct Billing<'a> {
client: &'a Client,
}
impl<'a> Billing<'a> {
pub(crate) fn new(client: &'a Client) -> Self {
Self { client }
}
pub async fn subscription(&self) -> Result<Subscription, VynFiError> {
self.client
.request(Method::GET, "/v1/billing/subscription")
.await
}
pub async fn invoices(&self) -> Result<Vec<Invoice>, VynFiError> {
let value: serde_json::Value = self
.client
.request(Method::GET, "/v1/billing/invoices")
.await?;
extract_list(value)
}
pub async fn payment_method(&self) -> Result<PaymentMethod, VynFiError> {
self.client
.request(Method::GET, "/v1/billing/payment-method")
.await
}
}