Skip to main content

mailchimp/types/
list_segment_options.rs

1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4///
5/// Segment Conditions
6///
7#[derive(Serialize, Deserialize, Debug, Clone)]
8#[serde(tag = "condition_type")]
9pub enum SegmentConditionsType {
10    /// Aim Segment
11    Aim(SegmentConditionInner),
12    /// Automation Segment
13    Automation(SegmentConditionInner),
14    /// Poll Activity Segment
15    CampaignPoll(SegmentConditionInner),
16    /// Conversation Segment
17    Conversation(SegmentConditionInner),
18    /// Date Segment
19    Date(SegmentConditionInner),
20    /// Email Client Segment
21    EmailClient(SegmentConditionInner),
22    /// Language Segment
23    Language(SegmentConditionInner),
24    /// Member Rating Segment
25    MemberRating(SegmentConditionInner),
26    /// Signup Source Segment
27    SignupSource(SegmentConditionInner),
28    /// Survey Monkey Segment
29    SurveyMonkey(SegmentConditionInner),
30    /// VIP Segment
31    VIP(SegmentConditionFlag),
32    /// Interests Segment
33    Interests(SegmentConditionInner),
34    /// Ecommerce Category Segment
35    EcommCategory(SegmentConditionInner),
36    /// Ecommerce Number Segment
37    EcommNumber(SegmentConditionInner),
38    /// Ecommerce Purchased Segment
39    EcommPurchased(SegmentConditionFlag),
40    /// Ecommerce Spent Segment
41    EcommSpent(SegmentConditionInner),
42    /// Ecommerce Purchased Store Segment
43    EcommStore(SegmentConditionInner),
44    /// Goal Activity Segment
45    GoalActivity(SegmentConditionInner),
46    /// Goal Timestamp Segment
47    GoalTimestamp(SegmentConditionInner),
48    /// Similar Subscribers Segment Member Segment
49    FuzzySegment(SegmentConditionInner),
50    /// Static Segment Member Segment
51    StaticSegment(SegmentConditionInner),
52    /// Location-Based Segment
53    IPGeoCountryState(SegmentConditionInner),
54    /// Geolocation Segment
55    IPGeoIn(SegmentGeoCondition),
56    /// US Zip Code Segment
57    IPGeoInZip(SegmentConditionInner),
58    /// Unknown Location-Based Segment
59    IPGeoUnknown(SegmentConditionFlag),
60    /// Zip Code Location-Based Segment
61    IPGeoZip(SegmentConditionInner),
62    /// Social Profiles Age Segment
63    SocialAge(SegmentConditionInner),
64    /// Social Profiles Gender Segment
65    SocialGender(SegmentConditionInner),
66    /// Social Profiles Influence Segment
67    SocialInfluence(SegmentConditionInner),
68    /// Social Profiles Social Network Segment
69    SocialNetworkMember(SegmentConditionInner),
70    /// Social Profiles Social Network Follow Segment
71    SocialNetworkFollow(SegmentConditionInner),
72    /// Address Merge Field Segment
73    AddressMerge(SegmentConditionInner),
74    /// Address/Zip Merge Field Segment
75    ZipMerge(SegmentConditionInner),
76    /// Birthday Merge Field Segment
77    BirthdayMerge(SegmentConditionInner),
78    /// Date Merge Field Segment
79    DateMerge(SegmentConditionInner),
80    /// Dropdown/Radio Merge Field Segment
81    SelectMerge(SegmentConditionInner),
82    /// Text or Number Merge Field Segment
83    TextMerge(SegmentConditionInner),
84    /// Email Segment
85    EmailAddress(SegmentConditionInner),
86    /// Predicted Gender Segment
87    PredictedGender(SegmentConditionInner),
88    /// Predicted Age Segment
89    PredictedAge(SegmentConditionInner),
90    /// New Subscribers Prebuilt Segment
91    NewSubsribers(SegmentConditionInner),
92}
93
94/// Segment condition without a value
95#[derive(Serialize, Deserialize, Debug, Clone)]
96pub struct SegmentConditionFlag {
97    /// Condition Field
98    pub field: String,
99    /// Condition Op
100    pub op: SegmentConditionOp,
101}
102
103/// Segment condition with a value and optionally extra data
104#[derive(Serialize, Deserialize, Debug, Clone)]
105pub struct SegmentConditionInner {
106    /// field
107    pub field: String,
108    /// op
109    pub op: SegmentConditionOp,
110    /// value
111    pub value: Value,
112    /// Extra
113    #[serde(skip_serializing_if = "Option::is_none")]
114    pub extra: Option<String>,
115}
116
117/// Segment condition on a geo-spatial value
118#[derive(Serialize, Deserialize, Debug, Clone)]
119pub struct SegmentGeoCondition {
120    /// field
121    pub field: String,
122    /// Op
123    pub op: SegmentConditionOp,
124    /// Value
125    pub value: Value,
126    /// addr
127    pub addr: String,
128    /// lat
129    pub lat: String,
130    /// lng
131    pub lng: String,
132}
133
134///
135/// Segment Operator
136///
137#[derive(Serialize, Deserialize, Debug, Clone)]
138#[serde(untagged, rename_all = "snake_case")]
139pub enum SegmentConditionOp {
140    // Aim conditions
141    /// The campaign was opened by the subscriber.
142    Open,
143    /// The campaign was clicked by the subscriber.
144    Click,
145    /// The campaign was sent to the subscriber.
146    Sent,
147    /// The campaign was not opened by the subscriber.
148    Noopen,
149    /// The campaign was not clicked by the subscriber.
150    Noclick,
151    /// The campaign was not sent to the subscriber.
152    Nosent,
153
154    // Automation, SurveyMonkey conditions
155    /// The member has started the automation workflow or survey.
156    Started,
157    /// The member has completed the automation workflow or survey.
158    Completed,
159    /// The member has not started the automation workflow or survey.
160    NotStarted,
161    /// The member has not completed the automation workflow or survey.
162    NotCompleted,
163
164    // CampaignPoll, Conversation, SocialNetwork, VIP conditions
165    /// The subscriber is a member.
166    Member,
167    /// The subscriber is not a member.
168    Notmember,
169
170    // Date, etc. conditions
171    /// The field is greater than the value.
172    Greater,
173    /// The field is less than the value.
174    Less,
175    /// The field is exactly the value.
176    Is,
177    /// The field is not equal to the value.
178    Not,
179    /// The field is blank.
180    Blank,
181    /// The field is not blank.
182    BlankNot,
183    /// The field is within the range.
184    Within,
185    /// The field is not within the range.
186    Notwithin,
187
188    // EmailClient conditions
189    /// The email client is the value.
190    ClientIs,
191    /// The email client is not the value.
192    ClientNot,
193
194    // SignupSource conditions
195    /// The signup source is the value.
196    SourceIs,
197    /// The signup source is not the value.
198    SourceNot,
199
200    // EcommCategory, AddressMerge conditions
201    /// The field contains the value.
202    Contains,
203    /// The field does not contain the value.
204    Notcontain,
205    /// The field starts with the value.
206    Starts,
207    /// The field ends with the value.
208    Ends,
209
210    // Goal conditions
211    /// The goal is not the value. (Inverse of `Is` for Goal Segments.)
212    GoalNot,
213    /// The goal does not contain the value. (Inverse of `Contains` for Goal Segments.)
214    GoalNotcontain,
215
216    // FuzzySegment conditions
217    /// The subscriber is in the value's "similar subscribers" segment.
218    FuzzyIs,
219    /// The subscriber is not in the value's "similar subscribers" segment.
220    FuzzyNot,
221
222    // StaticSegment conditions
223    /// The subscriber is has the value's tag.
224    StaticIs,
225    /// The subscriber does not have the value's tag.
226    StaticNot,
227
228    // IPGeoCountryState conditions
229    /// The subscriber is in the value's country code.
230    Ipgeocountry,
231    /// The subscriber is not in the value's country code.
232    Ipgeonotcountry,
233    /// The subscriber is in the value's state code.
234    Ipgeostate,
235    /// The subscriber is not in the value's state code.
236    Ipgeonotstate,
237
238    // IPGeoIn conditions
239    /// The subscriber is in a radius of {value} around {addr} or the {lat}/{lng} coordinates.
240    Ipgeoin,
241    /// The subscriber is not in a radius of {value} around {addr} or the {lat}/{lng} coordinates.
242    Ipgeonotin,
243
244    // IPGeoInZip condition
245    /// The subscriber is in a radius of {value} around the ZIP code, {extra}.
246    Ipgeoinzip,
247
248    // IPGeoUnknown condition
249    /// The subscriber's location is unknown.
250    Ipgeounknown,
251
252    // IPGeoZip conditions
253    /// The subscriber's ZIP code is the value.
254    Ipgeoiszip,
255    /// The subscriber's ZIP code is not the value.
256    Ipgeonotzip,
257
258    // SocialNetworkFollow conditions
259    /// The subscriber follows you on social media.
260    Follow,
261    /// The subscriber does not follow you on social media.
262    Notfollow,
263
264    // ZipMerge condition
265    /// The subscriber's address is {value} distance from the {extra} city or ZIP code.
266    Geoin,
267
268    // NewSubscribers condition
269    /// The subscriber joined within a given time period.
270    DateWithin,
271}
272
273///
274/// Segment Options
275///
276#[derive(Serialize, Deserialize, Debug, Default, Clone)]
277#[serde(default)]
278pub struct SegmentOptionsType {
279    /// The id for an existing saved segment.
280    pub saved_segment_id: u64,
281    /// The prebuilt segment id, if a prebuilt segment has been designated for this campaign.
282    pub prebuilt_segment_id: String,
283    /// Desc: Segment match type.
284    #[serde(rename = "match")]
285    pub match_filter: String,
286    /// An array of segment conditions.
287    pub conditions: Vec<SegmentConditionsType>,
288}