feat: use subscription req struct
This commit is contained in:
parent
73127fb886
commit
fe0667ed20
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::Client;
|
use crate::Client;
|
||||||
use client_api_entity::billing_dto::{
|
use client_api_entity::billing_dto::{
|
||||||
SetSubscriptionRecurringInterval, SubscriptionCancelRequest, SubscriptionPlanDetail,
|
SetSubscriptionRecurringInterval, SubscriptionCancelRequest, SubscriptionLinkRequest,
|
||||||
WorkspaceUsageAndLimit,
|
SubscriptionPlanDetail, WorkspaceUsageAndLimit,
|
||||||
};
|
};
|
||||||
use reqwest::Method;
|
use reqwest::Method;
|
||||||
use shared_entity::{
|
use shared_entity::{
|
||||||
|
|
@ -44,6 +44,14 @@ impl Client {
|
||||||
workspace_subscription_plan: SubscriptionPlan,
|
workspace_subscription_plan: SubscriptionPlan,
|
||||||
success_url: &str,
|
success_url: &str,
|
||||||
) -> Result<String, AppResponseError> {
|
) -> Result<String, AppResponseError> {
|
||||||
|
let sub_link_req = SubscriptionLinkRequest {
|
||||||
|
workspace_subscription_plan,
|
||||||
|
recurring_interval,
|
||||||
|
workspace_id,
|
||||||
|
success_url,
|
||||||
|
with_test_clock: None,
|
||||||
|
};
|
||||||
|
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"{}/billing/api/v1/subscription-link",
|
"{}/billing/api/v1/subscription-link",
|
||||||
self.base_billing_url()
|
self.base_billing_url()
|
||||||
|
|
@ -51,15 +59,7 @@ impl Client {
|
||||||
let resp = self
|
let resp = self
|
||||||
.http_client_with_auth(Method::GET, &url)
|
.http_client_with_auth(Method::GET, &url)
|
||||||
.await?
|
.await?
|
||||||
.query(&[
|
.query(&sub_link_req)
|
||||||
("workspace_id", workspace_id),
|
|
||||||
("recurring_interval", recurring_interval.as_str()),
|
|
||||||
(
|
|
||||||
"workspace_subscription_plan",
|
|
||||||
workspace_subscription_plan.as_ref(),
|
|
||||||
),
|
|
||||||
("success_url", success_url),
|
|
||||||
])
|
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,3 +148,12 @@ pub enum Currency {
|
||||||
#[default]
|
#[default]
|
||||||
USD,
|
USD,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct SubscriptionLinkRequest<'a> {
|
||||||
|
pub workspace_subscription_plan: SubscriptionPlan,
|
||||||
|
pub recurring_interval: RecurringInterval,
|
||||||
|
pub workspace_id: &'a str,
|
||||||
|
pub success_url: &'a str,
|
||||||
|
pub with_test_clock: Option<bool>,
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue