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 PaymentMethodsApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct EnableParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: SdkEnableOrDisablePaymentMethodRequestApplicationJson,
}
impl EnableParams {
#[allow(deprecated)]
pub fn new(body: SdkEnableOrDisablePaymentMethodRequestApplicationJson) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ConnectParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct ValidateParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
#[serde(skip)]
pub body: ValidateParamsBodyOneOf,
}
impl ValidateParams {
#[allow(deprecated)]
pub fn new(body: ValidateParamsBodyOneOf) -> Self {
Self {
x_store: Default::default(),
body,
}
}
}
impl<'a> PaymentMethodsApi<'a> {
pub async fn list(
&self,
params: ListParams,
) -> Result<SdkListPaymentMethodsResponseValue200ApplicationJson, Error> {
self.list_with_options(params, None).await
}
pub async fn list_with_options(
&self,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListPaymentMethodsResponseValue200ApplicationJson, Error> {
self.list_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn list_raw(
&self,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkListPaymentMethodsResponseValue200ApplicationJson>, Error>
{
let path = "/v2/payment-methods".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listPaymentMethods".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/payment-methods",
)
.await
}
pub async fn get(
&self,
payment_method: &str,
params: GetParams,
) -> Result<SdkGetPaymentMethodStatusResponseValue200ApplicationJson, Error> {
self.get_with_options(payment_method, params, None).await
}
pub async fn get_with_options(
&self,
payment_method: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetPaymentMethodStatusResponseValue200ApplicationJson, Error> {
self.get_raw(payment_method, params, options)
.await
.map(|response| response.data)
}
pub async fn get_raw(
&self,
payment_method: &str,
params: GetParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkGetPaymentMethodStatusResponseValue200ApplicationJson>, Error>
{
let payment_method = crate::client::path_segment(payment_method);
let path = format!("/v2/payment-methods/{payment_method}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getPaymentMethodStatus".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/payment-methods/{paymentMethod}",
)
.await
}
pub async fn enable(
&self,
payment_method: &str,
params: EnableParams,
) -> Result<SdkEnableOrDisablePaymentMethodResponseValue200ApplicationJson, Error> {
self.enable_with_options(payment_method, params, None).await
}
pub async fn enable_with_options(
&self,
payment_method: &str,
params: EnableParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkEnableOrDisablePaymentMethodResponseValue200ApplicationJson, Error> {
self.enable_raw(payment_method, params, options)
.await
.map(|response| response.data)
}
pub async fn enable_raw(
&self,
payment_method: &str,
params: EnableParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkEnableOrDisablePaymentMethodResponseValue200ApplicationJson>,
Error,
> {
let payment_method = crate::client::path_segment(payment_method);
let path = format!("/v2/payment-methods/{payment_method}");
let method = http::Method::PATCH;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("enableOrDisablePaymentMethod".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/{paymentMethod}",
)
.await
}
pub async fn connect(
&self,
payment_method: &str,
params: ConnectParams,
) -> Result<SdkCreatePaymentConnectionHandoffResponseValue200ApplicationJson, Error> {
self.connect_with_options(payment_method, params, None)
.await
}
pub async fn connect_with_options(
&self,
payment_method: &str,
params: ConnectParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkCreatePaymentConnectionHandoffResponseValue200ApplicationJson, Error> {
self.connect_raw(payment_method, params, options)
.await
.map(|response| response.data)
}
pub async fn connect_raw(
&self,
payment_method: &str,
params: ConnectParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkCreatePaymentConnectionHandoffResponseValue200ApplicationJson>,
Error,
> {
let payment_method = crate::client::path_segment(payment_method);
let path = format!("/v2/payment-methods/{payment_method}/connect");
let method = http::Method::POST;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("createPaymentConnectionHandoff".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"POST /v2/payment-methods/{paymentMethod}/connect",
)
.await
}
pub async fn validate(
&self,
payment_method: &str,
params: ValidateParams,
) -> Result<SdkValidateAndSavePaymentMethodConfigurationResponseValue200ApplicationJson, Error>
{
self.validate_with_options(payment_method, params, None)
.await
}
pub async fn validate_with_options(
&self,
payment_method: &str,
params: ValidateParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkValidateAndSavePaymentMethodConfigurationResponseValue200ApplicationJson, Error>
{
self.validate_raw(payment_method, params, options)
.await
.map(|response| response.data)
}
pub async fn validate_raw(
&self,
payment_method: &str,
params: ValidateParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<
SdkValidateAndSavePaymentMethodConfigurationResponseValue200ApplicationJson,
>,
Error,
> {
let payment_method = crate::client::path_segment(payment_method);
let path = format!("/v2/payment-methods/{payment_method}/configuration");
let method = http::Method::PUT;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("validateAndSavePaymentMethodConfiguration".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/{paymentMethod}/configuration",
)
.await
}
}