feat: add subscription free trial
This commit is contained in:
parent
fe0667ed20
commit
87083d503a
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::Client;
|
use crate::Client;
|
||||||
use client_api_entity::billing_dto::{
|
use client_api_entity::billing_dto::{
|
||||||
SetSubscriptionRecurringInterval, SubscriptionCancelRequest, SubscriptionLinkRequest,
|
SetSubscriptionRecurringInterval, SubscriptionCancelRequest, SubscriptionLinkRequest,
|
||||||
SubscriptionPlanDetail, WorkspaceUsageAndLimit,
|
SubscriptionPlanDetail, SubscriptionTrialRequest, WorkspaceUsageAndLimit,
|
||||||
};
|
};
|
||||||
use reqwest::Method;
|
use reqwest::Method;
|
||||||
use shared_entity::{
|
use shared_entity::{
|
||||||
|
|
@ -215,4 +215,24 @@ impl Client {
|
||||||
.await?
|
.await?
|
||||||
.into_data()
|
.into_data()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// request a free trial for plan
|
||||||
|
pub async fn post_subscription_free_trial(
|
||||||
|
&self,
|
||||||
|
workspace_id: &str,
|
||||||
|
plan: SubscriptionPlan,
|
||||||
|
) -> Result<(), AppResponseError> {
|
||||||
|
let url = format!(
|
||||||
|
"{}/billing/api/v1/subscription-trial/{}",
|
||||||
|
self.base_billing_url(),
|
||||||
|
workspace_id
|
||||||
|
);
|
||||||
|
let resp = self
|
||||||
|
.cloud_client
|
||||||
|
.post(&url)
|
||||||
|
.query(&SubscriptionTrialRequest { plan })
|
||||||
|
.send()
|
||||||
|
.await?;
|
||||||
|
AppResponse::<()>::from_response(resp).await?.into_error()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,3 +157,8 @@ pub struct SubscriptionLinkRequest<'a> {
|
||||||
pub success_url: &'a str,
|
pub success_url: &'a str,
|
||||||
pub with_test_clock: Option<bool>,
|
pub with_test_clock: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct SubscriptionTrialRequest {
|
||||||
|
pub plan: SubscriptionPlan,
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue