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 EntitlementsApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListCustomerEntitlementsParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListCustomerEntitlementsByExternalIdParams {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(rename = "X-STORE")]
pub x_store: Option<String>,
}
impl<'a> EntitlementsApi<'a> {
pub async fn list_customer_entitlements(
&self,
customer: &str,
params: ListCustomerEntitlementsParams,
) -> Result<SdkListCustomerEntitlementsResponseValue200ApplicationJson, Error> {
self.list_customer_entitlements_with_options(customer, params, None)
.await
}
pub async fn list_customer_entitlements_with_options(
&self,
customer: &str,
params: ListCustomerEntitlementsParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListCustomerEntitlementsResponseValue200ApplicationJson, Error> {
self.list_customer_entitlements_raw(customer, params, options)
.await
.map(|response| response.data)
}
pub async fn list_customer_entitlements_raw(
&self,
customer: &str,
params: ListCustomerEntitlementsParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkListCustomerEntitlementsResponseValue200ApplicationJson>, Error>
{
let customer = crate::client::path_segment(customer);
let path = format!("/v2/customers/{customer}/entitlements");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listCustomerEntitlements".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/customers/{customer}/entitlements",
)
.await
}
pub async fn list_customer_entitlements_by_external_id(
&self,
external_id: &str,
params: ListCustomerEntitlementsByExternalIdParams,
) -> Result<SdkListCustomerEntitlementsResponseValue200ApplicationJson, Error> {
self.list_customer_entitlements_by_external_id_with_options(external_id, params, None)
.await
}
pub async fn list_customer_entitlements_by_external_id_with_options(
&self,
external_id: &str,
params: ListCustomerEntitlementsByExternalIdParams,
options: Option<&crate::RequestOptions>,
) -> Result<SdkListCustomerEntitlementsResponseValue200ApplicationJson, Error> {
self.list_customer_entitlements_by_external_id_raw(external_id, params, options)
.await
.map(|response| response.data)
}
pub async fn list_customer_entitlements_by_external_id_raw(
&self,
external_id: &str,
params: ListCustomerEntitlementsByExternalIdParams,
options: Option<&crate::RequestOptions>,
) -> Result<crate::RawResponse<SdkListCustomerEntitlementsResponseValue200ApplicationJson>, Error>
{
let external_id = crate::client::path_segment(external_id);
let path = format!("/v2/customers/external/{external_id}/entitlements");
let method = http::Method::GET;
let mut merged = options.cloned().unwrap_or_default();
merged.idempotency_supported = false;
merged.operation_id = Some("listCustomerEntitlementsByExternalId".to_string());
let options = Some(&merged);
self.client
.request_with_query_schema_opts_raw(
method,
&path,
¶ms,
options,
"GET /v2/customers/external/{externalId}/entitlements",
)
.await
}
}