#[cfg(feature = "http")]
use crate::http::CacheHttp;
use crate::internal::prelude::Result;
use crate::model::id::{EntitlementId, GuildId, SkuId, UserId};
use crate::model::monetization::Entitlement;
#[derive(Clone, Debug, Default)]
#[must_use]
pub struct GetEntitlements {
user_id: Option<UserId>,
sku_ids: Option<Vec<SkuId>>,
before: Option<EntitlementId>,
after: Option<EntitlementId>,
limit: Option<u8>,
guild_id: Option<GuildId>,
exclude_ended: Option<bool>,
}
impl GetEntitlements {
pub fn user_id(mut self, user_id: UserId) -> Self {
self.user_id = Some(user_id);
self
}
pub fn sku_ids(mut self, sku_ids: Vec<SkuId>) -> Self {
self.sku_ids = Some(sku_ids);
self
}
pub fn before(mut self, before: EntitlementId) -> Self {
self.before = Some(before);
self
}
pub fn after(mut self, after: EntitlementId) -> Self {
self.after = Some(after);
self
}
pub fn limit(mut self, limit: u8) -> Self {
self.limit = Some(limit);
self
}
pub fn guild_id(mut self, guild_id: GuildId) -> Self {
self.guild_id = Some(guild_id);
self
}
pub fn exclude_ended(mut self, exclude_ended: bool) -> Self {
self.exclude_ended = Some(exclude_ended);
self
}
}
#[cfg(feature = "http")]
#[async_trait::async_trait]
impl super::Builder for GetEntitlements {
type Context<'ctx> = ();
type Built = Vec<Entitlement>;
async fn execute(
self,
cache_http: impl CacheHttp,
_: Self::Context<'_>,
) -> Result<Self::Built> {
let http = cache_http.http();
http.get_entitlements(
self.user_id,
self.sku_ids,
self.before,
self.after,
self.limit,
self.guild_id,
self.exclude_ended,
)
.await
}
}