new grpc functions
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 34s

This commit is contained in:
2025-06-16 13:01:16 +02:00
parent 2f0a45ced0
commit d71da5accd
12 changed files with 472 additions and 220 deletions

View File

@@ -9,7 +9,7 @@ import (
"github.com/rs/zerolog/log"
)
func (h Handler) BookDriverJourney(passengerid string, driverid string, journeyid string, returnWaitingDuration time.Duration, data map[string]any) (*types.Booking, error) {
func (h Handler) BookDriverJourney(passengerid string, driverid string, journeyid string, returnWaitingDuration time.Duration, priceAmount float64, priceCurrency string, data map[string]any) (*types.Booking, error) {
journey, err := h.Storage.GetDriverJourney(journeyid)
if err != nil {
log.Error().Err(err).Msg("could not find driver journey")
@@ -20,6 +20,11 @@ func (h Handler) BookDriverJourney(passengerid string, driverid string, journeyi
return nil, errors.New("not authorized : journey id driver and driverid mismatch")
}
journey.Price.Amount = priceAmount
journey.Price.Currency = priceCurrency
log.Debug().Float64("Price", priceAmount).Any("journey", journey.Price).Msg("store booking")
booking := types.Booking{
Id: uuid.NewString(),
GroupId: uuid.NewString(),
@@ -72,8 +77,16 @@ func (h Handler) GetBooking(id string) (*types.Booking, error) {
return booking, nil
}
func (h Handler) UpdateBookingStatus(bookingid string, newStatus string) error {
if err := h.Storage.UpdateBookingStatus(bookingid, newStatus); err != nil {
func (h Handler) UpdateBooking(booking types.Booking) error {
if err := h.Storage.UpdateBooking(booking); err != nil {
log.Error().Err(err).Msg("could not update booking")
return err
}
return nil
}
func (h Handler) UpdateBookingStatus(bookingid string, newStatus string, reason string) error {
if err := h.Storage.UpdateBookingStatus(bookingid, newStatus, reason); err != nil {
log.Error().Err(err).Msg("could not update booking")
return err
}