// 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 PaymentMethodsCustomApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListParams {
/// 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 CreateParams {
/// 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: SdkCreateCustomPaymentMethodRequestApplicationJson,
}
impl CreateParams {
/// Construct a new `CreateParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkCreateCustomPaymentMethodRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[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 ReplaceParams {
/// 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: SdkReplaceCustomPaymentMethodRequestApplicationJson,
}
impl ReplaceParams {
/// Construct a new `ReplaceParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkReplaceCustomPaymentMethodRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateParams {
/// 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: SdkUpdateCustomPaymentMethodRequestApplicationJson,
}
impl UpdateParams {
/// Construct a new `UpdateParams` with the required fields set.
#[allow(deprecated)]
pub fn new(body: SdkUpdateCustomPaymentMethodRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct DeleteParams {
/// 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> PaymentMethodsCustomApi<'a> {
/// List custom payment methods
///
/// List the current store's instruction and redirect payment methods. 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,
params: ListParams,
) -> Result<SdkListCustomPaymentMethodsResponseValue200ApplicationJson, Error> {
self.list_with_options(params, None).await
}
/// Variant of [`Self::list`] that accepts per-request [`crate::RequestOptions`].
pub async fn list_with_options(
&self,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListCustomPaymentMethodsResponseValue200ApplicationJson, Error> {
self.list_raw(params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn list_raw(
&self,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkListCustomPaymentMethodsResponseValue200ApplicationJson>, Error>
{
let path = "/v2/payment-methods/custom".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listCustomPaymentMethods".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/payment-methods/custom",
)
.await
}
/// Create a custom payment method
///
/// Create a store-scoped custom payment method. Requires payment-method management permission. The effective redirect type needs a public redirect_url; instructions type needs nonblank instructions or a nonempty step. Switching to instructions clears redirect options; switching to redirect clears instructions, steps and proof-of-payment requirements. This API does not assign the method to every product. Inspect existing checkout configuration before changing an enabled method; creates have no idempotency guarantee. 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 create(
&self,
params: CreateParams,
) -> Result<SdkCreateCustomPaymentMethodResponseValue201ApplicationJson, Error> {
self.create_with_options(params, None).await
}
/// Variant of [`Self::create`] that accepts per-request [`crate::RequestOptions`].
pub async fn create_with_options(
&self,
params: CreateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCreateCustomPaymentMethodResponseValue201ApplicationJson, Error> {
self.create_raw(params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn create_raw(
&self,
params: CreateParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkCreateCustomPaymentMethodResponseValue201ApplicationJson>,
Error,
> {
let path = "/v2/payment-methods/custom".to_string();
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("createCustomPaymentMethod".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"POST /v2/payment-methods/custom",
)
.await
}
/// Retrieve a custom payment method
///
/// Retrieve one custom payment method owned by the current store. 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,
custom_payment_method: &str,
params: GetParams,
) -> Result<SdkGetCustomPaymentMethodResponseValue200ApplicationJson, Error> {
self.get_with_options(custom_payment_method, params, None)
.await
}
/// Variant of [`Self::get`] that accepts per-request [`crate::RequestOptions`].
pub async fn get_with_options(
&self,
custom_payment_method: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetCustomPaymentMethodResponseValue200ApplicationJson, Error> {
self.get_raw(custom_payment_method, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn get_raw(
&self,
custom_payment_method: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkGetCustomPaymentMethodResponseValue200ApplicationJson>, Error>
{
let custom_payment_method = crate::client::path_segment(custom_payment_method);
let path = format!("/v2/payment-methods/custom/{custom_payment_method}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getCustomPaymentMethod".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/payment-methods/custom/{customPaymentMethod}",
)
.await
}
/// Replace a custom payment method
///
/// Update a custom payment method with required type and name. Omitted optional fields retain their stored values; this PUT does not reset every omitted field. Requires payment-method management permission. The effective redirect type needs a public redirect_url; instructions type needs nonblank instructions or a nonempty step. Switching to instructions clears redirect options; switching to redirect clears instructions, steps and proof-of-payment requirements. This API does not assign the method to every product. Inspect existing checkout configuration before changing an enabled method; creates have no idempotency guarantee. 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 replace(
&self,
custom_payment_method: &str,
params: ReplaceParams,
) -> Result<SdkReplaceCustomPaymentMethodResponseValue200ApplicationJson, Error> {
self.replace_with_options(custom_payment_method, params, None)
.await
}
/// Variant of [`Self::replace`] that accepts per-request [`crate::RequestOptions`].
pub async fn replace_with_options(
&self,
custom_payment_method: &str,
params: ReplaceParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkReplaceCustomPaymentMethodResponseValue200ApplicationJson, Error> {
self.replace_raw(custom_payment_method, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn replace_raw(
&self,
custom_payment_method: &str,
params: ReplaceParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkReplaceCustomPaymentMethodResponseValue200ApplicationJson>,
Error,
> {
let custom_payment_method = crate::client::path_segment(custom_payment_method);
let path = format!("/v2/payment-methods/custom/{custom_payment_method}");
let method = http::Method::PUT;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("replaceCustomPaymentMethod".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PUT /v2/payment-methods/custom/{customPaymentMethod}",
)
.await
}
/// Update a custom payment method
///
/// Partially update a store-scoped custom payment method; omitted fields retain their values. Requires payment-method management permission. The effective redirect type needs a public redirect_url; instructions type needs nonblank instructions or a nonempty step. Switching to instructions clears redirect options; switching to redirect clears instructions, steps and proof-of-payment requirements. This API does not assign the method to every product. Inspect existing checkout configuration before changing an enabled method; creates have no idempotency guarantee. 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(
&self,
custom_payment_method: &str,
params: UpdateParams,
) -> Result<SdkUpdateCustomPaymentMethodResponseValue200ApplicationJson, Error> {
self.update_with_options(custom_payment_method, params, None)
.await
}
/// Variant of [`Self::update`] that accepts per-request [`crate::RequestOptions`].
pub async fn update_with_options(
&self,
custom_payment_method: &str,
params: UpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkUpdateCustomPaymentMethodResponseValue200ApplicationJson, Error> {
self.update_raw(custom_payment_method, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn update_raw(
&self,
custom_payment_method: &str,
params: UpdateParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkUpdateCustomPaymentMethodResponseValue200ApplicationJson>,
Error,
> {
let custom_payment_method = crate::client::path_segment(custom_payment_method);
let path = format!("/v2/payment-methods/custom/{custom_payment_method}");
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("updateCustomPaymentMethod".to_string());
let options = Some(&merged);
self.client
.request_with_body_schema_opts_raw(
method,
&path,
¶ms,
Some(¶ms.body),
options,
"PATCH /v2/payment-methods/custom/{customPaymentMethod}",
)
.await
}
/// Delete a custom payment method
///
/// Delete one store-scoped custom payment method and remove its product assignments. 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 delete(
&self,
custom_payment_method: &str,
params: DeleteParams,
) -> Result<SdkDeleteCustomPaymentMethodResponseValue200ApplicationJson, Error> {
self.delete_with_options(custom_payment_method, params, None)
.await
}
/// Variant of [`Self::delete`] that accepts per-request [`crate::RequestOptions`].
pub async fn delete_with_options(
&self,
custom_payment_method: &str,
params: DeleteParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkDeleteCustomPaymentMethodResponseValue200ApplicationJson, Error> {
self.delete_raw(custom_payment_method, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn delete_raw(
&self,
custom_payment_method: &str,
params: DeleteParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkDeleteCustomPaymentMethodResponseValue200ApplicationJson>,
Error,
> {
let custom_payment_method = crate::client::path_segment(custom_payment_method);
let path = format!("/v2/payment-methods/custom/{custom_payment_method}");
let method = http::Method::DELETE;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("deleteCustomPaymentMethod".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"DELETE /v2/payment-methods/custom/{customPaymentMethod}",
)
.await
}
}