carpool-service/servers/ocss-api/book.go

35 lines
923 B
Go
Raw Normal View History

2023-03-27 18:54:56 +00:00
package ocssapi
import (
"context"
"git.coopgo.io/coopgo-platform/carpool-service/interoperability/ocss"
2023-03-30 06:44:58 +00:00
"github.com/rs/zerolog/log"
2023-03-27 18:54:56 +00:00
)
func (s *OCSSApiService) PostBookings(ctx context.Context, booking ocss.Booking) (*ocss.Booking, error) {
2023-03-30 06:44:58 +00:00
result, err := s.Handler.Book(booking)
if err != nil {
log.Error().Err(err).Msg("issue in booking")
return nil, err
}
return &result.Booking, nil
2023-03-27 18:54:56 +00:00
}
2023-03-29 22:45:18 +00:00
func (s *OCSSApiService) PatchBookings(ctx context.Context, bookingId string, status ocss.BookingStatus, message *string) error {
err := s.Handler.UpdateBookingStatus(bookingId, status)
if err != nil {
return err
}
return nil
2023-03-27 18:54:56 +00:00
}
2023-03-29 22:45:18 +00:00
func (s *OCSSApiService) GetBookings(ctx context.Context, bookingId string) (*ocss.Booking, error) {
2023-03-30 06:44:58 +00:00
result, err := s.Handler.GetBooking(bookingId)
if err != nil {
log.Error().Err(err).Msg("issue retrieving booking in handler")
return nil, err
}
return &result.Booking, nil
2023-03-27 18:54:56 +00:00
}