1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// This file is auto-generated by oagen. Do not edit.
#[allow(unused_imports)]
use super::*;
#[allow(unused_imports)]
use crate::enums::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(remote = "Self")]
pub struct SdkCreatePromotionRequestApplicationJson {
pub name: String,
pub status: SdkCreatePromotionRequestApplicationJsonStatus,
#[serde(
skip_serializing_if = "Option::is_none",
default,
deserialize_with = "crate::runtime_schema::present_nullable"
)]
pub starts_at: Option<Option<String>>,
/// A date and time after starts_at and after the current time, or null for no end date.
#[serde(
skip_serializing_if = "Option::is_none",
default,
deserialize_with = "crate::runtime_schema::present_nullable"
)]
pub ends_at: Option<Option<String>>,
pub priority: i64,
pub is_stackable: bool,
#[serde(
skip_serializing_if = "Option::is_none",
default,
deserialize_with = "crate::runtime_schema::present_nullable"
)]
pub max_redemptions: Option<Option<i64>>,
/// What the promotion discounts: `one_time` for one-time purchases, or `subscriptions` for the first payments of a subscription plan. A new promotion defaults to `one_time`, and an update that leaves this out keeps the current kind. The promotion only discounts order lines of its kind.
#[serde(skip_serializing_if = "Option::is_none", default)]
pub applies_to: Option<SdkCreatePromotionRequestApplicationJsonAppliesTo>,
/// How many payments a `subscriptions` promotion discounts, counting the signup payment as the first, so `3` discounts the signup and the next two renewals. A `subscriptions` promotion needs one, and an update that leaves it out keeps the stored number. Missing on a `subscriptions` promotion, or outside 1 to 36, it returns `422` on `subscription_payments` with `The number of discounted payments must be between 1 and 36.` A `one_time` promotion always stores null here.
#[serde(
skip_serializing_if = "Option::is_none",
default,
deserialize_with = "crate::runtime_schema::present_nullable"
)]
pub subscription_payments: Option<Option<i64>>,
/// Send `false` with `products` to limit a `subscriptions` promotion to picked products and plans. Required whenever the request sends `products` or `product_variants`. A new promotion defaults to `true`, an update that leaves it out keeps the current scope, and switching a promotion to `one_time` makes it store-wide again. A `one_time` promotion with `false` returns `422` on `store_wide` with `A promotion for one-time purchases applies to the whole store.`
#[serde(skip_serializing_if = "Option::is_none", default)]
pub store_wide: Option<bool>,
/// Product IDs a narrowed subscription promotion reaches. Each one must sell a subscription, or the request returns `422` on `products` with `Pick only products that sell a subscription.` A narrowed promotion left with no products returns `422` with `Pick at least one subscription product for this promotion.` An update replaces the picks with this list, or keeps them when it is left out.
#[serde(skip_serializing_if = "Option::is_none", default)]
pub products: Option<Vec<i64>>,
/// Subscription plan IDs to limit the picked products to. Each one must be a subscription plan of a product in `products`, or the request returns `422` on `product_variants` with `Pick only subscription plans of the picked products.` A picked product with none of its plans listed takes every plan, including plans added later. An update that leaves this out keeps the listed plans of products that stay picked.
#[serde(skip_serializing_if = "Option::is_none", default)]
pub product_variants: Option<Vec<i64>>,
/// The complete ordered phase set. Array order becomes phase position.
pub phases: Vec<CreatePromotionRequestApplicationJsonPropertyPhasesItem>,
/// Fields returned by a newer API version that are not yet known to this SDK.
#[serde(default, flatten)]
pub additional_properties: std::collections::HashMap<String, serde_json::Value>,
}
impl Serialize for SdkCreatePromotionRequestApplicationJson {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
Self::serialize(self, serializer)
}
}
impl<'de> Deserialize<'de> for SdkCreatePromotionRequestApplicationJson {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let mut value = serde_json::Value::deserialize(deserializer)?;
crate::runtime_schema::model(&value, "SdkCreatePromotionRequestApplicationJson", false)
.map_err(serde::de::Error::custom)?;
crate::runtime_schema::retain_model_fields(
&mut value,
"SdkCreatePromotionRequestApplicationJson",
);
Self::deserialize(value).map_err(serde::de::Error::custom)
}
}
impl SdkCreatePromotionRequestApplicationJson {
/// Validate the serialized request, including schema constraints and compatibility rules.
pub fn validate_request(&self) -> Result<(), crate::error::Error> {
let value = serde_json::to_value(self)
.map_err(|e| crate::error::Error::Serialization(e.to_string()))?;
crate::runtime_schema::model(&value, "SdkCreatePromotionRequestApplicationJson", true)
}
}