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 RefundsApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListRefundsParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct GetRefundParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
impl<'a> RefundsApi<'a> {
pub async fn list_refunds(
&self,
params: ListRefundsParams,
) -> Result<SdkListRefundsResponseValue200ApplicationJson, Error> {
self.list_refunds_with_options(params, None).await
}
pub async fn list_refunds_with_options(
&self,
params: ListRefundsParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListRefundsResponseValue200ApplicationJson, Error> {
self.list_refunds_raw(params, options)
.await
.map(|response| response.data)
}
pub async fn list_refunds_raw(
&self,
params: ListRefundsParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkListRefundsResponseValue200ApplicationJson>, Error> {
let path = "/v2/refunds".to_string();
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listRefunds".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(method, &path, ¶ms, options, "GET /v2/refunds")
.await
}
pub async fn get_refund(
&self,
refund: &str,
params: GetRefundParams,
) -> Result<SdkGetRefundResponseValue200ApplicationJson, Error> {
self.get_refund_with_options(refund, params, None).await
}
pub async fn get_refund_with_options(
&self,
refund: &str,
params: GetRefundParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkGetRefundResponseValue200ApplicationJson, Error> {
self.get_refund_raw(refund, params, options)
.await
.map(|response| response.data)
}
pub async fn get_refund_raw(
&self,
refund: &str,
params: GetRefundParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkGetRefundResponseValue200ApplicationJson>, Error> {
let refund = crate::client::path_segment(refund);
let path = format!("/v2/refunds/{refund}");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("getRefund".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/refunds/{refund}",
)
.await
}
}