Add PostgreSQL database option and more booking flow functionalities
This commit is contained in:
105
interoperability/ocss/journeys_passenger_functions.go
Normal file
105
interoperability/ocss/journeys_passenger_functions.go
Normal file
@@ -0,0 +1,105 @@
|
||||
package ocss
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
geojson "github.com/paulmach/orb/geojson"
|
||||
)
|
||||
|
||||
func NewPassengerJourney(
|
||||
id string,
|
||||
operator string,
|
||||
driver User,
|
||||
passengerPickup geojson.Feature,
|
||||
passengerDrop geojson.Feature,
|
||||
duration time.Duration,
|
||||
passengerPickupDate time.Time,
|
||||
journeyType JourneyScheduleType,
|
||||
) *PassengerJourney {
|
||||
var pickupAddress *string
|
||||
if addr := passengerPickup.Properties.MustString("label", ""); addr != "" {
|
||||
pickupAddress = &addr
|
||||
}
|
||||
var dropAddress *string
|
||||
if addr := passengerDrop.Properties.MustString("label", ""); addr != "" {
|
||||
dropAddress = &addr
|
||||
}
|
||||
|
||||
return &PassengerJourney{
|
||||
PassengerTrip: PassengerTrip{
|
||||
Passenger: driver,
|
||||
Trip: Trip{
|
||||
Operator: operator,
|
||||
PassengerPickupLat: passengerPickup.Point().Lat(),
|
||||
PassengerPickupLng: passengerPickup.Point().Lon(),
|
||||
PassengerPickupAddress: pickupAddress,
|
||||
PassengerDropLat: passengerDrop.Point().Lat(),
|
||||
PassengerDropLng: passengerDrop.Point().Lon(),
|
||||
PassengerDropAddress: dropAddress,
|
||||
Duration: duration,
|
||||
},
|
||||
},
|
||||
JourneySchedule: JourneySchedule{
|
||||
ID: &id,
|
||||
PassengerPickupDate: OCSSTime(passengerPickupDate),
|
||||
Type: journeyType,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (j *PassengerJourney) AddDriverDeparture(location geojson.Feature) *PassengerJourney {
|
||||
lat := location.Point().Lat()
|
||||
lon := location.Point().Lon()
|
||||
|
||||
j.DriverDepartureLat = &lat
|
||||
j.DriverDepartureLng = &lon
|
||||
if addr := location.Properties.MustString("label", ""); addr != "" {
|
||||
j.DriverDepartureAddress = &addr
|
||||
}
|
||||
|
||||
return j
|
||||
}
|
||||
|
||||
func (j *PassengerJourney) AddDriverArrival(location geojson.Feature) *PassengerJourney {
|
||||
lat := location.Point().Lat()
|
||||
lon := location.Point().Lon()
|
||||
|
||||
j.DriverArrivalLat = &lat
|
||||
j.DriverArrivalLng = &lon
|
||||
if addr := location.Properties.MustString("label", ""); addr != "" {
|
||||
j.DriverArrivalAddress = &addr
|
||||
}
|
||||
|
||||
return j
|
||||
}
|
||||
|
||||
func (j *PassengerJourney) AddDistance(distance int64) *PassengerJourney {
|
||||
j.Distance = &distance
|
||||
return j
|
||||
}
|
||||
|
||||
func (j *PassengerJourney) AddJourneyPolyline(polyline string) *PassengerJourney {
|
||||
j.JourneyPolyline = &polyline
|
||||
return j
|
||||
}
|
||||
|
||||
func (j *PassengerJourney) AddPreferences(preferences Preferences) *PassengerJourney {
|
||||
j.Preferences = &preferences
|
||||
return j
|
||||
}
|
||||
|
||||
func (j *PassengerJourney) AddAvailableSeats(seats int64) *PassengerJourney {
|
||||
j.RequestedSteats = &seats
|
||||
return j
|
||||
}
|
||||
|
||||
func (j *PassengerJourney) AddDriverDepartureDate(date time.Time) *PassengerJourney {
|
||||
d := OCSSTime(date)
|
||||
j.DriverDepartureDate = &d
|
||||
return j
|
||||
}
|
||||
|
||||
func (j *PassengerJourney) AddWebUrl(url string) *PassengerJourney {
|
||||
j.WebUrl = &url
|
||||
return j
|
||||
}
|
||||
Reference in New Issue
Block a user