chore: improve billing api
This commit is contained in:
parent
4623077cdd
commit
013653bc66
|
|
@ -161,4 +161,25 @@ impl Client {
|
|||
.await?
|
||||
.into_data()
|
||||
}
|
||||
|
||||
/// Query all active subscription, minimal information but faster
|
||||
pub async fn get_active_workspace_subscriptions(
|
||||
&self,
|
||||
workspace_id: &str,
|
||||
) -> Result<Vec<SubscriptionPlan>, AppResponseError> {
|
||||
let url = format!(
|
||||
"{}/billing/api/v1/active-subscription/{}",
|
||||
self.base_billing_url(),
|
||||
workspace_id
|
||||
);
|
||||
let resp = self
|
||||
.http_client_with_auth(Method::GET, &url)
|
||||
.await?
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
AppResponse::<Vec<SubscriptionPlan>>::from_response(resp)
|
||||
.await?
|
||||
.into_data()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,17 +80,18 @@ pub enum SubscriptionStatus {
|
|||
Unpaid,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct WorkspaceSubscriptionStatus {
|
||||
pub workspace_id: String,
|
||||
pub workspace_plan: SubscriptionPlan,
|
||||
pub recurring_interval: RecurringInterval,
|
||||
pub subscription_status: SubscriptionStatus,
|
||||
pub subscription_quantity: u64,
|
||||
pub canceled_at: Option<i64>,
|
||||
pub cancel_at: Option<i64>,
|
||||
pub current_end_date: i64,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct WorkspaceUsageAndLimit {
|
||||
pub member_count: i64,
|
||||
pub member_count_limit: i64,
|
||||
|
|
|
|||
Loading…
Reference in New Issue