// 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 SubscriptionsActionsApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct ListParams {
/// Number of items to return per page.
///
/// Defaults to `15`.
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
/// Page number to return.
///
/// Defaults to `1`.
#[serde(skip_serializing_if = "Option::is_none")]
pub page: Option<i64>,
/// Set to false to return at most 100 matching items in one data array without pagination links or metadata.
///
/// Defaults to `true`.
#[serde(skip_serializing_if = "Option::is_none")]
pub pagination: Option<bool>,
/// 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 Default for ListParams {
#[allow(deprecated)]
fn default() -> Self {
Self {
limit: Some(15),
page: Some(1),
pagination: Some(true),
x_store: Default::default(),
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetParams {
/// 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 DismissParams {
/// 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: SdkDismissSubscriptionActionRequestApplicationJson,
}
impl DismissParams {
/// Construct a new `DismissParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkDismissSubscriptionActionRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
impl<'a> SubscriptionsActionsApi<'a> {
/// List subscription actions
///
/// List the lifecycle actions recorded against one subscription, ordered by identifier descending so the newest action comes first. The order is fixed and cannot be steered from the request. Requires the `invoice` Sanctum ability. 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(
&self,
product_subscription: &str,
params: ListParams,
) -> Result<SdkListSubscriptionActionsResponseValue200ApplicationJson, Error> {
self.list_with_options(product_subscription, params, None)
.await
}
/// Variant of [`Self::list`] that accepts per-request [`crate::RequestOptions`].
pub async fn list_with_options(
&self,
product_subscription: &str,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListSubscriptionActionsResponseValue200ApplicationJson, Error> {
self.list_raw(product_subscription, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn list_raw(
&self,
product_subscription: &str,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkListSubscriptionActionsResponseValue200ApplicationJson>, Error>
{
let product_subscription = crate::client::path_segment(product_subscription);
let path = format!("/v2/subscriptions/{product_subscription}/actions");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listSubscriptionActions".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/subscriptions/{productSubscription}/actions",
)
.await
}
/// Retrieve a subscription action
///
/// Retrieve one recorded lifecycle action. An action is only ever reachable through the subscription that recorded it, so an action belonging to another subscription of the same store is not found either. Requires the `invoice` Sanctum ability. 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(
&self,
product_subscription: &str,
action: &str,
params: GetParams,
) -> Result<SdkGetSubscriptionActionResponseValue200ApplicationJson, Error> {
self.get_with_options(product_subscription, action, params, None)
.await
}
/// Variant of [`Self::get`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_with_options(
&self,
product_subscription: &str,
action: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetSubscriptionActionResponseValue200ApplicationJson, Error> {
self.get_raw(product_subscription, action, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn get_raw(
&self,
product_subscription: &str,
action: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkGetSubscriptionActionResponseValue200ApplicationJson>, Error>
{
let product_subscription = crate::client::path_segment(product_subscription);
let action = crate::client::path_segment(action);
let path = format!("/v2/subscriptions/{product_subscription}/actions/{action}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getSubscriptionAction".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/subscriptions/{productSubscription}/actions/{action}",
)
.await
}
/// Dismiss a subscription action
///
/// Dismiss a pending lifecycle action that the provider left unresolved, which frees the subscription for its next change. Only a pending action can be dismissed, and the required `note` is stored on the action as its `error` so the decision stays on the record. An action in any other state returns `422` with the refusal sentence under `errors.subscription`, while a missing or over-long `note` returns an ordinary field error. Requires the `invoice` Sanctum ability. 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 dismiss(
&self,
product_subscription: &str,
action: &str,
params: DismissParams,
) -> Result<SdkDismissSubscriptionActionResponseValue200ApplicationJson, Error> {
self.dismiss_with_options(product_subscription, action, params, None)
.await
}
/// Variant of [`Self::dismiss`] that accepts per-request [`crate::RequestOptions`].
pub async fn dismiss_with_options(
&self,
product_subscription: &str,
action: &str,
params: DismissParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkDismissSubscriptionActionResponseValue200ApplicationJson, Error> {
self.dismiss_raw(product_subscription, action, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn dismiss_raw(
&self,
product_subscription: &str,
action: &str,
params: DismissParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkDismissSubscriptionActionResponseValue200ApplicationJson>,
Error,
> {
let product_subscription = crate::client::path_segment(product_subscription);
let action = crate::client::path_segment(action);
let path = format!("/v2/subscriptions/{product_subscription}/actions/{action}/dismiss");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = true;
merged.operation_id = Some("dismissSubscriptionAction".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/{action}/dismiss",
)
.await
}
}