-
Notifications
You must be signed in to change notification settings - Fork 0
/
v3_run.go
123 lines (93 loc) · 3.1 KB
/
v3_run.go
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
)
// V3Run v3 run
// swagger:model V3.Run
type V3Run struct {
// Name of destination of run
DestinationName string `json:"destination_name,omitempty"`
// Direction of travel identifier
DirectionID int32 `json:"direction_id,omitempty"`
// The number of remaining skipped/express stations for the run/service from a stop
ExpressStopCount int32 `json:"express_stop_count,omitempty"`
// stop_id of final stop of run
FinalStopID int32 `json:"final_stop_id,omitempty"`
// Route identifier
RouteID int32 `json:"route_id,omitempty"`
// Transport mode identifier
RouteType int32 `json:"route_type,omitempty"`
// Trip/service run identifier
RunID int32 `json:"run_id,omitempty"`
// Chronological sequence of the trip/service run on the route in direction. Order ascendingly by this field to get chronological order (earliest first) of runs with the same route_id and direction_id.
RunSequence int32 `json:"run_sequence,omitempty"`
// Status of metropolitan train run; returns "scheduled" for other modes
Status string `json:"status,omitempty"`
// Descriptor of the trip/service run. Only available for some runs. May be null.
VehicleDescriptor *V3VehicleDescriptor `json:"vehicle_descriptor,omitempty"`
// Position of the trip/service run. Only available for some bus runs. May be null.
VehiclePosition *V3VehiclePosition `json:"vehicle_position,omitempty"`
}
// Validate validates this v3 run
func (m *V3Run) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateVehicleDescriptor(formats); err != nil {
res = append(res, err)
}
if err := m.validateVehiclePosition(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V3Run) validateVehicleDescriptor(formats strfmt.Registry) error {
if swag.IsZero(m.VehicleDescriptor) { // not required
return nil
}
if m.VehicleDescriptor != nil {
if err := m.VehicleDescriptor.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("vehicle_descriptor")
}
return err
}
}
return nil
}
func (m *V3Run) validateVehiclePosition(formats strfmt.Registry) error {
if swag.IsZero(m.VehiclePosition) { // not required
return nil
}
if m.VehiclePosition != nil {
if err := m.VehiclePosition.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("vehicle_position")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *V3Run) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V3Run) UnmarshalBinary(b []byte) error {
var res V3Run
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}