Merge pull request #695 from AppFlowy-IO/feat/billing-subscription-details
Feat/billing subscription details
This commit is contained in:
commit
1ee0896eb7
|
|
@ -1,6 +1,7 @@
|
|||
use crate::Client;
|
||||
use client_api_entity::billing_dto::{
|
||||
SetSubscriptionRecurringInterval, SubscriptionCancelRequest, WorkspaceUsageAndLimit,
|
||||
SetSubscriptionRecurringInterval, SubscriptionCancelRequest, SubscriptionPlanDetail,
|
||||
WorkspaceUsageAndLimit,
|
||||
};
|
||||
use reqwest::Method;
|
||||
use shared_entity::{
|
||||
|
|
@ -198,4 +199,20 @@ impl Client {
|
|||
|
||||
AppResponse::<()>::from_response(resp).await?.into_error()
|
||||
}
|
||||
|
||||
/// get all subscription plan details
|
||||
pub async fn get_subscription_plan_details(
|
||||
&self,
|
||||
) -> Result<Vec<SubscriptionPlanDetail>, AppResponseError> {
|
||||
let url = format!("{}/billing/api/v1/subscriptions", self.base_billing_url(),);
|
||||
let resp = self
|
||||
.http_client_with_auth(Method::GET, &url)
|
||||
.await?
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
AppResponse::<Vec<SubscriptionPlanDetail>>::from_response(resp)
|
||||
.await?
|
||||
.into_data()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,3 +134,17 @@ pub struct SetSubscriptionRecurringInterval {
|
|||
pub plan: SubscriptionPlan,
|
||||
pub recurring_interval: RecurringInterval,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SubscriptionPlanDetail {
|
||||
pub currency: Currency,
|
||||
pub price_cents: i64,
|
||||
pub recurring_interval: RecurringInterval,
|
||||
pub plan: SubscriptionPlan,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq, Hash, Default)]
|
||||
pub enum Currency {
|
||||
#[default]
|
||||
USD,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue