pub struct CreatePromotionCode { /* private fields */ }Expand description
A promotion code points to an underlying promotion. You can optionally restrict the code to a specific customer, redemption limit, and expiration date.
Implementations§
Source§impl CreatePromotionCode
impl CreatePromotionCode
Sourcepub fn new(promotion: impl Into<CreatePromotionCodePromotion>) -> Self
pub fn new(promotion: impl Into<CreatePromotionCodePromotion>) -> Self
Construct a new CreatePromotionCode.
Sourcepub fn active(self, active: impl Into<bool>) -> Self
pub fn active(self, active: impl Into<bool>) -> Self
Whether the promotion code is currently active.
Sourcepub fn code(self, code: impl Into<String>) -> Self
pub fn code(self, code: impl Into<String>) -> Self
The customer-facing code. Regardless of case, this code must be unique across all active promotion codes for a specific customer. Valid characters are lower case letters (a-z), upper case letters (A-Z), digits (0-9), and dashes (-).
If left blank, we will generate one automatically.
Sourcepub fn customer(self, customer: impl Into<String>) -> Self
pub fn customer(self, customer: impl Into<String>) -> Self
The customer who can use this promotion code. If not set, all customers can use the promotion code.
Sourcepub fn customer_account(self, customer_account: impl Into<String>) -> Self
pub fn customer_account(self, customer_account: impl Into<String>) -> Self
The account representing the customer who can use this promotion code. If not set, all customers can use the promotion code.
Sourcepub fn expand(self, expand: impl Into<Vec<String>>) -> Self
pub fn expand(self, expand: impl Into<Vec<String>>) -> Self
Specifies which fields in the response should be expanded.
Sourcepub fn expires_at(self, expires_at: impl Into<Timestamp>) -> Self
pub fn expires_at(self, expires_at: impl Into<Timestamp>) -> Self
The timestamp at which this promotion code will expire.
If the coupon has specified a redeems_by, then this value cannot be after the coupon’s redeems_by.
Sourcepub fn max_redemptions(self, max_redemptions: impl Into<i64>) -> Self
pub fn max_redemptions(self, max_redemptions: impl Into<i64>) -> Self
A positive integer specifying the number of times the promotion code can be redeemed.
If the coupon has specified a max_redemptions, then this value cannot be greater than the coupon’s max_redemptions.
Sourcepub fn metadata(self, metadata: impl Into<HashMap<String, String>>) -> Self
pub fn metadata(self, metadata: impl Into<HashMap<String, String>>) -> Self
Set of key-value pairs that you can attach to an object.
This can be useful for storing additional information about the object in a structured format.
Individual keys can be unset by posting an empty value to them.
All keys can be unset by posting an empty value to metadata.
Sourcepub fn restrictions(
self,
restrictions: impl Into<CreatePromotionCodeRestrictions>,
) -> Self
pub fn restrictions( self, restrictions: impl Into<CreatePromotionCodeRestrictions>, ) -> Self
Settings that restrict the redemption of the promotion code.
Source§impl CreatePromotionCode
impl CreatePromotionCode
Sourcepub async fn send<C: StripeClient>(
&self,
client: &C,
) -> Result<<Self as StripeRequest>::Output, C::Err>
pub async fn send<C: StripeClient>( &self, client: &C, ) -> Result<<Self as StripeRequest>::Output, C::Err>
Send the request and return the deserialized response.
Sourcepub fn send_blocking<C: StripeBlockingClient>(
&self,
client: &C,
) -> Result<<Self as StripeRequest>::Output, C::Err>
pub fn send_blocking<C: StripeBlockingClient>( &self, client: &C, ) -> Result<<Self as StripeRequest>::Output, C::Err>
Send the request and return the deserialized response, blocking until completion.
Trait Implementations§
Source§impl Clone for CreatePromotionCode
impl Clone for CreatePromotionCode
Source§fn clone(&self) -> CreatePromotionCode
fn clone(&self) -> CreatePromotionCode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more