pub struct Promotions { /* private fields */ }Expand description
Promotions API for managing discounts and coupon codes
Implementations§
Source§impl Promotions
impl Promotions
Source§impl Promotions
impl Promotions
pub fn into_reference( val: Promotions, env: Env, ) -> Result<Reference<Promotions>>
pub fn into_instance(self, env: Env) -> Result<ClassInstance<Promotions>>
Source§impl Promotions
impl Promotions
Sourcepub async fn create(
&self,
input: CreatePromotionInput,
) -> Result<PromotionOutput>
pub async fn create( &self, input: CreatePromotionInput, ) -> Result<PromotionOutput>
Create a new promotion
Sourcepub async fn get_by_code(&self, code: String) -> Result<Option<PromotionOutput>>
pub async fn get_by_code(&self, code: String) -> Result<Option<PromotionOutput>>
Get a promotion by its internal code
Sourcepub async fn list(
&self,
filter: Option<PromotionFilterInput>,
) -> Result<Vec<PromotionOutput>>
pub async fn list( &self, filter: Option<PromotionFilterInput>, ) -> Result<Vec<PromotionOutput>>
List promotions with optional filtering
Sourcepub async fn update(
&self,
id: String,
input: UpdatePromotionInput,
) -> Result<PromotionOutput>
pub async fn update( &self, id: String, input: UpdatePromotionInput, ) -> Result<PromotionOutput>
Update a promotion
Sourcepub async fn activate(&self, id: String) -> Result<PromotionOutput>
pub async fn activate(&self, id: String) -> Result<PromotionOutput>
Activate a promotion
Sourcepub async fn deactivate(&self, id: String) -> Result<PromotionOutput>
pub async fn deactivate(&self, id: String) -> Result<PromotionOutput>
Deactivate (pause) a promotion
Sourcepub async fn get_active(&self) -> Result<Vec<PromotionOutput>>
pub async fn get_active(&self) -> Result<Vec<PromotionOutput>>
Get all currently active promotions
Sourcepub async fn is_valid(&self, id: String) -> Result<bool>
pub async fn is_valid(&self, id: String) -> Result<bool>
Check if a promotion is currently valid
Sourcepub async fn create_coupon(
&self,
input: CreateCouponInput,
) -> Result<CouponOutput>
pub async fn create_coupon( &self, input: CreateCouponInput, ) -> Result<CouponOutput>
Create a coupon code for a promotion
Sourcepub async fn get_coupon(&self, id: String) -> Result<Option<CouponOutput>>
pub async fn get_coupon(&self, id: String) -> Result<Option<CouponOutput>>
Get a coupon by ID
Sourcepub async fn get_coupon_by_code(
&self,
code: String,
) -> Result<Option<CouponOutput>>
pub async fn get_coupon_by_code( &self, code: String, ) -> Result<Option<CouponOutput>>
Get a coupon by its code
Sourcepub async fn list_coupons(
&self,
filter: Option<CouponFilterInput>,
) -> Result<Vec<CouponOutput>>
pub async fn list_coupons( &self, filter: Option<CouponFilterInput>, ) -> Result<Vec<CouponOutput>>
List coupons with optional filtering
Sourcepub async fn validate_coupon(
&self,
code: String,
) -> Result<Option<CouponOutput>>
pub async fn validate_coupon( &self, code: String, ) -> Result<Option<CouponOutput>>
Validate a coupon code
Sourcepub async fn apply(
&self,
input: ApplyPromotionsInput,
) -> Result<ApplyPromotionsOutput>
pub async fn apply( &self, input: ApplyPromotionsInput, ) -> Result<ApplyPromotionsOutput>
Apply promotions to cart/order items
Trait Implementations§
Source§impl FromNapiMutRef for Promotions
impl FromNapiMutRef for Promotions
Source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static mut Self>
unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>
Safety Read more
Source§impl FromNapiRef for Promotions
impl FromNapiRef for Promotions
Source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>
Safety Read more
Source§impl FromNapiValue for &Promotions
impl FromNapiValue for &Promotions
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl FromNapiValue for &mut Promotions
impl FromNapiValue for &mut Promotions
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl ToNapiValue for Promotions
impl ToNapiValue for Promotions
Source§unsafe fn to_napi_value(env: napi_env, val: Promotions) -> Result<napi_value>
unsafe fn to_napi_value(env: napi_env, val: Promotions) -> Result<napi_value>
Safety Read more
Source§impl TypeName for &Promotions
impl TypeName for &Promotions
Source§impl TypeName for &mut Promotions
impl TypeName for &mut Promotions
Source§impl TypeName for Promotions
impl TypeName for Promotions
Source§impl ValidateNapiValue for &Promotions
impl ValidateNapiValue for &Promotions
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Source§impl ValidateNapiValue for &mut Promotions
impl ValidateNapiValue for &mut Promotions
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Auto Trait Implementations§
impl Freeze for Promotions
impl !RefUnwindSafe for Promotions
impl Send for Promotions
impl Sync for Promotions
impl Unpin for Promotions
impl UnsafeUnpin for Promotions
impl !UnwindSafe for Promotions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more