app_store_server_library/primitives/advanced_commerce/
offer.rs

1use crate::primitives::advanced_commerce::offer_period::OfferPeriod;
2use crate::primitives::advanced_commerce::offer_reason::OfferReason;
3use serde::{Deserialize, Serialize};
4
5/// A discount offer for an auto-renewable subscription.
6///
7/// [Offer](https://developer.apple.com/documentation/advancedcommerceapi/offer)
8#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, Hash)]
9#[serde(rename_all = "camelCase")]
10pub struct Offer {
11    /// The period of the offer.
12    ///
13    /// [Period](https://developer.apple.com/documentation/advancedcommerceapi/period)
14    pub period: OfferPeriod,
15    
16    /// The number of periods the offer is active.
17    /// Minimum: 1, Maximum: 12
18    pub period_count: i32,
19    
20    /// The offer price, in milliunits.
21    ///
22    /// [Price](https://developer.apple.com/documentation/advancedcommerceapi/price)
23    pub price: i64,
24    
25    /// The reason for the offer.
26    ///
27    /// [Reason](https://developer.apple.com/documentation/advancedcommerceapi/reason)
28    pub reason: OfferReason,
29}
30
31impl Offer {
32    pub fn new(period: OfferPeriod, period_count: i32, price: i64, reason: OfferReason) -> Self {
33        Self {
34            period,
35            period_count,
36            price,
37            reason,
38        }
39    }
40}