osdm_sys/models/trip_allocation_constraint.rs
1/*
2 * UIC 90918-10 - OSDM
3 *
4 * Specifications for the OSDM API standard. The OSDM specification supports two modes of operation: Retailer Mode and Distributor Mode. The API works identically in both modes, except that in distributor mode the API also returns fare information. The following resources are key to get started: - [Processes](https://osdm.io/spec/processes/) - [Models](https://osdm.io/spec/models/) - [Getting started](https://osdm.io/spec/getting-started/)
5 *
6 * The version of the OpenAPI document: 3.7.0
7 * Contact: osdm@uic.org
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// TripAllocationConstraint : constraint on the use of a multiple trip ticket
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
17pub struct TripAllocationConstraint {
18 /// Values from the [Trip Allocation Unit Code List](https://osdm.io/spec/catalog-of-code-lists/#TripAllocationUnit) Unit to allocate trips in a multi-trip fare. Trips can be allocated per day (e.g. Eurail) or per duration (e.g. multiples of a duration unit to cover the trip) or as single trips (e.g. carnet)) Known Values: - NONE: Individual trips don't need to be allocated. - TRIP: allocation per individual trip. - DAY: The allocation is per travel day. - DURATION: the allocation is per duration.
19 #[serde(rename = "allocationUnit")]
20 pub allocation_unit: String,
21 /// maximum number of allowed units to be allocated
22 #[serde(rename = "maxUnits", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
23 pub max_units: Option<Option<i32>>,
24 /// multiples of this duration can be allocated
25 #[serde(rename = "durationUnit", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
26 pub duration_unit: Option<Option<String>>,
27 /// one of the listed processes is required for the allocation of a single trip
28 #[serde(rename = "requiredProcesses")]
29 pub required_processes: Vec<String>,
30}
31
32impl TripAllocationConstraint {
33 /// constraint on the use of a multiple trip ticket
34 pub fn new(allocation_unit: String, required_processes: Vec<String>) -> TripAllocationConstraint {
35 TripAllocationConstraint {
36 allocation_unit,
37 max_units: None,
38 duration_unit: None,
39 required_processes,
40 }
41 }
42}
43