chore: update subscription entity (#1162)

This commit is contained in:
Nathan.fooo 2025-01-14 17:35:27 +08:00 committed by GitHub
parent c5cdb06b77
commit 56f4c0698c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 22 deletions

View File

@ -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, SubscriptionTrialRequest, WorkspaceUsageAndLimit, SubscriptionPlanDetail, WorkspaceUsageAndLimit,
}; };
use reqwest::Method; use reqwest::Method;
use shared_entity::{ use shared_entity::{
@ -222,24 +222,4 @@ 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()
}
} }

View File

@ -163,4 +163,7 @@ pub struct SubscriptionLinkRequest {
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub struct SubscriptionTrialRequest { pub struct SubscriptionTrialRequest {
pub plan: SubscriptionPlan, pub plan: SubscriptionPlan,
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub period_days: Option<u32>,
} }

View File

@ -50,6 +50,7 @@ use std::collections::{HashMap, HashSet};
use std::env::temp_dir; use std::env::temp_dir;
use std::fmt::Display; use std::fmt::Display;
use std::fs::Permissions; use std::fs::Permissions;
use std::io::ErrorKind;
use std::ops::DerefMut; use std::ops::DerefMut;
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
@ -596,7 +597,11 @@ async fn process_task(
"[Import]: {} deleted unzip file: {:?}", "[Import]: {} deleted unzip file: {:?}",
task.workspace_id, unzip_dir_path task.workspace_id, unzip_dir_path
), ),
Err(err) => error!("Failed to delete unzip file: {:?}", err), Err(err) => {
if err.kind() != ErrorKind::NotFound {
error!("Failed to delete unzip file: {:?}", err);
}
},
} }
}); });
}, },