chore: add more param for plan cancellation
This commit is contained in:
parent
430fbf845a
commit
8a2ba59ce8
|
|
@ -54,7 +54,7 @@ impl Client {
|
|||
("recurring_interval", recurring_interval.as_str()),
|
||||
(
|
||||
"workspace_subscription_plan",
|
||||
workspace_subscription_plan.as_str(),
|
||||
workspace_subscription_plan.as_ref(),
|
||||
),
|
||||
("success_url", success_url),
|
||||
])
|
||||
|
|
@ -66,7 +66,11 @@ impl Client {
|
|||
.into_data()
|
||||
}
|
||||
|
||||
pub async fn cancel_subscription(&self, workspace_id: &str) -> Result<(), AppResponseError> {
|
||||
pub async fn cancel_subscription(
|
||||
&self,
|
||||
workspace_id: &str,
|
||||
plan: &SubscriptionPlan,
|
||||
) -> Result<(), AppResponseError> {
|
||||
let url = format!(
|
||||
"{}/billing/api/v1/cancel-subscription",
|
||||
self.base_billing_url()
|
||||
|
|
@ -74,7 +78,10 @@ impl Client {
|
|||
let resp = self
|
||||
.http_client_with_auth(Method::POST, &url)
|
||||
.await?
|
||||
.json(&json!({ "workspace_id": workspace_id }))
|
||||
.json(&json!({
|
||||
"workspace_id": workspace_id,
|
||||
"plan": plan.as_ref(),
|
||||
}))
|
||||
.send()
|
||||
.await?;
|
||||
AppResponse::<()>::from_response(resp).await?.into_error()
|
||||
|
|
|
|||
|
|
@ -16,31 +16,31 @@ impl RecurringInterval {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum SubscriptionPlan {
|
||||
Pro,
|
||||
Team,
|
||||
}
|
||||
|
||||
impl SubscriptionPlan {
|
||||
pub fn as_str(&self) -> &str {
|
||||
match self {
|
||||
SubscriptionPlan::Pro => "pro",
|
||||
SubscriptionPlan::Team => "team",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[repr(i16)]
|
||||
pub enum WorkspaceSubscriptionPlan {
|
||||
pub enum SubscriptionPlan {
|
||||
Unknown = -1,
|
||||
|
||||
Free = 0,
|
||||
Pro = 1,
|
||||
Team = 2,
|
||||
|
||||
AIMax = 3,
|
||||
AILocal = 4,
|
||||
}
|
||||
|
||||
impl AsRef<str> for SubscriptionPlan {
|
||||
fn as_ref(&self) -> &str {
|
||||
match self {
|
||||
SubscriptionPlan::Free => "free",
|
||||
SubscriptionPlan::Pro => "pro",
|
||||
SubscriptionPlan::Team => "team",
|
||||
SubscriptionPlan::AIMax => "ai_max",
|
||||
SubscriptionPlan::AILocal => "ai_local",
|
||||
SubscriptionPlan::Unknown => "unknown",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
|
||||
|
|
@ -59,7 +59,7 @@ pub enum SubscriptionStatus {
|
|||
#[derive(Deserialize, Debug)]
|
||||
pub struct WorkspaceSubscriptionStatus {
|
||||
pub workspace_id: String,
|
||||
pub workspace_plan: WorkspaceSubscriptionPlan,
|
||||
pub workspace_plan: SubscriptionPlan,
|
||||
pub recurring_interval: RecurringInterval,
|
||||
pub subscription_status: SubscriptionStatus,
|
||||
pub subscription_quantity: u64,
|
||||
|
|
|
|||
Loading…
Reference in New Issue