// 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 CustomerPortalApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateCustomerPortalProfileParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkUpdateCustomerPortalProfileRequestApplicationJson,
}
impl UpdateCustomerPortalProfileParams {
/// Construct a new `UpdateCustomerPortalProfileParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkUpdateCustomerPortalProfileRequestApplicationJson) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CancelCustomerSubscriptionAtPeriodEndParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkCancelCustomerSubscriptionAtPeriodEndRequestApplicationJson,
}
impl CancelCustomerSubscriptionAtPeriodEndParams {
/// Construct a new `CancelCustomerSubscriptionAtPeriodEndParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkCancelCustomerSubscriptionAtPeriodEndRequestApplicationJson) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CancelCustomerSubscriptionImmediatelyParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkCancelCustomerSubscriptionImmediatelyRequestApplicationJson,
}
impl CancelCustomerSubscriptionImmediatelyParams {
/// Construct a new `CancelCustomerSubscriptionImmediatelyParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkCancelCustomerSubscriptionImmediatelyRequestApplicationJson) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct PauseCustomerSubscriptionParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkPauseCustomerSubscriptionRequestApplicationJson,
}
impl PauseCustomerSubscriptionParams {
/// Construct a new `PauseCustomerSubscriptionParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkPauseCustomerSubscriptionRequestApplicationJson) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateCustomerSubscriptionPaymentMethodParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkUpdateCustomerSubscriptionPaymentMethodRequestApplicationJson,
}
impl UpdateCustomerSubscriptionPaymentMethodParams {
/// Construct a new `UpdateCustomerSubscriptionPaymentMethodParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkUpdateCustomerSubscriptionPaymentMethodRequestApplicationJson) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct PreviewCustomerSubscriptionPlanChangeParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkPreviewCustomerSubscriptionPlanChangeRequestApplicationJson,
}
impl PreviewCustomerSubscriptionPlanChangeParams {
/// Construct a new `PreviewCustomerSubscriptionPlanChangeParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkPreviewCustomerSubscriptionPlanChangeRequestApplicationJson) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ConfirmCustomerSubscriptionPlanChangeParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkConfirmCustomerSubscriptionPlanChangeRequestApplicationJson,
}
impl ConfirmCustomerSubscriptionPlanChangeParams {
/// Construct a new `ConfirmCustomerSubscriptionPlanChangeParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkConfirmCustomerSubscriptionPlanChangeRequestApplicationJson) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct PreviewCustomerSubscriptionRenewalDateChangeParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkPreviewCustomerSubscriptionRenewalDateChangeRequestApplicationJson,
}
impl PreviewCustomerSubscriptionRenewalDateChangeParams {
/// Construct a new `PreviewCustomerSubscriptionRenewalDateChangeParams` with the required fields set.
#[allow(deprecated)]
pub fn new(
body: SdkPreviewCustomerSubscriptionRenewalDateChangeRequestApplicationJson,
) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ConfirmCustomerSubscriptionRenewalDateChangeParams {
/// Request body sent with this call.
///
/// Required.
#[serde(skip)]
pub body: SdkConfirmCustomerSubscriptionRenewalDateChangeRequestApplicationJson,
}
impl ConfirmCustomerSubscriptionRenewalDateChangeParams {
/// Construct a new `ConfirmCustomerSubscriptionRenewalDateChangeParams` with the required fields set.
#[allow(deprecated)]
pub fn new(
body: SdkConfirmCustomerSubscriptionRenewalDateChangeRequestApplicationJson,
) -> Self {
Self { body }
}
}
impl<'a> CustomerPortalApi<'a> {
/// Retrieve the signed-in customer
///
/// Customer-session bearer authentication; resource is redacted.
pub async fn get_customer_portal_profile(
&self,
) -> Result<SdkGetCustomerPortalProfileResponseValue200ApplicationJson, Error> {
self.get_customer_portal_profile_with_options(None).await
}
/// Variant of [`Self::get_customer_portal_profile`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_customer_portal_profile_with_options(
&self,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetCustomerPortalProfileResponseValue200ApplicationJson, Error> {
self.get_customer_portal_profile_raw(options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn get_customer_portal_profile_raw(
&self,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkGetCustomerPortalProfileResponseValue200ApplicationJson>, Error>
{
let path = "/v2/customer-portal/me".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getCustomerPortalProfile".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
&(),
options,
"GET /v2/customer-portal/me",
)
.await
}
/// Update the signed-in customer
///
/// Update customer-safe profile fields.
pub async fn update_customer_portal_profile(
&self,
params: UpdateCustomerPortalProfileParams,
) -> Result<SdkUpdateCustomerPortalProfileResponseValue200ApplicationJson, Error> {
self.update_customer_portal_profile_with_options(params, None)
.await
}
/// Variant of [`Self::update_customer_portal_profile`] that accepts per-request [`crate::RequestOptions`].
pub async fn update_customer_portal_profile_with_options(
&self,
params: UpdateCustomerPortalProfileParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkUpdateCustomerPortalProfileResponseValue200ApplicationJson, Error> {
self.update_customer_portal_profile_raw(params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn update_customer_portal_profile_raw(
&self,
params: UpdateCustomerPortalProfileParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkUpdateCustomerPortalProfileResponseValue200ApplicationJson>,
Error,
> {
let path = "/v2/customer-portal/me".to_string();
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("updateCustomerPortalProfile".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/customer-portal/me",
)
.await
}
/// List customer orders
///
/// List purchases belonging to the customer session.
pub async fn list_customer_portal_orders(
&self,
) -> Result<SdkListCustomerPortalOrdersResponseValue200ApplicationJson, Error> {
self.list_customer_portal_orders_with_options(None).await
}
/// Variant of [`Self::list_customer_portal_orders`] that accepts per-request [`crate::RequestOptions`].
pub async fn list_customer_portal_orders_with_options(
&self,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListCustomerPortalOrdersResponseValue200ApplicationJson, Error> {
self.list_customer_portal_orders_raw(options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn list_customer_portal_orders_raw(
&self,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkListCustomerPortalOrdersResponseValue200ApplicationJson>, Error>
{
let path = "/v2/customer-portal/orders".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listCustomerPortalOrders".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
&(),
options,
"GET /v2/customer-portal/orders",
)
.await
}
/// Retrieve a customer order
///
/// Retrieve a purchase belonging to the customer session.
pub async fn get_customer_portal_order(
&self,
order: &str,
) -> Result<SdkGetCustomerPortalOrderResponseValue200ApplicationJson, Error> {
self.get_customer_portal_order_with_options(order, None)
.await
}
/// Variant of [`Self::get_customer_portal_order`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_customer_portal_order_with_options(
&self,
order: &str,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetCustomerPortalOrderResponseValue200ApplicationJson, Error> {
self.get_customer_portal_order_raw(order, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn get_customer_portal_order_raw(
&self,
order: &str,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkGetCustomerPortalOrderResponseValue200ApplicationJson>, Error>
{
let order = crate::client::path_segment(order);
let path = format!("/v2/customer-portal/orders/{order}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getCustomerPortalOrder".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
&(),
options,
"GET /v2/customer-portal/orders/{order}",
)
.await
}
/// List customer subscriptions
///
/// List subscriptions belonging to the customer session, newest first, 15 per page. `trial_ends_at` is only set while a subscription is `TRIALING`.
pub async fn list_customer_portal_subscriptions(
&self,
) -> Result<SdkListCustomerPortalSubscriptionsResponseValue200ApplicationJson, Error> {
self.list_customer_portal_subscriptions_with_options(None)
.await
}
/// Variant of [`Self::list_customer_portal_subscriptions`] that accepts per-request [`crate::RequestOptions`].
pub async fn list_customer_portal_subscriptions_with_options(
&self,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListCustomerPortalSubscriptionsResponseValue200ApplicationJson, Error> {
self.list_customer_portal_subscriptions_raw(options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn list_customer_portal_subscriptions_raw(
&self,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkListCustomerPortalSubscriptionsResponseValue200ApplicationJson>,
Error,
> {
let path = "/v2/customer-portal/subscriptions".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listCustomerPortalSubscriptions".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
&(),
options,
"GET /v2/customer-portal/subscriptions",
)
.await
}
/// Retrieve a customer subscription
///
/// Retrieve a subscription belonging to the customer session.
pub async fn get_customer_portal_subscription(
&self,
subscription: &str,
) -> Result<SdkGetCustomerPortalSubscriptionResponseValue200ApplicationJson, Error> {
self.get_customer_portal_subscription_with_options(subscription, None)
.await
}
/// Variant of [`Self::get_customer_portal_subscription`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_customer_portal_subscription_with_options(
&self,
subscription: &str,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetCustomerPortalSubscriptionResponseValue200ApplicationJson, Error> {
self.get_customer_portal_subscription_raw(subscription, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn get_customer_portal_subscription_raw(
&self,
subscription: &str,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkGetCustomerPortalSubscriptionResponseValue200ApplicationJson>,
Error,
> {
let subscription = crate::client::path_segment(subscription);
let path = format!("/v2/customer-portal/subscriptions/{subscription}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getCustomerPortalSubscription".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
&(),
options,
"GET /v2/customer-portal/subscriptions/{subscription}",
)
.await
}
/// Retrieve subscription capabilities
///
/// Read immediately before displaying lifecycle controls. Each of the nine actions (`pause`, `resume`, `cancel_at_period_end`, `cancel_immediately`, `keep_subscription`, `update_payment_method`, `change_plan`, `shift_billing_date`, and `set_auto_renew`) reports a status and the reason to show the customer when it is not available. While a Stripe, PayPal, or Razorpay subscription has a payment still owed, every action except `cancel_immediately` and, on Razorpay, `update_payment_method`, is `unsupported`. `resume` is `unsupported` on a subscription on hold for an unpaid renewal, which the customer pays and resumes on the store's customer portal page. The example is abbreviated to three of the actions.
pub async fn get_customer_portal_subscription_capabilities(
&self,
subscription: &str,
) -> Result<SdkGetCustomerPortalSubscriptionCapabilitiesResponseValue200ApplicationJson, Error>
{
self.get_customer_portal_subscription_capabilities_with_options(subscription, None)
.await
}
/// Variant of [`Self::get_customer_portal_subscription_capabilities`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_customer_portal_subscription_capabilities_with_options(
&self,
subscription: &str,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetCustomerPortalSubscriptionCapabilitiesResponseValue200ApplicationJson, Error>
{
self.get_customer_portal_subscription_capabilities_raw(subscription, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn get_customer_portal_subscription_capabilities_raw(
&self,
subscription: &str,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<
SdkGetCustomerPortalSubscriptionCapabilitiesResponseValue200ApplicationJson,
>,
Error,
> {
let subscription = crate::client::path_segment(subscription);
let path = format!("/v2/customer-portal/subscriptions/{subscription}/capabilities");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getCustomerPortalSubscriptionCapabilities".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
&(),
options,
"GET /v2/customer-portal/subscriptions/{subscription}/capabilities",
)
.await
}
/// List customer entitlements
///
/// List the customer's purchase access summary without fulfillment secrets.
pub async fn list_customer_portal_entitlements(
&self,
) -> Result<SdkListCustomerPortalEntitlementsResponseValue200ApplicationJson, Error> {
self.list_customer_portal_entitlements_with_options(None)
.await
}
/// Variant of [`Self::list_customer_portal_entitlements`] that accepts per-request [`crate::RequestOptions`].
pub async fn list_customer_portal_entitlements_with_options(
&self,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListCustomerPortalEntitlementsResponseValue200ApplicationJson, Error> {
self.list_customer_portal_entitlements_raw(options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn list_customer_portal_entitlements_raw(
&self,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkListCustomerPortalEntitlementsResponseValue200ApplicationJson>,
Error,
> {
let path = "/v2/customer-portal/entitlements".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listCustomerPortalEntitlements".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
&(),
options,
"GET /v2/customer-portal/entitlements",
)
.await
}
/// Cancel at period end
///
/// Schedule the subscription to end when the current period ends. The customer keeps access until then. Read capabilities first. A refusal returns 422 with the sentence to show the customer under `errors.subscription`.
pub async fn cancel_customer_subscription_at_period_end(
&self,
product_subscription: &str,
params: CancelCustomerSubscriptionAtPeriodEndParams,
) -> Result<SdkCancelCustomerSubscriptionAtPeriodEndResponseValue200ApplicationJson, Error>
{
self.cancel_customer_subscription_at_period_end_with_options(
product_subscription,
params,
None,
)
.await
}
/// Variant of [`Self::cancel_customer_subscription_at_period_end`] that accepts per-request [`crate::RequestOptions`].
pub async fn cancel_customer_subscription_at_period_end_with_options(
&self,
product_subscription: &str,
params: CancelCustomerSubscriptionAtPeriodEndParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCancelCustomerSubscriptionAtPeriodEndResponseValue200ApplicationJson, Error>
{
self.cancel_customer_subscription_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_customer_subscription_at_period_end_raw(
&self,
product_subscription: &str,
params: CancelCustomerSubscriptionAtPeriodEndParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkCancelCustomerSubscriptionAtPeriodEndResponseValue200ApplicationJson>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!(
"/v2/customer-portal/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("cancelCustomerSubscriptionAtPeriodEnd".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(method, &path, ¶ms, Some(¶ms.body), options, "POST /v2/customer-portal/subscriptions/{productSubscription}/actions/cancel-period-end")
.await
}
/// Cancel immediately
///
/// End the subscription now. A customer session cannot request a refund. It is the one action left on a Stripe or PayPal subscription with a payment still owed, and one of two left on a Razorpay one alongside a payment method update. Read capabilities first. A refusal returns 422 with the sentence to show the customer under `errors.subscription`.
pub async fn cancel_customer_subscription_immediately(
&self,
product_subscription: &str,
params: CancelCustomerSubscriptionImmediatelyParams,
) -> Result<SdkCancelCustomerSubscriptionImmediatelyResponseValue200ApplicationJson, Error>
{
self.cancel_customer_subscription_immediately_with_options(
product_subscription,
params,
None,
)
.await
}
/// Variant of [`Self::cancel_customer_subscription_immediately`] that accepts per-request [`crate::RequestOptions`].
pub async fn cancel_customer_subscription_immediately_with_options(
&self,
product_subscription: &str,
params: CancelCustomerSubscriptionImmediatelyParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCancelCustomerSubscriptionImmediatelyResponseValue200ApplicationJson, Error>
{
self.cancel_customer_subscription_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_customer_subscription_immediately_raw(
&self,
product_subscription: &str,
params: CancelCustomerSubscriptionImmediatelyParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkCancelCustomerSubscriptionImmediatelyResponseValue200ApplicationJson>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!(
"/v2/customer-portal/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("cancelCustomerSubscriptionImmediately".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(method, &path, ¶ms, Some(¶ms.body), options, "POST /v2/customer-portal/subscriptions/{productSubscription}/actions/cancel-immediately")
.await
}
/// Pause a subscription
///
/// Pause billing, optionally until `resume_at`. Read capabilities first. A refusal returns 422 with the sentence to show the customer under `errors.subscription`.
pub async fn pause_customer_subscription(
&self,
product_subscription: &str,
params: PauseCustomerSubscriptionParams,
) -> Result<SdkPauseCustomerSubscriptionResponseValue200ApplicationJson, Error> {
self.pause_customer_subscription_with_options(product_subscription, params, None)
.await
}
/// Variant of [`Self::pause_customer_subscription`] that accepts per-request [`crate::RequestOptions`].
pub async fn pause_customer_subscription_with_options(
&self,
product_subscription: &str,
params: PauseCustomerSubscriptionParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkPauseCustomerSubscriptionResponseValue200ApplicationJson, Error> {
self.pause_customer_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 pause_customer_subscription_raw(
&self,
product_subscription: &str,
params: PauseCustomerSubscriptionParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkPauseCustomerSubscriptionResponseValue200ApplicationJson>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path =
format!("/v2/customer-portal/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("pauseCustomerSubscription".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/customer-portal/subscriptions/{productSubscription}/actions/pause",
)
.await
}
/// Resume a subscription
///
/// Resume a paused subscription. A subscription the store bills in house that is on hold for an unpaid renewal comes back only when the customer pays that renewal on the store's customer portal page, so it is refused. Read capabilities first. A refusal returns 422 with the sentence to show the customer under `errors.subscription`.
pub async fn resume_customer_subscription(
&self,
product_subscription: &str,
) -> Result<SdkResumeCustomerSubscriptionResponseValue200ApplicationJson, Error> {
self.resume_customer_subscription_with_options(product_subscription, None)
.await
}
/// Variant of [`Self::resume_customer_subscription`] that accepts per-request [`crate::RequestOptions`].
pub async fn resume_customer_subscription_with_options(
&self,
product_subscription: &str,
options: Option<&crate::RequestOptions>,
) -> Result<SdkResumeCustomerSubscriptionResponseValue200ApplicationJson, Error> {
self.resume_customer_subscription_raw(product_subscription, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn resume_customer_subscription_raw(
&self,
product_subscription: &str,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkResumeCustomerSubscriptionResponseValue200ApplicationJson>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path =
format!("/v2/customer-portal/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("resumeCustomerSubscription".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
&(),
options,
"POST /v2/customer-portal/subscriptions/{productSubscription}/actions/resume",
)
.await
}
/// Update payment method
///
/// Start a payment method update. Send the customer to `redirect_url` to finish it with the provider. Read capabilities first. A refusal returns 422 with the sentence to show the customer under `errors.subscription`.
pub async fn update_customer_subscription_payment_method(
&self,
product_subscription: &str,
params: UpdateCustomerSubscriptionPaymentMethodParams,
) -> Result<SdkUpdateCustomerSubscriptionPaymentMethodResponseValue200ApplicationJson, Error>
{
self.update_customer_subscription_payment_method_with_options(
product_subscription,
params,
None,
)
.await
}
/// Variant of [`Self::update_customer_subscription_payment_method`] that accepts per-request [`crate::RequestOptions`].
pub async fn update_customer_subscription_payment_method_with_options(
&self,
product_subscription: &str,
params: UpdateCustomerSubscriptionPaymentMethodParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkUpdateCustomerSubscriptionPaymentMethodResponseValue200ApplicationJson, Error>
{
self.update_customer_subscription_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_customer_subscription_payment_method_raw(
&self,
product_subscription: &str,
params: UpdateCustomerSubscriptionPaymentMethodParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<
SdkUpdateCustomerSubscriptionPaymentMethodResponseValue200ApplicationJson,
>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!(
"/v2/customer-portal/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("updateCustomerSubscriptionPaymentMethod".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(method, &path, ¶ms, Some(¶ms.body), options, "POST /v2/customer-portal/subscriptions/{productSubscription}/actions/update-payment-method")
.await
}
/// Preview a plan change
///
/// Preview a plan change before confirming it. On Stripe and in-house subscriptions, `preview.payment_required` says whether confirming charges `amount_due` today or leaves any amount to the next invoice, and `preview.renewal_date` says when the subscription renews next. A plan change during a trial never charges today. Read capabilities first. A refusal returns 422 with the sentence to show the customer under `errors.subscription`.
pub async fn preview_customer_subscription_plan_change(
&self,
product_subscription: &str,
params: PreviewCustomerSubscriptionPlanChangeParams,
) -> Result<SdkPreviewCustomerSubscriptionPlanChangeResponseValue200ApplicationJson, Error>
{
self.preview_customer_subscription_plan_change_with_options(
product_subscription,
params,
None,
)
.await
}
/// Variant of [`Self::preview_customer_subscription_plan_change`] that accepts per-request [`crate::RequestOptions`].
pub async fn preview_customer_subscription_plan_change_with_options(
&self,
product_subscription: &str,
params: PreviewCustomerSubscriptionPlanChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkPreviewCustomerSubscriptionPlanChangeResponseValue200ApplicationJson, Error>
{
self.preview_customer_subscription_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_customer_subscription_plan_change_raw(
&self,
product_subscription: &str,
params: PreviewCustomerSubscriptionPlanChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkPreviewCustomerSubscriptionPlanChangeResponseValue200ApplicationJson>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!(
"/v2/customer-portal/subscriptions/{product_subscription}/actions/change-plan/preview"
);
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("previewCustomerSubscriptionPlanChange".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(method, &path, ¶ms, Some(¶ms.body), options, "POST /v2/customer-portal/subscriptions/{productSubscription}/actions/change-plan/preview")
.await
}
/// Confirm a plan change
///
/// Confirm a previewed plan change, sending back its `preview_token`. When the change still needs the customer to approve it with the provider or pay for it, the action is `pending` and `redirect_url` says where. Read capabilities first. A refusal returns 422 with the sentence to show the customer under `errors.subscription`.
pub async fn confirm_customer_subscription_plan_change(
&self,
product_subscription: &str,
params: ConfirmCustomerSubscriptionPlanChangeParams,
) -> Result<SdkConfirmCustomerSubscriptionPlanChangeResponseValue200ApplicationJson, Error>
{
self.confirm_customer_subscription_plan_change_with_options(
product_subscription,
params,
None,
)
.await
}
/// Variant of [`Self::confirm_customer_subscription_plan_change`] that accepts per-request [`crate::RequestOptions`].
pub async fn confirm_customer_subscription_plan_change_with_options(
&self,
product_subscription: &str,
params: ConfirmCustomerSubscriptionPlanChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkConfirmCustomerSubscriptionPlanChangeResponseValue200ApplicationJson, Error>
{
self.confirm_customer_subscription_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_customer_subscription_plan_change_raw(
&self,
product_subscription: &str,
params: ConfirmCustomerSubscriptionPlanChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkConfirmCustomerSubscriptionPlanChangeResponseValue200ApplicationJson>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!(
"/v2/customer-portal/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("confirmCustomerSubscriptionPlanChange".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(method, &path, ¶ms, Some(¶ms.body), options, "POST /v2/customer-portal/subscriptions/{productSubscription}/actions/change-plan/confirm")
.await
}
/// Preview a renewal-date change
///
/// Preview moving the next renewal to `renewal_date`. `preview` is the provider's own preview, so its keys differ per provider. Read capabilities first. A refusal returns 422 with the sentence to show the customer under `errors.subscription`.
pub async fn preview_customer_subscription_renewal_date_change(
&self,
product_subscription: &str,
params: PreviewCustomerSubscriptionRenewalDateChangeParams,
) -> Result<SdkPreviewCustomerSubscriptionRenewalDateChangeResponseValue200ApplicationJson, Error>
{
self.preview_customer_subscription_renewal_date_change_with_options(
product_subscription,
params,
None,
)
.await
}
/// Variant of [`Self::preview_customer_subscription_renewal_date_change`] that accepts per-request [`crate::RequestOptions`].
pub async fn preview_customer_subscription_renewal_date_change_with_options(
&self,
product_subscription: &str,
params: PreviewCustomerSubscriptionRenewalDateChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkPreviewCustomerSubscriptionRenewalDateChangeResponseValue200ApplicationJson, Error>
{
self.preview_customer_subscription_renewal_date_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_customer_subscription_renewal_date_change_raw(
&self,
product_subscription: &str,
params: PreviewCustomerSubscriptionRenewalDateChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<
SdkPreviewCustomerSubscriptionRenewalDateChangeResponseValue200ApplicationJson,
>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!(
"/v2/customer-portal/subscriptions/{product_subscription}/actions/change-renewal-date/preview"
);
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("previewCustomerSubscriptionRenewalDateChange".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(method, &path, ¶ms, Some(¶ms.body), options, "POST /v2/customer-portal/subscriptions/{productSubscription}/actions/change-renewal-date/preview")
.await
}
/// Confirm a renewal-date change
///
/// Confirm a renewal-date change, sending the `preview_token` when the plan requires a preview. Read capabilities first. A refusal returns 422 with the sentence to show the customer under `errors.subscription`.
pub async fn confirm_customer_subscription_renewal_date_change(
&self,
product_subscription: &str,
params: ConfirmCustomerSubscriptionRenewalDateChangeParams,
) -> Result<SdkConfirmCustomerSubscriptionRenewalDateChangeResponseValue200ApplicationJson, Error>
{
self.confirm_customer_subscription_renewal_date_change_with_options(
product_subscription,
params,
None,
)
.await
}
/// Variant of [`Self::confirm_customer_subscription_renewal_date_change`] that accepts per-request [`crate::RequestOptions`].
pub async fn confirm_customer_subscription_renewal_date_change_with_options(
&self,
product_subscription: &str,
params: ConfirmCustomerSubscriptionRenewalDateChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkConfirmCustomerSubscriptionRenewalDateChangeResponseValue200ApplicationJson, Error>
{
self.confirm_customer_subscription_renewal_date_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_customer_subscription_renewal_date_change_raw(
&self,
product_subscription: &str,
params: ConfirmCustomerSubscriptionRenewalDateChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<
SdkConfirmCustomerSubscriptionRenewalDateChangeResponseValue200ApplicationJson,
>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!(
"/v2/customer-portal/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("confirmCustomerSubscriptionRenewalDateChange".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(method, &path, ¶ms, Some(¶ms.body), options, "POST /v2/customer-portal/subscriptions/{productSubscription}/actions/change-renewal-date/confirm")
.await
}
}