app_store_server_library/primitives/advanced_commerce/
offer_period.rs

1use serde::{Deserialize, Serialize};
2
3/// The period of the offer.
4///
5/// [Offer](https://developer.apple.com/documentation/advancedcommerceapi/offer)
6#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
7pub enum OfferPeriod {
8    #[serde(rename = "P3D")]
9    P3d,
10    #[serde(rename = "P1W")]
11    P1w,
12    #[serde(rename = "P2W")]
13    P2w,
14    #[serde(rename = "P1M")]
15    P1m,
16    #[serde(rename = "P2M")]
17    P2m,
18    #[serde(rename = "P3M")]
19    P3m,
20    #[serde(rename = "P6M")]
21    P6m,
22    #[serde(rename = "P9M")]
23    P9m,
24    #[serde(rename = "P1Y")]
25    P1y,
26}
27
28impl OfferPeriod {
29    pub fn as_str(&self) -> &str {
30        match self {
31            OfferPeriod::P3d => "P3D",
32            OfferPeriod::P1w => "P1W",
33            OfferPeriod::P2w => "P2W",
34            OfferPeriod::P1m => "P1M",
35            OfferPeriod::P2m => "P2M",
36            OfferPeriod::P3m => "P3M",
37            OfferPeriod::P6m => "P6M",
38            OfferPeriod::P9m => "P9M",
39            OfferPeriod::P1y => "P1Y",
40        }
41    }
42}