diff --git a/libs/client-api/src/http_billing.rs b/libs/client-api/src/http_billing.rs index 0b286ad7..2f3fc307 100644 --- a/libs/client-api/src/http_billing.rs +++ b/libs/client-api/src/http_billing.rs @@ -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, 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::>::from_response(resp) + .await? + .into_data() + } } diff --git a/libs/shared-entity/src/dto/billing_dto.rs b/libs/shared-entity/src/dto/billing_dto.rs index 8be28fe0..827ca1c0 100644 --- a/libs/shared-entity/src/dto/billing_dto.rs +++ b/libs/shared-entity/src/dto/billing_dto.rs @@ -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, +}