94 lines
2.8 KiB
Go
94 lines
2.8 KiB
Go
/*
|
|
* Solidarity Mobility API
|
|
*
|
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
*
|
|
* API version: 1.0.0
|
|
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
|
*/
|
|
|
|
package openapi
|
|
|
|
type Booking struct {
|
|
|
|
// Booking id is common between both operators, and must be created as a [UUID](https://datatracker.ietf.org/doc/html/rfc4122) by whoever initiates the booking. Usage of a [4 UUID](https://datatracker.ietf.org/doc/html/rfc4122#section-4.4) generation algorithm is advised.
|
|
Id string `json:"id"`
|
|
|
|
Driver User `json:"driver"`
|
|
|
|
Passenger User `json:"passenger"`
|
|
|
|
// Passenger pickup datetime as a UNIX UTC timestamp in seconds.
|
|
PassengerPickupDate int32 `json:"passengerPickupDate"`
|
|
|
|
// Latitude of the passenger pick-up point.
|
|
PassengerPickupLat float64 `json:"passengerPickupLat"`
|
|
|
|
// Longitude of the passenger pick-up point.
|
|
PassengerPickupLng float64 `json:"passengerPickupLng"`
|
|
|
|
// Latitude of the passenger drop-off point.
|
|
PassengerDropLat float64 `json:"passengerDropLat"`
|
|
|
|
// Longitude of the passenger drop-off point.
|
|
PassengerDropLng float64 `json:"passengerDropLng"`
|
|
|
|
// String representing the pickup-up address.
|
|
PassengerPickupAddress string `json:"passengerPickupAddress,omitempty"`
|
|
|
|
// String representing the drop-off address.
|
|
PassengerDropAddress string `json:"passengerDropAddress,omitempty"`
|
|
|
|
Status BookingStatus `json:"status"`
|
|
|
|
// Carpooling duration in seconds.
|
|
Duration int32 `json:"duration,omitempty"`
|
|
|
|
// Carpooling distance in meters.
|
|
Distance int32 `json:"distance,omitempty"`
|
|
|
|
Price Price `json:"price"`
|
|
|
|
Car Car `json:"car,omitempty"`
|
|
}
|
|
|
|
// AssertBookingRequired checks if the required fields are not zero-ed
|
|
func AssertBookingRequired(obj Booking) error {
|
|
elements := map[string]interface{}{
|
|
"id": obj.Id,
|
|
"driver": obj.Driver,
|
|
"passenger": obj.Passenger,
|
|
"passengerPickupDate": obj.PassengerPickupDate,
|
|
"passengerPickupLat": obj.PassengerPickupLat,
|
|
"passengerPickupLng": obj.PassengerPickupLng,
|
|
"passengerDropLat": obj.PassengerDropLat,
|
|
"passengerDropLng": obj.PassengerDropLng,
|
|
"status": obj.Status,
|
|
"price": obj.Price,
|
|
}
|
|
for name, el := range elements {
|
|
if isZero := IsZeroValue(el); isZero {
|
|
return &RequiredError{Field: name}
|
|
}
|
|
}
|
|
|
|
if err := AssertUserRequired(obj.Driver); err != nil {
|
|
return err
|
|
}
|
|
if err := AssertUserRequired(obj.Passenger); err != nil {
|
|
return err
|
|
}
|
|
if err := AssertPriceRequired(obj.Price); err != nil {
|
|
return err
|
|
}
|
|
if err := AssertCarRequired(obj.Car); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// AssertBookingConstraints checks if the values respects the defined constraints
|
|
func AssertBookingConstraints(obj Booking) error {
|
|
return nil
|
|
}
|