pub struct CreateCouponInput {Show 15 fields
pub name: String,
pub code: String,
pub coupon_type: CouponType,
pub amount_cents: Option<i64>,
pub amount_currency: Option<String>,
pub percentage_rate: Option<String>,
pub frequency: CouponFrequency,
pub frequency_duration: Option<i32>,
pub reusable: Option<bool>,
pub limited_plans: Option<bool>,
pub plan_codes: Option<Vec<String>>,
pub limited_billable_metrics: Option<bool>,
pub billable_metric_codes: Option<Vec<String>>,
pub expiration: CouponExpiration,
pub expiration_at: Option<String>,
}Expand description
Input for creating a coupon.
This struct contains the data needed to create a new coupon.
Fields§
§name: String§code: String§coupon_type: CouponType§amount_cents: Option<i64>§amount_currency: Option<String>§percentage_rate: Option<String>§frequency: CouponFrequency§frequency_duration: Option<i32>§reusable: Option<bool>§limited_plans: Option<bool>§plan_codes: Option<Vec<String>>§limited_billable_metrics: Option<bool>§billable_metric_codes: Option<Vec<String>>§expiration: CouponExpiration§expiration_at: Option<String>Implementations§
Source§impl CreateCouponInput
impl CreateCouponInput
Sourcepub fn fixed_amount(
name: String,
code: String,
amount_cents: i64,
amount_currency: String,
frequency: CouponFrequency,
expiration: CouponExpiration,
) -> Self
pub fn fixed_amount( name: String, code: String, amount_cents: i64, amount_currency: String, frequency: CouponFrequency, expiration: CouponExpiration, ) -> Self
Creates a new fixed amount coupon input.
§Arguments
name- The name of the couponcode- The unique code for the couponamount_cents- The discount amount in centsamount_currency- The currency code (e.g., “USD”)frequency- The frequency of the coupon applicationexpiration- The expiration policy for the coupon
§Returns
A new CreateCouponInput instance for a fixed amount coupon
Sourcepub fn percentage(
name: String,
code: String,
percentage_rate: String,
frequency: CouponFrequency,
expiration: CouponExpiration,
) -> Self
pub fn percentage( name: String, code: String, percentage_rate: String, frequency: CouponFrequency, expiration: CouponExpiration, ) -> Self
Creates a new percentage coupon input.
§Arguments
name- The name of the couponcode- The unique code for the couponpercentage_rate- The discount percentage (e.g., “10.5” for 10.5%)frequency- The frequency of the coupon applicationexpiration- The expiration policy for the coupon
§Returns
A new CreateCouponInput instance for a percentage coupon
Sourcepub fn with_frequency_duration(self, duration: i32) -> Self
pub fn with_frequency_duration(self, duration: i32) -> Self
Sourcepub fn with_reusable(self, reusable: bool) -> Self
pub fn with_reusable(self, reusable: bool) -> Self
Sourcepub fn with_limited_plans(self, plan_codes: Vec<String>) -> Self
pub fn with_limited_plans(self, plan_codes: Vec<String>) -> Self
Sourcepub fn with_limited_billable_metrics(
self,
billable_metric_codes: Vec<String>,
) -> Self
pub fn with_limited_billable_metrics( self, billable_metric_codes: Vec<String>, ) -> Self
Sourcepub fn with_expiration_at(self, expiration_at: String) -> Self
pub fn with_expiration_at(self, expiration_at: String) -> Self
Trait Implementations§
Source§impl Clone for CreateCouponInput
impl Clone for CreateCouponInput
Source§fn clone(&self) -> CreateCouponInput
fn clone(&self) -> CreateCouponInput
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CreateCouponInput
impl Debug for CreateCouponInput
Source§impl<'de> Deserialize<'de> for CreateCouponInput
impl<'de> Deserialize<'de> for CreateCouponInput
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CreateCouponInput
impl RefUnwindSafe for CreateCouponInput
impl Send for CreateCouponInput
impl Sync for CreateCouponInput
impl Unpin for CreateCouponInput
impl UnwindSafe for CreateCouponInput
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