wallet_pass/
template.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4/// Apple Wallet pass with localizations, NFC and web service push updates support.
5#[derive(Debug, Clone, Serialize, Deserialize)]
6#[serde(deny_unknown_fields)]
7pub struct Template {
8    /// A URL to be passed to the associated app when launching it. The app receives this URL in
9    /// the application:didFinishLaunchingWithOptions: and application:openURL:options: methods
10    /// of its app delegate.
11    #[serde(rename = "appLaunchURL")]
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub app_launch_url: Option<String>,
14
15    /// A list of iTunes Store item identifiers for the associated apps.
16    /// Only one item in the list is used—the first item identifier for an app compatible with
17    /// the current device. If the app is not installed, the link opens the App Store and shows
18    /// the app. If the app is already installed, the link launches the app.
19    #[serde(rename = "associatedStoreIdentifiers")]
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub associated_store_identifiers: Option<Vec<f64>>,
22
23    /// The authentication token to use with the web service.
24    #[serde(rename = "authenticationToken")]
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub authentication_token: Option<String>,
27
28    /// Background color of the pass, specified as an CSS-style RGB triple.
29    #[serde(rename = "backgroundColor")]
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub background_color: Option<String>,
32
33    /// Information specific to the pass’s barcode.
34    /// Deprecated in iOS 9.0 and later; use barcodes instead.
35    #[serde(rename = "barcode")]
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub barcode: Option<Barcode>,
38
39    /// Information specific to the pass’s barcode. The system uses the first valid barcode
40    /// dictionary in the array. Additional dictionaries can be added as fallbacks.
41    /// Available only in iOS 9.0 and later.
42    #[serde(rename = "barcodes")]
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub barcodes: Option<Vec<Barcode>>,
45
46    /// Beacons marking locations where the pass is relevant.
47    /// Available in iOS 7.0.
48    #[serde(rename = "beacons")]
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub beacons: Option<Vec<Beacon>>,
51
52    /// Information specific to a boarding pass.
53    #[serde(rename = "boardingPass")]
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub boarding_pass: Option<BoardingPass>,
56
57    /// Information specific to a coupon.
58    #[serde(rename = "coupon")]
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub coupon: Option<Details>,
61
62    /// Brief description of the pass, used by the iOS accessibility technologies.
63    /// Don’t try to include all of the data on the pass in its description, just include enough
64    /// detail to distinguish passes of the same type.
65    /// Localizable.
66    #[serde(rename = "description")]
67    pub description: String,
68
69    /// Information specific to an event ticket.
70    #[serde(rename = "eventTicket")]
71    #[serde(skip_serializing_if = "Option::is_none")]
72    pub event_ticket: Option<Details>,
73
74    /// Date and time when the pass expires.
75    /// Available in iOS 7.0.
76    #[serde(rename = "expirationDate")]
77    #[serde(skip_serializing_if = "Option::is_none")]
78    pub expiration_date: Option<String>,
79
80    /// Foreground color of the pass, specified as a CSS-style RGB triple
81    #[serde(rename = "foregroundColor")]
82    #[serde(skip_serializing_if = "Option::is_none")]
83    pub foreground_color: Option<String>,
84
85    /// Version of the file format.
86    #[serde(rename = "formatVersion")]
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub format_version: Option<serde_json::Value>,
89
90    /// Information specific to a generic pass.
91    #[serde(rename = "generic")]
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub generic: Option<Details>,
94
95    /// Identifier used to group related passes. If a grouping identifier is specified, passes
96    /// with the same style, pass type identifier, and grouping identifier are displayed as a
97    /// group. Otherwise, passes are grouped automatically.
98    /// Use this to group passes that are tightly related, such as the boarding passes for
99    /// different connections of the same trip.
100    /// Available in iOS 7.0.
101    #[serde(rename = "groupingIdentifier")]
102    #[serde(skip_serializing_if = "Option::is_none")]
103    pub grouping_identifier: Option<String>,
104
105    /// olor of the label text, specified as a CSS-style RGB triple.
106    /// If omitted, the label color is determined automatically.
107    #[serde(rename = "labelColor")]
108    #[serde(skip_serializing_if = "Option::is_none")]
109    pub label_color: Option<String>,
110
111    /// Locations where the pass is relevant. For example, the location of your store.
112    #[serde(rename = "locations")]
113    #[serde(skip_serializing_if = "Option::is_none")]
114    pub locations: Option<Vec<Location>>,
115
116    /// Text displayed next to the logo on the pass.
117    /// Localizable.
118    #[serde(rename = "logoText")]
119    #[serde(skip_serializing_if = "Option::is_none")]
120    pub logo_text: Option<String>,
121
122    /// Maximum distance in meters from a relevant latitude and longitude that the pass is
123    /// relevant. This number is compared to the pass’s default distance and the smaller value is
124    /// used.
125    /// Available in iOS 7.0.
126    #[serde(rename = "maxDistance")]
127    #[serde(skip_serializing_if = "Option::is_none")]
128    pub max_distance: Option<f64>,
129
130    /// Information used for Value Added Service Protocol transactions.
131    /// Available in iOS 9.0.
132    #[serde(rename = "nfc")]
133    #[serde(skip_serializing_if = "Option::is_none")]
134    pub nfc: Option<Nfc>,
135
136    /// Display name of the organization that originated and signed the pass.
137    /// Localizable.
138    #[serde(rename = "organizationName")]
139    pub organization_name: String,
140
141    /// Pass type identifier, as issued by Apple. The value must correspond with your signing
142    /// certificate.
143    #[serde(rename = "passTypeIdentifier")]
144    pub pass_type_identifier: String,
145
146    /// Date and time when the pass becomes relevant. For example, the start time of a movie.
147    /// Recommended for event tickets and boarding passes.
148    #[serde(rename = "relevantDate")]
149    #[serde(skip_serializing_if = "Option::is_none")]
150    pub relevant_date: Option<String>,
151
152    /// Serial number that uniquely identifies the pass. No two passes with the same pass type
153    /// identifier may have the same serial number.
154    #[serde(rename = "serialNumber")]
155    pub serial_number: String,
156
157    /// Information specific to a store card.
158    #[serde(rename = "storeCard")]
159    #[serde(skip_serializing_if = "Option::is_none")]
160    pub store_card: Option<Details>,
161
162    /// If true, the strip image is displayed without a shine effect. The default value prior to
163    /// iOS 7.0 is false. In iOS 7.0, a shine effect is never applied, and this key is deprecated.
164    #[serde(rename = "suppressStripShine")]
165    #[serde(skip_serializing_if = "Option::is_none")]
166    pub suppress_strip_shine: Option<bool>,
167
168    /// Team identifier of the organization that originated and signed the pass, as issued by
169    /// Apple.
170    #[serde(rename = "teamIdentifier")]
171    #[serde(skip_serializing_if = "Option::is_none")]
172    pub team_identifier: Option<String>,
173
174    /// Custom information for companion apps. This data is not displayed to the user.
175    /// For example, a pass for a cafe could include information about the user’s favorite drink
176    /// and sandwich in a machine-readable form for the companion app to read, making it easy to
177    /// place an order for “the usual” from the app.
178    /// Available in iOS 7.0.
179    #[serde(rename = "userInfo")]
180    #[serde(skip_serializing_if = "Option::is_none")]
181    pub user_info: Option<HashMap<String, Option<serde_json::Value>>>,
182
183    /// Indicates that the pass is void—for example, a one time use coupon that has been
184    /// redeemed.
185    /// Available in iOS 7.0.
186    #[serde(rename = "voided")]
187    #[serde(skip_serializing_if = "Option::is_none")]
188    pub voided: Option<bool>,
189
190    /// The URL of a web service that conforms to the API described in PassKit Web Service
191    /// Reference. The web service must use the HTTPS protocol; the leading https:// is included
192    /// in the value of this key. On devices configured for development, there is UI in Settings
193    /// to allow HTTP web services.
194    #[serde(rename = "webServiceURL")]
195    #[serde(skip_serializing_if = "Option::is_none")]
196    pub web_service_url: Option<String>,
197}
198
199impl Template {
200    /// Create a new Instance
201    pub fn new(
202        description: &str,
203        organization_name: &str,
204        pass_type_identifier: &str,
205        serial_number: &str,
206    ) -> Self {
207        Self {
208            app_launch_url: None,
209            associated_store_identifiers: None,
210            authentication_token: None,
211            background_color: None,
212            barcode: None,
213            barcodes: None,
214            beacons: None,
215            boarding_pass: None,
216            coupon: None,
217            description: description.into(),
218            event_ticket: None,
219            expiration_date: None,
220            foreground_color: None,
221            format_version: None,
222            generic: None,
223            grouping_identifier: None,
224            label_color: None,
225            locations: None,
226            logo_text: None,
227            max_distance: None,
228            nfc: None,
229            organization_name: organization_name.into(),
230            pass_type_identifier: pass_type_identifier.into(),
231            relevant_date: None,
232            serial_number: serial_number.into(),
233            store_card: None,
234            suppress_strip_shine: None,
235            team_identifier: None,
236            user_info: None,
237            voided: None,
238            web_service_url: None,
239        }
240    }
241
242    /// A URL to be passed to the associated app when launching it. The app receives this URL in
243    /// the application:didFinishLaunchingWithOptions: and application:openURL:options: methods
244    /// of its app delegate.
245    pub fn app_launch_url(&mut self, app_launch_url: &str) {
246        self.app_launch_url = Some(app_launch_url.into());
247    }
248
249    /// A list of iTunes Store item identifiers for the associated apps.
250    /// Only one item in the list is used—the first item identifier for an app compatible with
251    /// the current device. If the app is not installed, the link opens the App Store and shows
252    /// the app. If the app is already installed, the link launches the app.
253    pub fn add_associated_store_identifiers(&mut self, associated_store_identifier: f64) {
254        let mut vec = match &self.associated_store_identifiers {
255            Some(vec) => vec.clone(),
256            None => Vec::new(),
257        };
258
259        vec.push(associated_store_identifier);
260        self.associated_store_identifiers = Some(vec);
261    }
262
263    /// A list of iTunes Store item identifiers for the associated apps.
264    /// Only one item in the list is used—the first item identifier for an app compatible with
265    /// the current device. If the app is not installed, the link opens the App Store and shows
266    /// the app. If the app is already installed, the link launches the app.
267    pub fn clear_associated_store_identifiers(&mut self) {
268        self.associated_store_identifiers = None;
269    }
270
271    /// The authentication token to use with the web service.
272    pub fn authentication_token(&mut self, authentication_token: &str) {
273        self.authentication_token = Some(authentication_token.into());
274    }
275
276    /// Background color of the pass, specified as an CSS-style RGB triple.
277    pub fn background_color(&mut self, background_color: &str) {
278        self.background_color = Some(background_color.into());
279    }
280
281    /// Information specific to the pass’s barcode.
282    /// Deprecated in iOS 9.0 and later; use barcodes instead.
283    pub fn barcode(&mut self, barcode: Barcode) {
284        self.barcode = Some(barcode);
285    }
286
287    /// Information specific to the pass’s barcode. The system uses the first valid barcode
288    /// dictionary in the array. Additional dictionaries can be added as fallbacks.
289    /// Available only in iOS 9.0 and later.
290    pub fn add_barcodes(&mut self, barcode: Barcode) {
291        let mut vec = match &self.barcodes {
292            Some(vec) => vec.clone(),
293            None => Vec::new(),
294        };
295
296        vec.push(barcode);
297        self.barcodes = Some(vec);
298    }
299
300    /// Information specific to the pass’s barcode. The system uses the first valid barcode
301    /// dictionary in the array. Additional dictionaries can be added as fallbacks.
302    /// Available only in iOS 9.0 and later.
303    pub fn clear_barcodes(&mut self) {
304        self.barcodes = None;
305    }
306
307    /// Beacons marking locations where the pass is relevant.
308    /// Available in iOS 7.0.
309    pub fn add_beacon(&mut self, beacon: Beacon) {
310        let mut vec = match &self.beacons {
311            Some(vec) => vec.clone(),
312            None => Vec::new(),
313        };
314
315        vec.push(beacon);
316        self.beacons = Some(vec);
317    }
318
319    /// Beacons marking locations where the pass is relevant.
320    /// Available in iOS 7.0.
321    pub fn clear_beacons(&mut self) {
322        self.beacons = None;
323    }
324
325    /// Information specific to a boarding pass.
326    pub fn boarding_pass(&mut self, boarding_pass: BoardingPass) {
327        self.boarding_pass = Some(boarding_pass);
328    }
329
330    /// Information specific to a coupon.
331    pub fn coupon(&mut self, coupon: Details) {
332        self.coupon = Some(coupon);
333    }
334
335    /// Brief description of the pass, used by the iOS accessibility technologies.
336    /// Don’t try to include all of the data on the pass in its description, just include enough
337    /// detail to distinguish passes of the same type.
338    /// Localizable.
339    pub fn description(&mut self, description: &str) {
340        self.description = description.into();
341    }
342
343    /// Information specific to an event ticket.
344    pub fn event_ticket(&mut self, event_ticket: Details) {
345        self.event_ticket = Some(event_ticket);
346    }
347
348    /// Date and time when the pass expires.
349    /// Available in iOS 7.0.
350    pub fn expiration_date(&mut self, expiration_date: &str) {
351        self.expiration_date = Some(expiration_date.into());
352    }
353
354    /// Foreground color of the pass, specified as a CSS-style RGB triple
355    pub fn foreground_color(&mut self, foreground_color: &str) {
356        self.foreground_color = Some(foreground_color.into());
357    }
358
359    /// Version of the file format.
360    pub fn format_version(&mut self, format_version: serde_json::Value) {
361        self.format_version = Some(format_version);
362    }
363
364    /// Information specific to a generic pass.
365    pub fn generic(&mut self, generic: Details) {
366        self.generic = Some(generic);
367    }
368
369    /// Identifier used to group related passes. If a grouping identifier is specified, passes
370    /// with the same style, pass type identifier, and grouping identifier are displayed as a
371    /// group. Otherwise, passes are grouped automatically.
372    /// Use this to group passes that are tightly related, such as the boarding passes for
373    /// different connections of the same trip.
374    /// Available in iOS 7.0.
375    pub fn grouping_identifier(&mut self, grouping_identifier: &str) {
376        self.grouping_identifier = Some(grouping_identifier.into());
377    }
378
379    /// olor of the label text, specified as a CSS-style RGB triple.
380    /// If omitted, the label color is determined automatically.
381    pub fn label_color(&mut self, label_color: &str) {
382        self.label_color = Some(label_color.into());
383    }
384
385    /// Locations where the pass is relevant. For example, the location of your store.
386    pub fn add_location(&mut self, location: Location) {
387        let mut vec = match &self.locations {
388            Some(vec) => vec.clone(),
389            None => Vec::new(),
390        };
391
392        vec.push(location);
393        self.locations = Some(vec);
394    }
395
396    /// Locations where the pass is relevant. For example, the location of your store.
397    pub fn clear_locations(&mut self) {
398        self.locations = None;
399    }
400
401    /// Text displayed next to the logo on the pass.
402    /// Localizable.
403    pub fn logo_text(&mut self, logo_text: &str) {
404        self.logo_text = Some(logo_text.into());
405    }
406
407    /// Maximum distance in meters from a relevant latitude and longitude that the pass is
408    /// relevant. This number is compared to the pass’s default distance and the smaller value is
409    /// used.
410    /// Available in iOS 7.0.
411    pub fn max_distance(&mut self, max_distance: f64) {
412        self.max_distance = Some(max_distance);
413    }
414
415    /// Information used for Value Added Service Protocol transactions.
416    /// Available in iOS 9.0.
417    pub fn nfc(&mut self, nfc: Nfc) {
418        self.nfc = Some(nfc);
419    }
420
421    /// Display name of the organization that originated and signed the pass.
422    /// Localizable.
423    pub fn organization_name(&mut self, organization_name: &str) {
424        self.organization_name = organization_name.into();
425    }
426
427    /// Pass type identifier, as issued by Apple. The value must correspond with your signing
428    /// certificate.
429    pub fn pass_type_identifier(&mut self, pass_type_identifier: &str) {
430        self.pass_type_identifier = pass_type_identifier.into();
431    }
432
433    /// Date and time when the pass becomes relevant. For example, the start time of a movie.
434    /// Recommended for event tickets and boarding passes.
435    pub fn relevant_date(&mut self, relevant_date: &str) {
436        self.relevant_date = Some(relevant_date.into());
437    }
438
439    /// Serial number that uniquely identifies the pass. No two passes with the same pass type
440    /// identifier may have the same serial number.
441    pub fn serial_number(&mut self, serial_number: &str) {
442        self.serial_number = serial_number.into();
443    }
444
445    /// Information specific to a store card.
446    pub fn store_card(&mut self, store_card: Details) {
447        self.store_card = Some(store_card);
448    }
449
450    /// If true, the strip image is displayed without a shine effect. The default value prior to
451    /// iOS 7.0 is false. In iOS 7.0, a shine effect is never applied, and this key is deprecated.
452    pub fn suppress_strip_shine(&mut self, suppress_strip_shine: bool) {
453        self.suppress_strip_shine = Some(suppress_strip_shine);
454    }
455
456    /// Team identifier of the organization that originated and signed the pass, as issued by
457    /// Apple.
458    pub fn team_identifier(&mut self, team_identifier: &str) {
459        self.team_identifier = Some(team_identifier.into());
460    }
461
462    /// Custom information for companion apps. This data is not displayed to the user.
463    /// For example, a pass for a cafe could include information about the user’s favorite drink
464    /// and sandwich in a machine-readable form for the companion app to read, making it easy to
465    /// place an order for “the usual” from the app.
466    /// Available in iOS 7.0.
467    pub fn add_user_info(&mut self, key: &str, value: serde_json::Value) {
468        let mut map = match &self.user_info {
469            Some(map) => map.clone(),
470            None => HashMap::new(),
471        };
472
473        map.insert(key.into(), Some(value));
474        self.user_info = Some(map);
475    }
476
477    /// Custom information for companion apps. This data is not displayed to the user.
478    /// For example, a pass for a cafe could include information about the user’s favorite drink
479    /// and sandwich in a machine-readable form for the companion app to read, making it easy to
480    /// place an order for “the usual” from the app.
481    /// Available in iOS 7.0.
482    pub fn clear_user_info(&mut self) {
483        self.user_info = None;
484    }
485
486    /// Indicates that the pass is void—for example, a one time use coupon that has been
487    /// redeemed.
488    /// Available in iOS 7.0.
489    pub fn voided(&mut self, voided: bool) {
490        self.voided = Some(voided);
491    }
492
493    /// The URL of a web service that conforms to the API described in PassKit Web Service
494    /// Reference. The web service must use the HTTPS protocol; the leading https:// is included
495    /// in the value of this key. On devices configured for development, there is UI in Settings
496    /// to allow HTTP web services.
497    pub fn web_service_url(&mut self, web_service_url: &str) {
498        self.web_service_url = Some(web_service_url.into());
499    }
500}
501
502/// Information specific to the pass’s barcode.
503/// Deprecated in iOS 9.0 and later; use barcodes instead.
504///
505/// Information about a pass’s barcode.
506#[derive(Debug, Clone, Serialize, Deserialize)]
507pub struct Barcode {
508    /// Text displayed near the barcode. For example, a human-readable version of the barcode
509    /// data in case the barcode doesn’t scan.
510    #[serde(rename = "altText")]
511    #[serde(skip_serializing_if = "Option::is_none")]
512    pub alt_text: Option<String>,
513
514    /// Barcode format. PKBarcodeFormatCode128 may only be used for dictionaries in the barcodes
515    /// array.
516    #[serde(rename = "format")]
517    pub format: BarcodeFormat,
518
519    /// Message or payload to be displayed as a barcode.
520    #[serde(rename = "message")]
521    pub message: String,
522
523    /// Text encoding that is used to convert the message from the string representation to a
524    /// data representation to render the barcode. The value is typically iso-8859-1, but you may
525    /// use another encoding that is supported by your barcode scanning infrastructure.
526    #[serde(rename = "messageEncoding")]
527    pub message_encoding: String,
528}
529
530impl Barcode {
531    /// Create a new Instance
532    pub fn new(format: BarcodeFormat, message: &str, message_encoding: &str) -> Self {
533        Self {
534            alt_text: None,
535            format,
536            message: message.into(),
537            message_encoding: message_encoding.into(),
538        }
539    }
540}
541
542/// Information about a location beacon.
543#[derive(Debug, Clone, Serialize, Deserialize)]
544pub struct Beacon {
545    /// Major identifier of a Bluetooth Low Energy location beacon.
546    #[serde(rename = "major")]
547    #[serde(skip_serializing_if = "Option::is_none")]
548    pub major: Option<i64>,
549
550    /// Minor identifier of a Bluetooth Low Energy location beacon.
551    #[serde(rename = "minor")]
552    #[serde(skip_serializing_if = "Option::is_none")]
553    pub minor: Option<i64>,
554
555    /// Unique identifier of a Bluetooth Low Energy location beacon.
556    #[serde(rename = "proximityUUID")]
557    pub proximity_uuid: String,
558
559    /// Text displayed on the lock screen when the pass is currently relevant.
560    #[serde(rename = "relevantText")]
561    #[serde(skip_serializing_if = "Option::is_none")]
562    pub relevant_text: Option<String>,
563}
564
565impl Beacon {
566    /// Create a new Instance
567    pub fn new(proximity_uuid: &str) -> Self {
568        Self {
569            major: None,
570            minor: None,
571            proximity_uuid: proximity_uuid.into(),
572            relevant_text: None,
573        }
574    }
575}
576
577/// Information specific to a boarding pass.
578///
579/// Keys that define the structure of the pass.
580/// These keys are used for all pass styles and partition the fields into the various parts
581/// of the pass.
582#[derive(Debug, Clone, Serialize, Deserialize)]
583pub struct BoardingPass {
584    /// Type of transit.
585    #[serde(rename = "transitType")]
586    pub transit_type: TransitType,
587
588    /// Additional fields to be displayed on the front of the pass.
589    #[serde(rename = "auxiliaryFields")]
590    #[serde(skip_serializing_if = "Option::is_none")]
591    pub auxiliary_fields: Option<Vec<Field>>,
592
593    /// Fields to be on the back of the pass.
594    #[serde(rename = "backFields")]
595    #[serde(skip_serializing_if = "Option::is_none")]
596    pub back_fields: Option<Vec<Field>>,
597
598    /// Fields to be displayed in the header on the front of the pass.Use header fields
599    /// sparingly; unlike all other fields, they remain visible when a stack of passes are
600    /// displayed.
601    #[serde(rename = "headerFields")]
602    #[serde(skip_serializing_if = "Option::is_none")]
603    pub header_fields: Option<Vec<Field>>,
604
605    /// Fields to be displayed prominently on the front of the pass.
606    #[serde(rename = "primaryFields")]
607    #[serde(skip_serializing_if = "Option::is_none")]
608    pub primary_fields: Option<Vec<Field>>,
609
610    /// Fields to be displayed on the front of the pass.
611    #[serde(rename = "secondaryFields")]
612    #[serde(skip_serializing_if = "Option::is_none")]
613    pub secondary_fields: Option<Vec<Field>>,
614}
615
616impl BoardingPass {
617    /// Create a new Instance
618    pub fn new(transit_type: TransitType) -> Self {
619        Self {
620            transit_type,
621            auxiliary_fields: None,
622            back_fields: None,
623            header_fields: None,
624            primary_fields: None,
625            secondary_fields: None,
626        }
627    }
628}
629
630/// Keys that define an individual field.
631#[derive(Debug, Clone, Serialize, Deserialize)]
632pub struct Field {
633    /// Attributed value of the field.
634    /// The value may contain HTML markup for links. Only the <a> tag and its href attribute are
635    /// supported. This key’s value overrides the text specified by the value key.
636    /// Available in iOS 7.0.
637    #[serde(rename = "attributedValue")]
638    #[serde(skip_serializing_if = "Option::is_none")]
639    pub attributed_value: Option<ValueUnion>,
640
641    /// Format string for the alert text that is displayed when the pass is updated. The format
642    /// string must contain the escape %@, which is replaced with the field’s new value. If you
643    /// don’t specify a change message, the user isn’t notified when the field changes.
644    /// Localizable.
645    #[serde(rename = "changeMessage")]
646    #[serde(skip_serializing_if = "Option::is_none")]
647    pub change_message: Option<String>,
648
649    /// Code of currency
650    #[serde(rename = "currencyCode")]
651    #[serde(skip_serializing_if = "Option::is_none")]
652    pub currency_code: Option<String>,
653
654    /// Data detectors that are applied to the field’s value. Provide an empty array to use no
655    /// data detectors. Data detectors are applied only to back fields.
656    #[serde(rename = "dataDetectorTypes")]
657    #[serde(skip_serializing_if = "Option::is_none")]
658    pub data_detector_types: Option<Vec<serde_json::Value>>,
659
660    /// Style of date to display.
661    #[serde(rename = "dateStyle")]
662    #[serde(skip_serializing_if = "Option::is_none")]
663    pub date_style: Option<EStyle>,
664
665    /// Always display the time and date in the given time zone, not in the user’s current time
666    /// zone.
667    /// The format for a date and time always requires a time zone, even if it will be ignored.
668    /// For backward compatibility with iOS 6, provide an appropriate time zone, so that the
669    /// information is displayed meaningfully even without ignoring time zones.
670    /// This key does not affect how relevance is calculated.
671    /// Available in iOS 7.0.
672    #[serde(rename = "ignoresTimeZone")]
673    #[serde(skip_serializing_if = "Option::is_none")]
674    pub ignores_time_zone: Option<bool>,
675
676    /// If true, the label’s value is displayed as a relative date; otherwise, it is displayed as
677    /// an absolute date.
678    /// This key does not affect how relevance is calculated.
679    #[serde(rename = "isRelative")]
680    #[serde(skip_serializing_if = "Option::is_none")]
681    pub is_relative: Option<bool>,
682
683    /// The key must be unique within the scope of the entire pass.
684    #[serde(rename = "key")]
685    pub key: String,
686
687    /// Label text for the field.
688    /// Localizable.
689    #[serde(rename = "label")]
690    #[serde(skip_serializing_if = "Option::is_none")]
691    pub label: Option<String>,
692
693    /// Style of number to display. Number styles have the same meaning as the Cocoa number
694    /// formatter styles with corresponding names. See
695    /// https://developer.apple.com/documentation/foundation/nsnumberformatterstyle
696    #[serde(rename = "numberStyle")]
697    #[serde(skip_serializing_if = "Option::is_none")]
698    pub number_style: Option<NumberStyle>,
699
700    /// Machine-readable metadata to allow the system to offer Wallet passes to users
701    /// intelligently.
702    #[serde(rename = "semantics")]
703    #[serde(skip_serializing_if = "Option::is_none")]
704    pub semantics: Option<Semantics>,
705
706    /// Alignment for the field’s contents.
707    /// This key is not allowed for primary fields or back fields.
708    #[serde(rename = "textAlignment")]
709    #[serde(skip_serializing_if = "Option::is_none")]
710    pub text_alignment: Option<TextAlignment>,
711
712    /// Style of time to display.
713    #[serde(rename = "timeStyle")]
714    #[serde(skip_serializing_if = "Option::is_none")]
715    pub time_style: Option<EStyle>,
716
717    /// Value of the field
718    #[serde(rename = "value")]
719    pub value: ValueUnion,
720
721    /// Row for auxiliary fields. Set to 1 to add an extra row for auxiliary fields.
722    #[serde(rename = "row")]
723    #[serde(skip_serializing_if = "Option::is_none")]
724    pub row: Option<i32>,
725}
726
727impl Field {
728    /// Create a new Instance with a String value
729    pub fn new_string(key: &str, value: &str) -> Self {
730        Self {
731            attributed_value: None,
732            change_message: None,
733            currency_code: None,
734            data_detector_types: None,
735            date_style: None,
736            ignores_time_zone: None,
737            is_relative: None,
738            key: key.into(),
739            label: None,
740            number_style: None,
741            semantics: None,
742            text_alignment: None,
743            time_style: None,
744            value: ValueUnion::String(value.into()),
745            row: None,
746        }
747    }
748
749    /// Create a new Instance with a Double value
750    pub fn new_f64(key: &str, value: f64) -> Self {
751        Self {
752            attributed_value: None,
753            change_message: None,
754            currency_code: None,
755            data_detector_types: None,
756            date_style: None,
757            ignores_time_zone: None,
758            is_relative: None,
759            key: key.into(),
760            label: None,
761            number_style: None,
762            semantics: None,
763            text_alignment: None,
764            time_style: None,
765            value: ValueUnion::Double(value),
766            row: None,
767        }
768    }
769
770    /// Attributed value of the field.
771    /// The value may contain HTML markup for links. Only the <a> tag and its href attribute are
772    /// supported. This key’s value overrides the text specified by the value key.
773    /// Available in iOS 7.0.
774    pub fn attributed_value(&mut self, attributed_value: ValueUnion) {
775        self.attributed_value = Some(attributed_value);
776    }
777
778    /// Format string for the alert text that is displayed when the pass is updated. The format
779    /// string must contain the escape %@, which is replaced with the field’s new value. If you
780    /// don’t specify a change message, the user isn’t notified when the field changes.
781    /// Localizable.
782    pub fn change_message(&mut self, change_message: &str) {
783        self.change_message = Some(change_message.into());
784    }
785
786    /// Code of currency
787    pub fn currency_code(&mut self, currency_code: &str) {
788        self.currency_code = Some(currency_code.into());
789    }
790
791    /// Data detectors that are applied to the field’s value. Provide an empty array to use no
792    /// data detectors. Data detectors are applied only to back fields.
793    pub fn clear_data_detector_types(&mut self) {
794        self.data_detector_types = None;
795    }
796
797    /// Data detectors that are applied to the field’s value. Provide an empty array to use no
798    /// data detectors. Data detectors are applied only to back fields.
799    pub fn add_data_detector_type(&mut self, data_detector_type: serde_json::Value) {
800        let mut vec = match &self.data_detector_types {
801            Some(vec) => vec.clone(),
802            None => Vec::new(),
803        };
804        vec.push(data_detector_type);
805
806        self.data_detector_types = Some(vec);
807    }
808
809    /// Style of date to display.
810    pub fn date_style(&mut self, date_style: EStyle) {
811        self.date_style = Some(date_style);
812    }
813
814    /// Always display the time and date in the given time zone, not in the user’s current time
815    /// zone.
816    /// The format for a date and time always requires a time zone, even if it will be ignored.
817    /// For backward compatibility with iOS 6, provide an appropriate time zone, so that the
818    /// information is displayed meaningfully even without ignoring time zones.
819    /// This key does not affect how relevance is calculated.
820    /// Available in iOS 7.0.
821    pub fn ignores_time_zone(&mut self, ignores_time_zone: bool) {
822        self.ignores_time_zone = Some(ignores_time_zone);
823    }
824
825    /// If true, the label’s value is displayed as a relative date; otherwise, it is displayed as
826    /// an absolute date.
827    /// This key does not affect how relevance is calculated.
828    pub fn is_relative(&mut self, is_relative: bool) {
829        self.is_relative = Some(is_relative);
830    }
831
832    /// Label text for the field.
833    /// Localizable.
834    pub fn label(&mut self, label: &str) {
835        self.label = Some(label.into());
836    }
837
838    /// Style of number to display. Number styles have the same meaning as the Cocoa number
839    /// formatter styles with corresponding names. See
840    /// https://developer.apple.com/documentation/foundation/nsnumberformatterstyle
841    pub fn number_style(&mut self, number_style: NumberStyle) {
842        self.number_style = Some(number_style);
843    }
844
845    /// Machine-readable metadata to allow the system to offer Wallet passes to users
846    /// intelligently.
847    pub fn semantics(&mut self, semantics: Semantics) {
848        self.semantics = Some(semantics);
849    }
850
851    /// Alignment for the field’s contents.
852    /// This key is not allowed for primary fields or back fields.
853    pub fn text_alignment(&mut self, text_alignment: TextAlignment) {
854        self.text_alignment = Some(text_alignment);
855    }
856
857    /// Style of time to display.
858    pub fn time_style(&mut self, time_style: EStyle) {
859        self.time_style = Some(time_style);
860    }
861
862    /// Add row information for auxiliary fields
863    pub fn row(&mut self, row: i32) {
864        self.row = Some(row);
865    }
866}
867
868/// Machine-readable metadata to allow the system to offer Wallet passes to users
869/// intelligently.
870#[derive(Debug, Clone, Serialize, Deserialize)]
871pub struct Semantics {
872    /// The IATA airline code, such as 'EX' for flightCode 'EX123'.
873    #[serde(rename = "airlineCode")]
874    #[serde(skip_serializing_if = "Option::is_none")]
875    pub airline_code: Option<String>,
876
877    /// The Adam IDs for the artists performing, in decreasing order of significance.
878    #[serde(rename = "artistIDs")]
879    #[serde(skip_serializing_if = "Option::is_none")]
880    pub artist_i_ds: Option<Vec<String>>,
881
882    /// The unique abbreviation of the away team's name.
883    #[serde(rename = "awayTeamAbbreviation")]
884    #[serde(skip_serializing_if = "Option::is_none")]
885    pub away_team_abbreviation: Option<String>,
886
887    /// The home location of the away team.
888    #[serde(rename = "awayTeamLocation")]
889    #[serde(skip_serializing_if = "Option::is_none")]
890    pub away_team_location: Option<String>,
891
892    /// The name of the away team.
893    #[serde(rename = "awayTeamName")]
894    #[serde(skip_serializing_if = "Option::is_none")]
895    pub away_team_name: Option<String>,
896
897    /// The balance redeemable with the pass.
898    #[serde(rename = "balance")]
899    #[serde(skip_serializing_if = "Option::is_none")]
900    pub balance: Option<CurrencyAmount>,
901
902    /// A group number for boarding.
903    #[serde(rename = "boardingGroup")]
904    #[serde(skip_serializing_if = "Option::is_none")]
905    pub boarding_group: Option<String>,
906
907    /// A sequence number for boarding.
908    #[serde(rename = "boardingSequenceNumber")]
909    #[serde(skip_serializing_if = "Option::is_none")]
910    pub boarding_sequence_number: Option<String>,
911
912    /// The car number.
913    #[serde(rename = "carNumber")]
914    #[serde(skip_serializing_if = "Option::is_none")]
915    pub car_number: Option<String>,
916
917    /// A booking or reservation confirmation number.
918    #[serde(rename = "confirmationNumber")]
919    #[serde(skip_serializing_if = "Option::is_none")]
920    pub confirmation_number: Option<String>,
921
922    /// The updated date and time of arrival, if different than the original scheduled date.
923    #[serde(rename = "currentArrivalDate")]
924    #[serde(skip_serializing_if = "Option::is_none")]
925    pub current_arrival_date: Option<String>,
926
927    /// The updated date and time of boarding, if different than the original scheduled date.
928    #[serde(rename = "currentBoardingDate")]
929    #[serde(skip_serializing_if = "Option::is_none")]
930    pub current_boarding_date: Option<String>,
931
932    /// The updated date and time of departure, if different than the original scheduled date.
933    #[serde(rename = "currentDepartureDate")]
934    #[serde(skip_serializing_if = "Option::is_none")]
935    pub current_departure_date: Option<String>,
936
937    /// The IATA airport code for the departure airport.
938    #[serde(rename = "departureAirportCode")]
939    #[serde(skip_serializing_if = "Option::is_none")]
940    pub departure_airport_code: Option<String>,
941
942    /// The full name of the departure airport
943    #[serde(rename = "departureAirportName")]
944    #[serde(skip_serializing_if = "Option::is_none")]
945    pub departure_airport_name: Option<String>,
946
947    /// The gate number or letters of the departure gate, such as '1A'. Do not include the word
948    /// 'Gate'.
949    #[serde(rename = "departureGate")]
950    #[serde(skip_serializing_if = "Option::is_none")]
951    pub departure_gate: Option<String>,
952
953    /// The geographic coordinates of the transit departure, suitable to be shown on a map. If
954    /// possible, precise locations are more useful to travelers, such as the specific location
955    /// of the gate at an airport.
956    #[serde(rename = "departureLocation")]
957    #[serde(skip_serializing_if = "Option::is_none")]
958    pub departure_location: Option<Location>,
959
960    /// A brief description of the departure location.
961    #[serde(rename = "departureLocationDescription")]
962    #[serde(skip_serializing_if = "Option::is_none")]
963    pub departure_location_description: Option<String>,
964
965    /// The name of the departure platform, such as 'A'. Do not include the word 'Platform'.
966    #[serde(rename = "departurePlatform")]
967    #[serde(skip_serializing_if = "Option::is_none")]
968    pub departure_platform: Option<String>,
969
970    /// The name of the departure station.
971    #[serde(rename = "departureStationName")]
972    #[serde(skip_serializing_if = "Option::is_none")]
973    pub departure_station_name: Option<String>,
974
975    /// The terminal name or letter of the departure terminal, such as 'A'. Do not include the
976    /// word 'Terminal'
977    #[serde(rename = "departureTerminal")]
978    #[serde(skip_serializing_if = "Option::is_none")]
979    pub departure_terminal: Option<String>,
980
981    /// The IATA airport code for the destination airport.
982    #[serde(rename = "destinationAirportCode")]
983    #[serde(skip_serializing_if = "Option::is_none")]
984    pub destination_airport_code: Option<String>,
985
986    /// The full name of the destination airport
987    #[serde(rename = "destinationAirportName")]
988    #[serde(skip_serializing_if = "Option::is_none")]
989    pub destination_airport_name: Option<String>,
990
991    /// The gate number or letters of the destination gate, such as '1A'. Do not include the word
992    /// 'Gate'.
993    #[serde(rename = "destinationGate")]
994    #[serde(skip_serializing_if = "Option::is_none")]
995    pub destination_gate: Option<String>,
996
997    /// The geographic coordinates of the transit destination, suitable to be shown on a map.
998    #[serde(rename = "destinationLocation")]
999    #[serde(skip_serializing_if = "Option::is_none")]
1000    pub destination_location: Option<Location>,
1001
1002    /// A brief description of the destination location.
1003    #[serde(rename = "destinationLocationDescription")]
1004    #[serde(skip_serializing_if = "Option::is_none")]
1005    pub destination_location_description: Option<Location>,
1006
1007    /// The name of the destination platform, such as 'A'. Do not include the word 'Platform'.
1008    #[serde(rename = "destinationPlatform")]
1009    #[serde(skip_serializing_if = "Option::is_none")]
1010    pub destination_platform: Option<String>,
1011
1012    /// The name of the destination station.
1013    #[serde(rename = "destinationStationName")]
1014    #[serde(skip_serializing_if = "Option::is_none")]
1015    pub destination_station_name: Option<String>,
1016
1017    /// The terminal name or letter of the destination terminal, such as 'A'. Do not include the
1018    /// word 'Terminal'
1019    #[serde(rename = "destinationTerminal")]
1020    #[serde(skip_serializing_if = "Option::is_none")]
1021    pub destination_terminal: Option<String>,
1022
1023    /// The duration of the event or transit journey, in seconds.
1024    #[serde(rename = "duration")]
1025    #[serde(skip_serializing_if = "Option::is_none")]
1026    pub duration: Option<f64>,
1027
1028    /// The date and time the event ends.
1029    #[serde(rename = "eventEndDate")]
1030    #[serde(skip_serializing_if = "Option::is_none")]
1031    pub event_end_date: Option<String>,
1032
1033    /// The full name for the event, such as the title of a movie.
1034    #[serde(rename = "eventName")]
1035    #[serde(skip_serializing_if = "Option::is_none")]
1036    pub event_name: Option<String>,
1037
1038    /// The date and time the event starts.
1039    #[serde(rename = "eventStartDate")]
1040    #[serde(skip_serializing_if = "Option::is_none")]
1041    pub event_start_date: Option<String>,
1042
1043    /// The event type.
1044    #[serde(rename = "eventType")]
1045    #[serde(skip_serializing_if = "Option::is_none")]
1046    pub event_type: Option<EventType>,
1047
1048    /// The IATA flight code
1049    #[serde(rename = "flightCode")]
1050    #[serde(skip_serializing_if = "Option::is_none")]
1051    pub flight_code: Option<String>,
1052
1053    /// The numeric portion of the IATA flightCode, such as 123 for flightCode 'EX123'
1054    #[serde(rename = "flightNumber")]
1055    #[serde(skip_serializing_if = "Option::is_none")]
1056    pub flight_number: Option<f64>,
1057
1058    /// The genre of the performance.
1059    #[serde(rename = "genre")]
1060    #[serde(skip_serializing_if = "Option::is_none")]
1061    pub genre: Option<String>,
1062
1063    /// The unique abbreviation of the home team's name.
1064    #[serde(rename = "homeTeamAbbreviation")]
1065    #[serde(skip_serializing_if = "Option::is_none")]
1066    pub home_team_abbreviation: Option<String>,
1067
1068    /// The home location of the home team.
1069    #[serde(rename = "homeTeamLocation")]
1070    #[serde(skip_serializing_if = "Option::is_none")]
1071    pub home_team_location: Option<String>,
1072
1073    /// The name of the home team.
1074    #[serde(rename = "homeTeamName")]
1075    #[serde(skip_serializing_if = "Option::is_none")]
1076    pub home_team_name: Option<String>,
1077
1078    /// The abbreviated league name for a sporting event.
1079    #[serde(rename = "leagueAbbreviation")]
1080    #[serde(skip_serializing_if = "Option::is_none")]
1081    pub league_abbreviation: Option<String>,
1082
1083    /// he unabbreviated league name for a sporting event.
1084    #[serde(rename = "leagueName")]
1085    #[serde(skip_serializing_if = "Option::is_none")]
1086    pub league_name: Option<String>,
1087
1088    /// The name of a frequent flyer or loyalty program.
1089    #[serde(rename = "membershipProgramName")]
1090    #[serde(skip_serializing_if = "Option::is_none")]
1091    pub membership_program_name: Option<String>,
1092
1093    /// The ticketed passenger's frequent flyer or loyalty number.
1094    #[serde(rename = "membershipProgramNumber")]
1095    #[serde(skip_serializing_if = "Option::is_none")]
1096    pub membership_program_number: Option<String>,
1097
1098    /// The original scheduled date and time of arrival.
1099    #[serde(rename = "originalArrivalDate")]
1100    #[serde(skip_serializing_if = "Option::is_none")]
1101    pub original_arrival_date: Option<String>,
1102
1103    /// The original scheduled date and time of boarding.
1104    #[serde(rename = "originalBoardingDate")]
1105    #[serde(skip_serializing_if = "Option::is_none")]
1106    pub original_boarding_date: Option<String>,
1107
1108    /// The original scheduled date and time of departure.
1109    #[serde(rename = "originalDepartureDate")]
1110    #[serde(skip_serializing_if = "Option::is_none")]
1111    pub original_departure_date: Option<String>,
1112
1113    /// The passenger's name.
1114    #[serde(rename = "passengerName")]
1115    #[serde(skip_serializing_if = "Option::is_none")]
1116    pub passenger_name: Option<PersonNameComponents>,
1117
1118    /// The full names of the performers and opening acts, in decreasing order of significance.
1119    #[serde(rename = "performerNames")]
1120    #[serde(skip_serializing_if = "Option::is_none")]
1121    pub performer_names: Option<Vec<String>>,
1122
1123    /// he priority status held by the ticketed passenger
1124    #[serde(rename = "priorityStatus")]
1125    #[serde(skip_serializing_if = "Option::is_none")]
1126    pub priority_status: Option<String>,
1127
1128    /// Seating details for all seats at the event or transit journey.
1129    #[serde(rename = "seats")]
1130    #[serde(skip_serializing_if = "Option::is_none")]
1131    pub seats: Option<Vec<Seat>>,
1132
1133    /// The type of security screening that the ticketed passenger will be subject to, such as
1134    /// 'Priority'.
1135    #[serde(rename = "securityScreening")]
1136    #[serde(skip_serializing_if = "Option::is_none")]
1137    pub security_screening: Option<String>,
1138
1139    /// Request the user's device to remain silent during a the event or transit journey. This
1140    /// key may not be honored and the system will determine the length of the silence period.
1141    #[serde(rename = "silenceRequested")]
1142    #[serde(skip_serializing_if = "Option::is_none")]
1143    pub silence_requested: Option<bool>,
1144
1145    /// The commonly used local name of the sport.
1146    #[serde(rename = "sportName")]
1147    #[serde(skip_serializing_if = "Option::is_none")]
1148    pub sport_name: Option<String>,
1149
1150    /// The total price for the pass.
1151    #[serde(rename = "totalPrice")]
1152    #[serde(skip_serializing_if = "Option::is_none")]
1153    pub total_price: Option<CurrencyAmount>,
1154
1155    /// The name of the transit company.
1156    #[serde(rename = "transitProvider")]
1157    #[serde(skip_serializing_if = "Option::is_none")]
1158    pub transit_provider: Option<String>,
1159
1160    /// A brief description of the current status of the vessel being boarded. For delayed
1161    /// statuses, provide currentBoardingDate, currentDepartureDate, and currentArrivalDate where
1162    /// available.
1163    #[serde(rename = "transitStatus")]
1164    #[serde(skip_serializing_if = "Option::is_none")]
1165    pub transit_status: Option<String>,
1166
1167    /// A brief description explaining the reason for the current transitStatus
1168    #[serde(rename = "transitStatusReason")]
1169    #[serde(skip_serializing_if = "Option::is_none")]
1170    pub transit_status_reason: Option<String>,
1171
1172    /// The name of the vehicle being boarded, such as the name of a boat.
1173    #[serde(rename = "vehicleName")]
1174    #[serde(skip_serializing_if = "Option::is_none")]
1175    pub vehicle_name: Option<String>,
1176
1177    /// The identifier of the vehicle being boarded, such as the aircraft registration number or
1178    /// train number.
1179    #[serde(rename = "vehicleNumber")]
1180    #[serde(skip_serializing_if = "Option::is_none")]
1181    pub vehicle_number: Option<String>,
1182
1183    /// A brief description of the type of vehicle being boarded, such as the model and
1184    /// manufacturer of a plane or the class of a boat.
1185    #[serde(rename = "vehicleType")]
1186    #[serde(skip_serializing_if = "Option::is_none")]
1187    pub vehicle_type: Option<String>,
1188
1189    /// The full name of the entrance to use to gain access to the ticketed event.
1190    #[serde(rename = "venueEntrance")]
1191    #[serde(skip_serializing_if = "Option::is_none")]
1192    pub venue_entrance: Option<String>,
1193
1194    /// The geographic coordinates of the venue.
1195    #[serde(rename = "venueLocation")]
1196    #[serde(skip_serializing_if = "Option::is_none")]
1197    pub venue_location: Option<Location>,
1198
1199    /// The full name of the venue.
1200    #[serde(rename = "venueName")]
1201    #[serde(skip_serializing_if = "Option::is_none")]
1202    pub venue_name: Option<String>,
1203
1204    /// The phone number for enquiries about the venue's ticketed event.
1205    #[serde(rename = "venuePhoneNumber")]
1206    #[serde(skip_serializing_if = "Option::is_none")]
1207    pub venue_phone_number: Option<String>,
1208
1209    /// The full name of the room where the ticketed event is taking place.
1210    #[serde(rename = "venueRoom")]
1211    #[serde(skip_serializing_if = "Option::is_none")]
1212    pub venue_room: Option<String>,
1213}
1214
1215impl Semantics {
1216    /// Create a new Instance
1217    pub fn new() -> Self {
1218        Self {
1219            airline_code: None,
1220            artist_i_ds: None,
1221            away_team_abbreviation: None,
1222            away_team_location: None,
1223            away_team_name: None,
1224            balance: None,
1225            boarding_group: None,
1226            boarding_sequence_number: None,
1227            car_number: None,
1228            confirmation_number: None,
1229            current_arrival_date: None,
1230            current_boarding_date: None,
1231            current_departure_date: None,
1232            departure_airport_code: None,
1233            departure_airport_name: None,
1234            departure_gate: None,
1235            departure_location: None,
1236            departure_location_description: None,
1237            departure_platform: None,
1238            departure_station_name: None,
1239            departure_terminal: None,
1240            destination_airport_code: None,
1241            destination_airport_name: None,
1242            destination_gate: None,
1243            destination_location: None,
1244            destination_location_description: None,
1245            destination_platform: None,
1246            destination_station_name: None,
1247            destination_terminal: None,
1248            duration: None,
1249            event_end_date: None,
1250            event_name: None,
1251            event_start_date: None,
1252            event_type: None,
1253            flight_code: None,
1254            flight_number: None,
1255            genre: None,
1256            home_team_abbreviation: None,
1257            home_team_location: None,
1258            home_team_name: None,
1259            league_abbreviation: None,
1260            league_name: None,
1261            membership_program_name: None,
1262            membership_program_number: None,
1263            original_arrival_date: None,
1264            original_boarding_date: None,
1265            original_departure_date: None,
1266            passenger_name: None,
1267            performer_names: None,
1268            priority_status: None,
1269            seats: None,
1270            security_screening: None,
1271            silence_requested: None,
1272            sport_name: None,
1273            total_price: None,
1274            transit_provider: None,
1275            transit_status: None,
1276            transit_status_reason: None,
1277            vehicle_name: None,
1278            vehicle_number: None,
1279            vehicle_type: None,
1280            venue_entrance: None,
1281            venue_location: None,
1282            venue_name: None,
1283            venue_phone_number: None,
1284            venue_room: None,
1285        }
1286    }
1287}
1288
1289impl Default for Semantics {
1290    fn default() -> Self {
1291        Self::new()
1292    }
1293}
1294
1295/// The balance redeemable with the pass.
1296///
1297/// An ISO 4217 currency code and an amount.
1298///
1299/// The total price for the pass.
1300#[derive(Debug, Clone, Serialize, Deserialize)]
1301pub struct CurrencyAmount {
1302    /// Amount of currency
1303    #[serde(rename = "amount")]
1304    #[serde(skip_serializing_if = "Option::is_none")]
1305    pub amount: Option<String>,
1306
1307    /// Code of currency
1308    #[serde(rename = "currencyCode")]
1309    #[serde(skip_serializing_if = "Option::is_none")]
1310    pub currency_code: Option<String>,
1311}
1312
1313impl CurrencyAmount {
1314    /// Create a new Instance
1315    pub fn new() -> Self {
1316        Self {
1317            amount: None,
1318            currency_code: None,
1319        }
1320    }
1321}
1322
1323impl Default for CurrencyAmount {
1324    fn default() -> Self {
1325        Self::new()
1326    }
1327}
1328
1329/// The geographic coordinates of the transit departure, suitable to be shown on a map. If
1330/// possible, precise locations are more useful to travelers, such as the specific location
1331/// of the gate at an airport.
1332///
1333/// Information about a location.
1334///
1335/// The geographic coordinates of the transit destination, suitable to be shown on a map.
1336///
1337/// A brief description of the destination location.
1338///
1339/// The geographic coordinates of the venue.
1340#[derive(Debug, Clone, Serialize, Deserialize)]
1341pub struct Location {
1342    /// Altitude, in meters, of the location.
1343    #[serde(rename = "altitude")]
1344    #[serde(skip_serializing_if = "Option::is_none")]
1345    pub altitude: Option<f64>,
1346
1347    /// Latitude, in degrees, of the location.
1348    #[serde(rename = "latitude")]
1349    pub latitude: f64,
1350
1351    /// Longitude, in degrees, of the location.
1352    #[serde(rename = "longitude")]
1353    pub longitude: f64,
1354
1355    /// Text displayed on the lock screen when the pass is currently relevant.
1356    #[serde(rename = "relevantText")]
1357    #[serde(skip_serializing_if = "Option::is_none")]
1358    pub relevant_text: Option<String>,
1359}
1360
1361impl Location {
1362    /// Create a new Instance
1363    pub fn new(latitude: f64, longitude: f64) -> Self {
1364        Self {
1365            altitude: None,
1366            latitude,
1367            longitude,
1368            relevant_text: None,
1369        }
1370    }
1371}
1372
1373/// The passenger's name.
1374///
1375/// An object that manages the separate parts of a person's name
1376#[derive(Debug, Clone, Serialize, Deserialize)]
1377pub struct PersonNameComponents {
1378    /// Name bestowed upon an individual to denote membership in a group or family.
1379    #[serde(rename = "familyName")]
1380    #[serde(skip_serializing_if = "Option::is_none")]
1381    pub family_name: Option<String>,
1382
1383    /// Name bestowed upon an individual to differentiate them from other members of a group that
1384    /// share a family name.
1385    #[serde(rename = "givenName")]
1386    #[serde(skip_serializing_if = "Option::is_none")]
1387    pub given_name: Option<String>,
1388
1389    /// Secondary name bestowed upon an individual to differentiate them from others that have
1390    /// the same given name.
1391    #[serde(rename = "middleName")]
1392    #[serde(skip_serializing_if = "Option::is_none")]
1393    pub middle_name: Option<String>,
1394
1395    /// The portion of a name’s full form of address that precedes the name itself.
1396    #[serde(rename = "namePrefix")]
1397    #[serde(skip_serializing_if = "Option::is_none")]
1398    pub name_prefix: Option<String>,
1399
1400    /// The portion of a name’s full form of address that follows the name itself.
1401    #[serde(rename = "nameSuffix")]
1402    #[serde(skip_serializing_if = "Option::is_none")]
1403    pub name_suffix: Option<String>,
1404
1405    /// Name substituted for the purposes of familiarity.
1406    #[serde(rename = "nickname")]
1407    #[serde(skip_serializing_if = "Option::is_none")]
1408    pub nickname: Option<String>,
1409
1410    /// The phonetic representation name components of the receiver.
1411    #[serde(rename = "phoneticRepresentation")]
1412    #[serde(skip_serializing_if = "Option::is_none")]
1413    pub phonetic_representation: Box<Option<PhoneticRepresentation>>,
1414}
1415
1416impl PersonNameComponents {
1417    /// Create a new Instance
1418    pub fn new() -> Self {
1419        Self {
1420            family_name: None,
1421            given_name: None,
1422            middle_name: None,
1423            name_prefix: None,
1424            name_suffix: None,
1425            nickname: None,
1426            phonetic_representation: Box::new(None),
1427        }
1428    }
1429}
1430
1431impl Default for PersonNameComponents {
1432    fn default() -> Self {
1433        Self::new()
1434    }
1435}
1436
1437/// The phonetic representation name components of the receiver.
1438///
1439/// The passenger's name.
1440///
1441/// An object that manages the separate parts of a person's name
1442#[derive(Debug, Clone, Serialize, Deserialize)]
1443pub struct PhoneticRepresentation {
1444    /// Name bestowed upon an individual to denote membership in a group or family.
1445    #[serde(rename = "familyName")]
1446    #[serde(skip_serializing_if = "Option::is_none")]
1447    pub family_name: Option<String>,
1448
1449    /// Name bestowed upon an individual to differentiate them from other members of a group that
1450    /// share a family name.
1451    #[serde(rename = "givenName")]
1452    #[serde(skip_serializing_if = "Option::is_none")]
1453    pub given_name: Option<String>,
1454
1455    /// Secondary name bestowed upon an individual to differentiate them from others that have
1456    /// the same given name.
1457    #[serde(rename = "middleName")]
1458    #[serde(skip_serializing_if = "Option::is_none")]
1459    pub middle_name: Option<String>,
1460
1461    /// The portion of a name’s full form of address that precedes the name itself.
1462    #[serde(rename = "namePrefix")]
1463    #[serde(skip_serializing_if = "Option::is_none")]
1464    pub name_prefix: Option<String>,
1465
1466    /// The portion of a name’s full form of address that follows the name itself.
1467    #[serde(rename = "nameSuffix")]
1468    #[serde(skip_serializing_if = "Option::is_none")]
1469    pub name_suffix: Option<String>,
1470
1471    /// Name substituted for the purposes of familiarity.
1472    #[serde(rename = "nickname")]
1473    #[serde(skip_serializing_if = "Option::is_none")]
1474    pub nickname: Option<String>,
1475
1476    /// The phonetic representation name components of the receiver.
1477    #[serde(rename = "phoneticRepresentation")]
1478    #[serde(skip_serializing_if = "Option::is_none")]
1479    pub phonetic_representation: Box<Option<PhoneticRepresentation>>,
1480}
1481
1482impl PhoneticRepresentation {
1483    /// Create a new Instance
1484    pub fn new() -> Self {
1485        Self {
1486            family_name: None,
1487            given_name: None,
1488            middle_name: None,
1489            name_prefix: None,
1490            name_suffix: None,
1491            nickname: None,
1492            phonetic_representation: Box::new(None),
1493        }
1494    }
1495}
1496
1497impl Default for PhoneticRepresentation {
1498    fn default() -> Self {
1499        Self::new()
1500    }
1501}
1502
1503/// A dictionary with seat information
1504#[derive(Debug, Clone, Serialize, Deserialize)]
1505pub struct Seat {
1506    /// Seat description
1507    #[serde(rename = "seatDescription")]
1508    #[serde(skip_serializing_if = "Option::is_none")]
1509    pub seat_description: Option<String>,
1510
1511    /// Seat identifier
1512    #[serde(rename = "seatIdentifier")]
1513    #[serde(skip_serializing_if = "Option::is_none")]
1514    pub seat_identifier: Option<String>,
1515
1516    /// Seat number
1517    #[serde(rename = "seatNumber")]
1518    #[serde(skip_serializing_if = "Option::is_none")]
1519    pub seat_number: Option<String>,
1520
1521    /// Seat row
1522    #[serde(rename = "seatRow")]
1523    #[serde(skip_serializing_if = "Option::is_none")]
1524    pub seat_row: Option<String>,
1525
1526    /// Seat section
1527    #[serde(rename = "seatSection")]
1528    #[serde(skip_serializing_if = "Option::is_none")]
1529    pub seat_section: Option<String>,
1530
1531    /// Seat type
1532    #[serde(rename = "seatType")]
1533    #[serde(skip_serializing_if = "Option::is_none")]
1534    pub seat_type: Option<String>,
1535}
1536
1537impl Seat {
1538    /// Create a new Instance
1539    pub fn new() -> Self {
1540        Self {
1541            seat_description: None,
1542            seat_identifier: None,
1543            seat_number: None,
1544            seat_row: None,
1545            seat_section: None,
1546            seat_type: None,
1547        }
1548    }
1549}
1550
1551impl Default for Seat {
1552    fn default() -> Self {
1553        Self::new()
1554    }
1555}
1556
1557/// Information specific to a coupon.
1558///
1559/// Information specific to an event ticket.
1560///
1561/// Information specific to a generic pass.
1562///
1563/// Information specific to a store card.
1564///
1565/// Information specific to a boarding pass.
1566///
1567/// Keys that define the structure of the pass.
1568/// These keys are used for all pass styles and partition the fields into the various parts
1569/// of the pass.
1570#[derive(Debug, Clone, Serialize, Deserialize)]
1571pub struct Details {
1572    /// Additional fields to be displayed on the front of the pass.
1573    #[serde(rename = "auxiliaryFields")]
1574    #[serde(skip_serializing_if = "Option::is_none")]
1575    pub auxiliary_fields: Option<Vec<Field>>,
1576
1577    /// Fields to be on the back of the pass.
1578    #[serde(rename = "backFields")]
1579    #[serde(skip_serializing_if = "Option::is_none")]
1580    pub back_fields: Option<Vec<Field>>,
1581
1582    /// Fields to be displayed in the header on the front of the pass. Use header fields
1583    /// sparingly; unlike all other fields, they remain visible when a stack of passes are
1584    /// displayed.
1585    #[serde(rename = "headerFields")]
1586    #[serde(skip_serializing_if = "Option::is_none")]
1587    pub header_fields: Option<Vec<Field>>,
1588
1589    /// Fields to be displayed prominently on the front of the pass.
1590    #[serde(rename = "primaryFields")]
1591    #[serde(skip_serializing_if = "Option::is_none")]
1592    pub primary_fields: Option<Vec<Field>>,
1593
1594    /// Fields to be displayed on the front of the pass.
1595    #[serde(rename = "secondaryFields")]
1596    #[serde(skip_serializing_if = "Option::is_none")]
1597    pub secondary_fields: Option<Vec<Field>>,
1598
1599    /// Type of transit.
1600    #[serde(rename = "transitType")]
1601    #[serde(skip_serializing_if = "Option::is_none")]
1602    pub transit_type: Option<TransitType>,
1603}
1604
1605impl Details {
1606    /// Create a new Instance
1607    pub fn new() -> Self {
1608        Self {
1609            auxiliary_fields: None,
1610            back_fields: None,
1611            header_fields: None,
1612            primary_fields: None,
1613            secondary_fields: None,
1614            transit_type: None,
1615        }
1616    }
1617
1618    /// Type of transit.
1619    pub fn transit_type(&mut self, transit_type: TransitType) {
1620        self.transit_type = Some(transit_type);
1621    }
1622
1623    /// Add additional field to be displayed on the front of the pass.
1624    pub fn add_auxiliary_field(&mut self, field: Field) {
1625        let mut vec = match &self.auxiliary_fields {
1626            Some(vec) => vec.clone(),
1627            None => Vec::new(),
1628        };
1629        vec.push(field);
1630
1631        self.auxiliary_fields = Some(vec);
1632    }
1633
1634    /// Remove additional fields to be displayed on the front of the pass.
1635    pub fn clear_auxiliary_fields(&mut self) {
1636        self.auxiliary_fields = None;
1637    }
1638
1639    /// Add field to be on the back of the pass.
1640    pub fn add_back_field(&mut self, field: Field) {
1641        let mut vec = match &self.back_fields {
1642            Some(vec) => vec.clone(),
1643            None => Vec::new(),
1644        };
1645        vec.push(field);
1646
1647        self.back_fields = Some(vec);
1648    }
1649
1650    /// Remove fields to be on the back of the pass.
1651    pub fn clear_back_fields(&mut self) {
1652        self.back_fields = None;
1653    }
1654
1655    /// Add field to be displayed in the header on the front of the pass. Use header fields
1656    /// sparingly; unlike all other fields, they remain visible when a stack of passes are
1657    /// displayed.
1658    pub fn add_header_field(&mut self, field: Field) {
1659        let mut vec = match &self.header_fields {
1660            Some(vec) => vec.clone(),
1661            None => Vec::new(),
1662        };
1663        vec.push(field);
1664
1665        self.header_fields = Some(vec);
1666    }
1667
1668    /// Remove fields to be displayed in the header on the front of the pass. Use header fields
1669    /// sparingly; unlike all other fields, they remain visible when a stack of passes are
1670    /// displayed.
1671    pub fn clear_header_fields(&mut self) {
1672        self.header_fields = None;
1673    }
1674
1675    /// Add field to be displayed prominently on the front of the pass.    
1676    pub fn add_primary_field(&mut self, field: Field) {
1677        let mut vec = match &self.primary_fields {
1678            Some(vec) => vec.clone(),
1679            None => Vec::new(),
1680        };
1681        vec.push(field);
1682
1683        self.primary_fields = Some(vec);
1684    }
1685
1686    /// Remove fields to be displayed prominently on the front of the pass.
1687    pub fn clear_primary_fields(&mut self) {
1688        self.primary_fields = None;
1689    }
1690
1691    /// Add field to be displayed on the front of the pass.
1692    pub fn add_secondary_field(&mut self, field: Field) {
1693        let mut vec = match &self.secondary_fields {
1694            Some(vec) => vec.clone(),
1695            None => Vec::new(),
1696        };
1697        vec.push(field);
1698
1699        self.secondary_fields = Some(vec);
1700    }
1701
1702    /// Remove fields to be displayed on the front of the pass.
1703    pub fn clear_secondary_fields(&mut self) {
1704        self.secondary_fields = None;
1705    }
1706}
1707
1708impl Default for Details {
1709    fn default() -> Self {
1710        Self::new()
1711    }
1712}
1713
1714/// Information used for Value Added Service Protocol transactions.
1715/// Available in iOS 9.0.
1716///
1717/// Information about the NFC payload passed to an Apple Pay terminal.
1718#[derive(Debug, Clone, Serialize, Deserialize)]
1719pub struct Nfc {
1720    /// The public encryption key used by the Value Added Services protocol. Use a Base64 encoded
1721    /// X.509 SubjectPublicKeyInfo structure containing a ECDH public key for group P256.
1722    #[serde(rename = "encryptionPublicKey")]
1723    #[serde(skip_serializing_if = "Option::is_none")]
1724    pub encryption_public_key: Option<String>,
1725
1726    /// The payload to be transmitted to the Apple Pay terminal. Must be 64 bytes or less.
1727    /// Messages longer than 64 bytes are truncated by the system.
1728    #[serde(rename = "message")]
1729    pub message: String,
1730}
1731
1732impl Nfc {
1733    /// Create a new Instance
1734    pub fn new(message: &str) -> Self {
1735        Self {
1736            encryption_public_key: None,
1737            message: message.into(),
1738        }
1739    }
1740}
1741
1742/// Represents a Double or String value
1743#[derive(Debug, Clone, Serialize, Deserialize)]
1744#[serde(untagged)]
1745pub enum ValueUnion {
1746    /// Represents a Double value
1747    Double(f64),
1748
1749    /// Represents a String value
1750    String(String),
1751}
1752
1753/// Barcode format. PKBarcodeFormatCode128 may only be used for dictionaries in the barcodes
1754/// array.
1755#[derive(Debug, Clone, Serialize, Deserialize)]
1756pub enum BarcodeFormat {
1757    /// Barcode fromat `PKBarcodeFormatAztec`
1758    #[serde(rename = "PKBarcodeFormatAztec")]
1759    PkBarcodeFormatAztec,
1760
1761    /// Barcode fromat `PKBarcodeFormatCode128`
1762    #[serde(rename = "PKBarcodeFormatCode128")]
1763    PkBarcodeFormatCode128,
1764
1765    /// Barcode fromat `PKBarcodeFormatPDF417`
1766    #[serde(rename = "PKBarcodeFormatPDF417")]
1767    PkBarcodeFormatPdf417,
1768
1769    /// Barcode fromat `PKBarcodeFormatQR`
1770    #[serde(rename = "PKBarcodeFormatQR")]
1771    PkBarcodeFormatQr,
1772}
1773
1774/// Style of date to display.
1775///
1776/// Style of time to display.
1777#[derive(Debug, Clone, Serialize, Deserialize)]
1778pub enum EStyle {
1779    /// date/time style `PKDateStyleFull`
1780    #[serde(rename = "PKDateStyleFull")]
1781    PkDateStyleFull,
1782
1783    /// date/time style `PKDateStyleLong`
1784    #[serde(rename = "PKDateStyleLong")]
1785    PkDateStyleLong,
1786
1787    /// date/time style `PKDateStyleMedium`
1788    #[serde(rename = "PKDateStyleMedium")]
1789    PkDateStyleMedium,
1790
1791    /// date/time style `PKDateStyleNone`
1792    #[serde(rename = "PKDateStyleNone")]
1793    PkDateStyleNone,
1794
1795    /// date/time style `PKDateStyleShort`
1796    #[serde(rename = "PKDateStyleShort")]
1797    PkDateStyleShort,
1798}
1799
1800/// Style of number to display. Number styles have the same meaning as the Cocoa number
1801/// formatter styles with corresponding names. See
1802/// https://developer.apple.com/documentation/foundation/nsnumberformatterstyle
1803#[derive(Debug, Clone, Serialize, Deserialize)]
1804pub enum NumberStyle {
1805    /// Number style `PKNumberStyleDecimal`
1806    #[serde(rename = "PKNumberStyleDecimal")]
1807    PkNumberStyleDecimal,
1808
1809    /// Number style `PKNumberStylePercent`
1810    #[serde(rename = "PKNumberStylePercent")]
1811    PkNumberStylePercent,
1812
1813    /// Number style `PKNumberStyleScientific`
1814    #[serde(rename = "PKNumberStyleScientific")]
1815    PkNumberStyleScientific,
1816
1817    /// Number style `PKNumberStyleSpellOut`
1818    #[serde(rename = "PKNumberStyleSpellOut")]
1819    PkNumberStyleSpellOut,
1820}
1821
1822/// The event type.
1823#[derive(Debug, Clone, Serialize, Deserialize)]
1824pub enum EventType {
1825    /// Event type `PKEventTypeConference`
1826    #[serde(rename = "PKEventTypeConference")]
1827    PkEventTypeConference,
1828
1829    /// Event type `PKEventTypeConvention`
1830    #[serde(rename = "PKEventTypeConvention")]
1831    PkEventTypeConvention,
1832
1833    /// Event type `PKEventTypeGeneric`
1834    #[serde(rename = "PKEventTypeGeneric")]
1835    PkEventTypeGeneric,
1836
1837    /// Event type `PKEventTypeLivePerformance`
1838    #[serde(rename = "PKEventTypeLivePerformance")]
1839    PkEventTypeLivePerformance,
1840
1841    /// Event type `PKEventTypeMovie`
1842    #[serde(rename = "PKEventTypeMovie")]
1843    PkEventTypeMovie,
1844
1845    /// Event type `PKEventTypeSocialGathering`
1846    #[serde(rename = "PKEventTypeSocialGathering")]
1847    PkEventTypeSocialGathering,
1848
1849    /// Event type `PKEventTypeSports`
1850    #[serde(rename = "PKEventTypeSports")]
1851    PkEventTypeSports,
1852
1853    /// Event type `PKEventTypeWorkshop`
1854    #[serde(rename = "PKEventTypeWorkshop")]
1855    PkEventTypeWorkshop,
1856}
1857
1858/// Alignment for the field’s contents.
1859/// This key is not allowed for primary fields or back fields.
1860#[derive(Debug, Clone, Serialize, Deserialize)]
1861pub enum TextAlignment {
1862    /// Alignment `PKTextAlignmentCenter`
1863    #[serde(rename = "PKTextAlignmentCenter")]
1864    PkTextAlignmentCenter,
1865
1866    /// Alignment `PKTextAlignmentLeft`
1867    #[serde(rename = "PKTextAlignmentLeft")]
1868    PkTextAlignmentLeft,
1869
1870    /// Alignment `PKTextAlignmentNatural`
1871    #[serde(rename = "PKTextAlignmentNatural")]
1872    PkTextAlignmentNatural,
1873
1874    /// Alignment `PKTextAlignmentRight`
1875    #[serde(rename = "PKTextAlignmentRight")]
1876    PkTextAlignmentRight,
1877}
1878
1879/// Type of transit.
1880#[derive(Debug, Clone, Serialize, Deserialize)]
1881pub enum TransitType {
1882    /// Transit type `PKTransitTypeAir`
1883    #[serde(rename = "PKTransitTypeAir")]
1884    PkTransitTypeAir,
1885
1886    /// Transit type `PKTransitTypeBoat`
1887    #[serde(rename = "PKTransitTypeBoat")]
1888    PkTransitTypeBoat,
1889
1890    /// Transit type `PKTransitTypeBus`
1891    #[serde(rename = "PKTransitTypeBus")]
1892    PkTransitTypeBus,
1893
1894    /// Transit type `PKTransitTypeGeneric`
1895    #[serde(rename = "PKTransitTypeGeneric")]
1896    PkTransitTypeGeneric,
1897
1898    /// Transit type `PKTransitTypeTrain`
1899    #[serde(rename = "PKTransitTypeTrain")]
1900    PkTransitTypeTrain,
1901}