// 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 CreditsBalancesTransactionsApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct ListParams {
/// Defaults to `1`.
#[serde(skip_serializing_if = "Option::is_none")]
pub page: Option<i64>,
/// Defaults to `15`.
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
/// 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 {
page: Some(1),
limit: Some(15),
x_store: Default::default(),
}
}
}
impl<'a> CreditsBalancesTransactionsApi<'a> {
/// List credit balance transactions
///
/// Read all credit transactions for one customer and credits product in the selected store, newest first. Requires the credit API-key ability and store credit permission. Amounts are integer credit units. Use links.next to continue beyond the 100 entries embedded in balance details. An existing balance with no entries returns an empty data array; an unknown balance returns 404. 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,
customer: &str,
credit_product: &str,
params: ListParams,
) -> Result<SdkListCreditBalanceTransactionsResponseValue200ApplicationJson, Error> {
self.list_with_options(customer, credit_product, params, None)
.await
}
/// Variant of [`Self::list`] that accepts per-request [`crate::RequestOptions`].
pub async fn list_with_options(
&self,
customer: &str,
credit_product: &str,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListCreditBalanceTransactionsResponseValue200ApplicationJson, Error> {
self.list_raw(customer, credit_product, params, options)
.await
.map(|response| response.data)
}
/// Returns the typed result together with status, headers, and request ID.
pub async fn list_raw(
&self,
customer: &str,
credit_product: &str,
params: ListParams,
options: Option<&crate::RequestOptions>,
) -> Result<
crate::RawResponse<SdkListCreditBalanceTransactionsResponseValue200ApplicationJson>,
Error,
> {
let customer = crate::client::path_segment(customer);
let credit_product = crate::client::path_segment(credit_product);
let path = format!("/v2/credit-balances/{customer}/{credit_product}/transactions");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listCreditBalanceTransactions".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/credit-balances/{customer}/{creditProduct}/transactions",
)
.await
}
}