// This file is auto-generated by oagen. Do not edit.
use crate::client::Client;
#[allow(unused_imports)]
use crate::enums::*;
use crate::error::Error;
#[allow(unused_imports)]
use crate::models::*;
#[allow(unused_imports)]
use serde::Serialize;
pub struct SubscriptionsApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct CancelParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkCancelSubscriptionRequestApplicationJson,
}
impl CancelParams {
/// Construct a new `CancelParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkCancelSubscriptionRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetCapabilitiesParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct CancelAtPeriodEndParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkCancelSubscriptionAtPeriodEndRequestApplicationJson,
}
impl CancelAtPeriodEndParams {
/// Construct a new `CancelAtPeriodEndParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkCancelSubscriptionAtPeriodEndRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CancelImmediatelyParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkCancelSubscriptionImmediatelyRequestApplicationJson,
}
impl CancelImmediatelyParams {
/// Construct a new `CancelImmediatelyParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkCancelSubscriptionImmediatelyRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct PauseParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkPauseSubscriptionRequestApplicationJson,
}
impl PauseParams {
/// Construct a new `PauseParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkPauseSubscriptionRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ResumeParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkResumeSubscriptionRequestApplicationJson,
}
impl ResumeParams {
/// Construct a new `ResumeParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkResumeSubscriptionRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdatePaymentMethodParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkUpdateSubscriptionPaymentMethodRequestApplicationJson,
}
impl UpdatePaymentMethodParams {
/// Construct a new `UpdatePaymentMethodParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkUpdateSubscriptionPaymentMethodRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct PreviewPlanChangeParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkPreviewSubscriptionPlanChangeRequestApplicationJson,
}
impl PreviewPlanChangeParams {
/// Construct a new `PreviewPlanChangeParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkPreviewSubscriptionPlanChangeRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ConfirmPlanChangeParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkConfirmSubscriptionPlanChangeRequestApplicationJson,
}
impl ConfirmPlanChangeParams {
/// Construct a new `ConfirmPlanChangeParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkConfirmSubscriptionPlanChangeRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct PreviewRenewalDateParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkPreviewSubscriptionRenewalDateChangeRequestApplicationJson,
}
impl PreviewRenewalDateParams {
/// Construct a new `PreviewRenewalDateParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkPreviewSubscriptionRenewalDateChangeRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ConfirmRenewalDateParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkConfirmSubscriptionRenewalDateChangeRequestApplicationJson,
}
impl ConfirmRenewalDateParams {
/// Construct a new `ConfirmRenewalDateParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkConfirmSubscriptionRenewalDateChangeRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListSubscriptionsParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct SearchSubscriptionsParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkSearchSubscriptionsRequestApplicationJson,
}
impl SearchSubscriptionsParams {
/// Construct a new `SearchSubscriptionsParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkSearchSubscriptionsRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetSubscriptionParams {
/// Store slug. Required for OAuth access tokens. API keys may omit it to use their current store, or the first accessible store when no current store is selected.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
impl<'a> SubscriptionsApi<'a> {
/// Cancel a subscription
///
/// Cancel an active subscription now or at period end. cancel_at_period_end is required. Refund flags are valid only when it is false; period-end cancellation does not refund the last payment. Refunds are off by default. refund_last_payment requests a real refund; pro_rated_refund requires refund_last_payment and defaults to false. Cancellation can succeed even if the requested refund fails. A 200 response or confirmed cancellation does not prove a refund, and the action response does not expose the provider refund result. Check the order and payment-provider refund records before retrying; do not replay cancellation as a refund-recovery step. Reuse an idempotency key only with identical action input and actor. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn cancel(
&self,
subscription: &str,
params: CancelParams,
) -> Result<SdkCancelSubscriptionResponseValue200ApplicationJson, Error> {
self.cancel_with_options(subscription, params, None).await
}
/// Variant of [`Self::cancel`] that accepts per-request [`crate::RequestOptions`].
pub async fn cancel_with_options(
&self,
subscription: &str,
params: CancelParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCancelSubscriptionResponseValue200ApplicationJson, Error> {
self.cancel_raw(subscription, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn cancel_raw(
&self,
subscription: &str,
params: CancelParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkCancelSubscriptionResponseValue200ApplicationJson>, Error>
{
let subscription = crate::client::path_segment(subscription);
let path = format!("/v2/subscriptions/{subscription}/cancel");
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("cancelSubscription".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/subscriptions/{subscription}/cancel",
)
.await
}
/// View subscription capabilities
///
/// Return the lifecycle actions currently supported for a subscription. Capability status controls whether an actor can pause, resume, cancel, update the payment method, change plan, or shift the billing date. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn get_capabilities(
&self,
product_subscription: &str,
params: GetCapabilitiesParams,
) -> Result<SdkGetSubscriptionCapabilitiesResponseValue200ApplicationJson, Error> {
self.get_capabilities_with_options(product_subscription, params, None)
.await
}
/// Variant of [`Self::get_capabilities`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_capabilities_with_options(
&self,
product_subscription: &str,
params: GetCapabilitiesParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetSubscriptionCapabilitiesResponseValue200ApplicationJson, Error> {
self.get_capabilities_raw(product_subscription, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn get_capabilities_raw(
&self,
product_subscription: &str,
params: GetCapabilitiesParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkGetSubscriptionCapabilitiesResponseValue200ApplicationJson>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!("/v2/subscriptions/{product_subscription}/capabilities");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getSubscriptionCapabilities".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/subscriptions/{productSubscription}/capabilities",
)
.await
}
/// Cancel a subscription at period end
///
/// Schedule cancellation at the end of the current billing period without requesting a refund. Inspect capabilities first. The response records the cancellation action; retrieve the subscription to observe its current state. Reuse an idempotency key only with identical action input and actor. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn cancel_at_period_end(
&self,
product_subscription: &str,
params: CancelAtPeriodEndParams,
) -> Result<SdkCancelSubscriptionAtPeriodEndResponseValue200ApplicationJson, Error> {
self.cancel_at_period_end_with_options(product_subscription, params, None)
.await
}
/// Variant of [`Self::cancel_at_period_end`] that accepts per-request [`crate::RequestOptions`].
pub async fn cancel_at_period_end_with_options(
&self,
product_subscription: &str,
params: CancelAtPeriodEndParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCancelSubscriptionAtPeriodEndResponseValue200ApplicationJson, Error> {
self.cancel_at_period_end_raw(product_subscription, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn cancel_at_period_end_raw(
&self,
product_subscription: &str,
params: CancelAtPeriodEndParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkCancelSubscriptionAtPeriodEndResponseValue200ApplicationJson>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!("/v2/subscriptions/{product_subscription}/actions/cancel-period-end");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("cancelSubscriptionAtPeriodEnd".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/subscriptions/{productSubscription}/actions/cancel-period-end",
)
.await
}
/// Cancel a subscription immediately
///
/// Request immediate subscription cancellation. Inspect capabilities for provider support. This ends future billing and can change customer access. Refunds are off by default. refund_last_payment requests a real refund; pro_rated_refund requires refund_last_payment and defaults to false. Cancellation can succeed even if the requested refund fails. A 200 response or confirmed cancellation does not prove a refund, and the action response does not expose the provider refund result. Check the order and payment-provider refund records before retrying; do not replay cancellation as a refund-recovery step. Reuse an idempotency key only with identical action input and actor. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn cancel_immediately(
&self,
product_subscription: &str,
params: CancelImmediatelyParams,
) -> Result<SdkCancelSubscriptionImmediatelyResponseValue200ApplicationJson, Error> {
self.cancel_immediately_with_options(product_subscription, params, None)
.await
}
/// Variant of [`Self::cancel_immediately`] that accepts per-request [`crate::RequestOptions`].
pub async fn cancel_immediately_with_options(
&self,
product_subscription: &str,
params: CancelImmediatelyParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCancelSubscriptionImmediatelyResponseValue200ApplicationJson, Error> {
self.cancel_immediately_raw(product_subscription, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn cancel_immediately_raw(
&self,
product_subscription: &str,
params: CancelImmediatelyParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkCancelSubscriptionImmediatelyResponseValue200ApplicationJson>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!("/v2/subscriptions/{product_subscription}/actions/cancel-immediately");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("cancelSubscriptionImmediately".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/subscriptions/{productSubscription}/actions/cancel-immediately",
)
.await
}
/// Pause a subscription
///
/// Pause a subscription after checking capabilities. Automatic resume dates are supported only by the current Stripe flow; use a future resume_at when supplied. Other provider pauses may need an explicit resume action. Customer-originated pauses are also subject to store pause policies. Reuse an idempotency key only with identical input and actor, and retrieve the subscription after the action. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn pause(
&self,
product_subscription: &str,
params: PauseParams,
) -> Result<SdkPauseSubscriptionResponseValue200ApplicationJson, Error> {
self.pause_with_options(product_subscription, params, None)
.await
}
/// Variant of [`Self::pause`] that accepts per-request [`crate::RequestOptions`].
pub async fn pause_with_options(
&self,
product_subscription: &str,
params: PauseParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkPauseSubscriptionResponseValue200ApplicationJson, Error> {
self.pause_raw(product_subscription, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn pause_raw(
&self,
product_subscription: &str,
params: PauseParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkPauseSubscriptionResponseValue200ApplicationJson>, Error>
{
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!("/v2/subscriptions/{product_subscription}/actions/pause");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("pauseSubscription".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/subscriptions/{productSubscription}/actions/pause",
)
.await
}
/// Resume a subscription
///
/// Resume a paused subscription and restore related entitlements where possible. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn resume(
&self,
product_subscription: &str,
params: ResumeParams,
) -> Result<SdkResumeSubscriptionResponseValue200ApplicationJson, Error> {
self.resume_with_options(product_subscription, params, None)
.await
}
/// Variant of [`Self::resume`] that accepts per-request [`crate::RequestOptions`].
pub async fn resume_with_options(
&self,
product_subscription: &str,
params: ResumeParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkResumeSubscriptionResponseValue200ApplicationJson, Error> {
self.resume_raw(product_subscription, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn resume_raw(
&self,
product_subscription: &str,
params: ResumeParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkResumeSubscriptionResponseValue200ApplicationJson>, Error>
{
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!("/v2/subscriptions/{product_subscription}/actions/resume");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("resumeSubscription".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/subscriptions/{productSubscription}/actions/resume",
)
.await
}
/// Update a subscription payment method
///
/// This action belongs to the customer. Seller API requests return a 422 validation error. Check subscription capabilities and use the customer flow; never expose a seller API key to work around this restriction. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn update_payment_method(
&self,
product_subscription: &str,
params: UpdatePaymentMethodParams,
) -> Result<String, Error> {
self.update_payment_method_with_options(product_subscription, params, None)
.await
}
/// Variant of [`Self::update_payment_method`] that accepts per-request [`crate::RequestOptions`].
pub async fn update_payment_method_with_options(
&self,
product_subscription: &str,
params: UpdatePaymentMethodParams,
options: Option<&crate::RequestOptions>,
) -> Result<String, Error> {
self.update_payment_method_raw(product_subscription, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn update_payment_method_raw(
&self,
product_subscription: &str,
params: UpdatePaymentMethodParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<String>, Error> {
let product_subscription = crate::client::path_segment(product_subscription);
let path =
format!("/v2/subscriptions/{product_subscription}/actions/update-payment-method");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("updateSubscriptionPaymentMethod".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/subscriptions/{productSubscription}/actions/update-payment-method",
)
.await
}
/// Preview a subscription plan change
///
/// This action belongs to the customer. Seller API requests return a 422 validation error. Check subscription capabilities and use the customer flow; never expose a seller API key to work around this restriction. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn preview_plan_change(
&self,
product_subscription: &str,
params: PreviewPlanChangeParams,
) -> Result<String, Error> {
self.preview_plan_change_with_options(product_subscription, params, None)
.await
}
/// Variant of [`Self::preview_plan_change`] that accepts per-request [`crate::RequestOptions`].
pub async fn preview_plan_change_with_options(
&self,
product_subscription: &str,
params: PreviewPlanChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<String, Error> {
self.preview_plan_change_raw(product_subscription, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn preview_plan_change_raw(
&self,
product_subscription: &str,
params: PreviewPlanChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<String>, Error> {
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!("/v2/subscriptions/{product_subscription}/actions/change-plan/preview");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("previewSubscriptionPlanChange".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/subscriptions/{productSubscription}/actions/change-plan/preview",
)
.await
}
/// Confirm a subscription plan change
///
/// This action belongs to the customer. Seller API requests return a 422 validation error. Check subscription capabilities and use the customer flow; never expose a seller API key to work around this restriction. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn confirm_plan_change(
&self,
product_subscription: &str,
params: ConfirmPlanChangeParams,
) -> Result<String, Error> {
self.confirm_plan_change_with_options(product_subscription, params, None)
.await
}
/// Variant of [`Self::confirm_plan_change`] that accepts per-request [`crate::RequestOptions`].
pub async fn confirm_plan_change_with_options(
&self,
product_subscription: &str,
params: ConfirmPlanChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<String, Error> {
self.confirm_plan_change_raw(product_subscription, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn confirm_plan_change_raw(
&self,
product_subscription: &str,
params: ConfirmPlanChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<String>, Error> {
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!("/v2/subscriptions/{product_subscription}/actions/change-plan/confirm");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("confirmSubscriptionPlanChange".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/subscriptions/{productSubscription}/actions/change-plan/confirm",
)
.await
}
/// Preview a subscription renewal date change
///
/// Preview a new renewal date before confirmation when the subscription's billing-date policy requires a preview. The current Stripe and PayPal provider flows do not support renewal-date changes and return 422. Check shift_billing_date capabilities before sending a request. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn preview_renewal_date(
&self,
product_subscription: &str,
params: PreviewRenewalDateParams,
) -> Result<SdkPreviewSubscriptionRenewalDateChangeResponseValue200ApplicationJson, Error> {
self.preview_renewal_date_with_options(product_subscription, params, None)
.await
}
/// Variant of [`Self::preview_renewal_date`] that accepts per-request [`crate::RequestOptions`].
pub async fn preview_renewal_date_with_options(
&self,
product_subscription: &str,
params: PreviewRenewalDateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkPreviewSubscriptionRenewalDateChangeResponseValue200ApplicationJson, Error> {
self.preview_renewal_date_raw(product_subscription, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn preview_renewal_date_raw(
&self,
product_subscription: &str,
params: PreviewRenewalDateParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkPreviewSubscriptionRenewalDateChangeResponseValue200ApplicationJson>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path =
format!("/v2/subscriptions/{product_subscription}/actions/change-renewal-date/preview");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("previewSubscriptionRenewalDateChange".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/subscriptions/{productSubscription}/actions/change-renewal-date/preview",
)
.await
}
/// Confirm a subscription renewal date change
///
/// Confirm a subscription renewal date change. A preview token is required when the variant's billing-date policy requires previews. The current Stripe and PayPal provider flows do not support renewal-date changes and return 422. Check shift_billing_date capabilities before sending a request. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn confirm_renewal_date(
&self,
product_subscription: &str,
params: ConfirmRenewalDateParams,
) -> Result<SdkConfirmSubscriptionRenewalDateChangeResponseValue200ApplicationJson, Error> {
self.confirm_renewal_date_with_options(product_subscription, params, None)
.await
}
/// Variant of [`Self::confirm_renewal_date`] that accepts per-request [`crate::RequestOptions`].
pub async fn confirm_renewal_date_with_options(
&self,
product_subscription: &str,
params: ConfirmRenewalDateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkConfirmSubscriptionRenewalDateChangeResponseValue200ApplicationJson, Error> {
self.confirm_renewal_date_raw(product_subscription, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn confirm_renewal_date_raw(
&self,
product_subscription: &str,
params: ConfirmRenewalDateParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkConfirmSubscriptionRenewalDateChangeResponseValue200ApplicationJson>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path =
format!("/v2/subscriptions/{product_subscription}/actions/change-renewal-date/confirm");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("confirmSubscriptionRenewalDateChange".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/subscriptions/{productSubscription}/actions/change-renewal-date/confirm",
)
.await
}
/// List subscriptions
///
/// List page-based subscriptions with canonical customer and deprecated provider aliases. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn list_subscriptions(
&self,
params: ListSubscriptionsParams,
) -> Result<SdkListSubscriptionsResponseValue200ApplicationJson, Error> {
self.list_subscriptions_with_options(params, None).await
}
/// Variant of [`Self::list_subscriptions`] that accepts per-request [`crate::RequestOptions`].
pub async fn list_subscriptions_with_options(
&self,
params: ListSubscriptionsParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListSubscriptionsResponseValue200ApplicationJson, Error> {
self.list_subscriptions_raw(params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn list_subscriptions_raw(
&self,
params: ListSubscriptionsParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkListSubscriptionsResponseValue200ApplicationJson>, Error>
{
let path = "/v2/subscriptions".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listSubscriptions".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/subscriptions",
)
.await
}
/// Search subscriptions
///
/// Search while preserving page-based pagination. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn search_subscriptions(
&self,
params: SearchSubscriptionsParams,
) -> Result<SdkSearchSubscriptionsResponseValue200ApplicationJson, Error> {
self.search_subscriptions_with_options(params, None).await
}
/// Variant of [`Self::search_subscriptions`] that accepts per-request [`crate::RequestOptions`].
pub async fn search_subscriptions_with_options(
&self,
params: SearchSubscriptionsParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkSearchSubscriptionsResponseValue200ApplicationJson, Error> {
self.search_subscriptions_raw(params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn search_subscriptions_raw(
&self,
params: SearchSubscriptionsParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkSearchSubscriptionsResponseValue200ApplicationJson>, Error>
{
let path = "/v2/subscriptions/search".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("searchSubscriptions".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/subscriptions/search",
)
.await
}
/// Retrieve a subscription
///
/// Retrieve by SellApp subscription record ID. OAuth callers use the admin grant and select a store with X-STORE. Current membership and role permissions apply to every request.
pub async fn get_subscription(
&self,
product_subscription: &str,
params: GetSubscriptionParams,
) -> Result<SdkGetSubscriptionResponseValue200ApplicationJson, Error> {
self.get_subscription_with_options(product_subscription, params, None)
.await
}
/// Variant of [`Self::get_subscription`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_subscription_with_options(
&self,
product_subscription: &str,
params: GetSubscriptionParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetSubscriptionResponseValue200ApplicationJson, Error> {
self.get_subscription_raw(product_subscription, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn get_subscription_raw(
&self,
product_subscription: &str,
params: GetSubscriptionParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkGetSubscriptionResponseValue200ApplicationJson>, Error> {
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!("/v2/subscriptions/{product_subscription}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getSubscription".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/subscriptions/{productSubscription}",
)
.await
}
}