Add PostgreSQL database option and more booking flow functionalities
This commit is contained in:
@@ -2,7 +2,6 @@ package ocssapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"git.coopgo.io/coopgo-platform/carpool-service/interoperability/ocss"
|
||||
"github.com/rs/zerolog/log"
|
||||
@@ -15,10 +14,14 @@ func (s *OCSSApiService) PostBookings(ctx context.Context, booking ocss.Booking)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result.BookingDefinition, nil
|
||||
return &result.Booking, nil
|
||||
}
|
||||
func (s *OCSSApiService) PatchBookings(ctx context.Context, bookingId string, status ocss.BookingStatus, message *string) error {
|
||||
return errors.New("booking not found")
|
||||
err := s.Handler.UpdateBookingStatus(bookingId, status)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *OCSSApiService) GetBookings(ctx context.Context, bookingId string) (*ocss.Booking, error) {
|
||||
result, err := s.Handler.GetBooking(bookingId)
|
||||
@@ -27,5 +30,5 @@ func (s *OCSSApiService) GetBookings(ctx context.Context, bookingId string) (*oc
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result.BookingDefinition, nil
|
||||
return &result.Booking, nil
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func (s *OCSSApiService) GetDriverJourneys(ctx context.Context, departureLat flo
|
||||
driverDepartureLng := j.Route.Features[0].Point().Lon()
|
||||
driverArrivalLat := j.Route.Features[1].Point().Lat()
|
||||
driverArrivalLng := j.Route.Features[1].Point().Lon()
|
||||
driverDepartureDate := ocss.JSONTime(j.DepartureDate)
|
||||
driverDepartureDate := ocss.OCSSTime(j.DepartureDate)
|
||||
duration := time.Duration(0)
|
||||
var distance *int64
|
||||
if len(j.Itinerary.Legs) > 2 {
|
||||
@@ -53,7 +53,7 @@ func (s *OCSSApiService) GetDriverJourneys(ctx context.Context, departureLat flo
|
||||
Alias: usermap["alias"].(string),
|
||||
},
|
||||
Trip: ocss.Trip{
|
||||
Operator: "ridygo.fr",
|
||||
Operator: s.Handler.InternalOperatorID,
|
||||
PassengerPickupLat: departureLat,
|
||||
PassengerPickupLng: departureLng,
|
||||
PassengerDropLat: arrivalLat,
|
||||
@@ -68,7 +68,7 @@ func (s *OCSSApiService) GetDriverJourneys(ctx context.Context, departureLat flo
|
||||
},
|
||||
JourneySchedule: ocss.JourneySchedule{
|
||||
ID: &journeyId,
|
||||
PassengerPickupDate: ocss.JSONTime(j.DepartureDate.Add(j.Itinerary.Legs[0].Duration)),
|
||||
PassengerPickupDate: ocss.OCSSTime(j.DepartureDate.Add(j.Itinerary.Legs[0].Duration)),
|
||||
DriverDepartureDate: &driverDepartureDate,
|
||||
Type: ocss.Planned,
|
||||
},
|
||||
@@ -109,8 +109,8 @@ func (s *OCSSApiService) GetPassengerJourneys(ctx context.Context, departureLat
|
||||
passengerDepartureLng := j.Route.Features[0].Point().Lon()
|
||||
passengerArrivalLat := j.Route.Features[1].Point().Lat()
|
||||
passengerArrivalLng := j.Route.Features[1].Point().Lon()
|
||||
passengerDepartureDate := ocss.JSONTime(j.DepartureDate)
|
||||
driverDepartureDate := ocss.JSONTime(j.DepartureDate.Add(-j.Itinerary.Legs[0].Duration))
|
||||
passengerDepartureDate := ocss.OCSSTime(j.DepartureDate)
|
||||
driverDepartureDate := ocss.OCSSTime(j.DepartureDate.Add(-j.Itinerary.Legs[0].Duration))
|
||||
duration := time.Duration(0)
|
||||
var distance *int64
|
||||
log.Debug().Any("itinerary", j.Itinerary).Msg("debug itinerary")
|
||||
@@ -128,7 +128,7 @@ func (s *OCSSApiService) GetPassengerJourneys(ctx context.Context, departureLat
|
||||
Alias: usermap["alias"].(string),
|
||||
},
|
||||
Trip: ocss.Trip{
|
||||
Operator: "ridygo.fr",
|
||||
Operator: s.Handler.InternalOperatorID,
|
||||
PassengerPickupLat: passengerDepartureLat,
|
||||
PassengerPickupLng: passengerDepartureLng,
|
||||
PassengerDropLat: passengerArrivalLat,
|
||||
|
||||
Reference in New Issue
Block a user