2023-12-08 06:35:04 +00:00
|
|
|
package grpcserver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-10-31 19:32:54 +00:00
|
|
|
|
2023-12-08 06:35:04 +00:00
|
|
|
"git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/proto"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
)
|
|
|
|
|
2024-10-31 19:32:54 +00:00
|
|
|
func (s *SolidarityService) SetDriverRegularAvailabilities(ctx context.Context,
|
|
|
|
req *proto.DriverRegularAvailabilities) (resp *proto.DriverAvailabilitiesResponse, err error) {
|
2023-12-08 06:35:04 +00:00
|
|
|
log.Info().
|
|
|
|
Str("Driver ID", req.DriverRequest.Driver.Id).
|
|
|
|
Msg("SetDriverRegularAvailabilities")
|
|
|
|
resp, err = s.SolidarityClient.SetDriverRegularAvailabilities(ctx, req)
|
2024-10-31 19:32:54 +00:00
|
|
|
|
2023-12-08 06:35:04 +00:00
|
|
|
return resp, err
|
|
|
|
}
|
|
|
|
|
2024-10-31 19:32:54 +00:00
|
|
|
func (s *SolidarityService) SetDriverPunctualAvailabilities(ctx context.Context,
|
|
|
|
req *proto.DriverPunctualAvailabilities) (resp *proto.DriverAvailabilitiesResponse, err error) {
|
2023-12-08 06:35:04 +00:00
|
|
|
log.Info().
|
|
|
|
Str("Driver ID", req.DriverRequest.Driver.Id).
|
|
|
|
Msg("SetDriverRegularAvailabilities")
|
|
|
|
resp, err = s.SolidarityClient.SetDriverPunctualAvailabilities(ctx, req)
|
2024-10-31 19:32:54 +00:00
|
|
|
|
2023-12-08 06:35:04 +00:00
|
|
|
return resp, err
|
|
|
|
}
|
|
|
|
|
2024-10-31 19:32:54 +00:00
|
|
|
func (s *SolidarityService) CreateBooking(ctx context.Context,
|
|
|
|
req *proto.CreateBookingRequest) (resp *proto.CreateBookingResponse, err error) {
|
|
|
|
|
2023-12-08 06:35:04 +00:00
|
|
|
log.Info().
|
|
|
|
Str("Booking ID", req.Booking.Id).
|
|
|
|
Msg("CreateBooking")
|
2024-10-31 19:32:54 +00:00
|
|
|
|
|
|
|
if resp, err = s.SolidarityClient.CreateBooking(ctx, req); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = s.Handler.SendNotification(req.Booking.DriverId,
|
|
|
|
"Silvermobi", "Vous avez reçu une demande de trajet. "+
|
|
|
|
"\n Pour plus de détails, veuillez consulter"+
|
|
|
|
" l'interface \"Mes Trajets\" dans l'application SilverMobi."); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = s.Handler.SendEmail(req.Booking.DriverId, "Silvermobi",
|
|
|
|
"Vous avez reçu une demande de trajet. \n Pour plus de détails, "+
|
|
|
|
"veuillez consulter l'interface \"Mes Trajets\" dans l'application SilverMobi."); err != nil {
|
|
|
|
return nil, err
|
2023-12-08 06:35:04 +00:00
|
|
|
}
|
2024-10-31 19:32:54 +00:00
|
|
|
|
2023-12-08 06:35:04 +00:00
|
|
|
return resp, err
|
|
|
|
}
|
|
|
|
|
2024-10-31 19:32:54 +00:00
|
|
|
func (s *SolidarityService) UpdateBooking(ctx context.Context,
|
|
|
|
req *proto.UpdateBookingRequest) (resp *proto.UpdateBookingResponse, err error) {
|
|
|
|
|
2023-12-08 06:35:04 +00:00
|
|
|
log.Info().
|
|
|
|
Str("Booking ID", req.BookingId).
|
|
|
|
Msg("UpdateBooking")
|
2024-10-30 09:16:37 +00:00
|
|
|
resp, err = s.SolidarityClient.UpdateBooking(ctx, req)
|
2024-10-31 19:32:54 +00:00
|
|
|
|
2023-12-08 06:35:04 +00:00
|
|
|
return resp, err
|
|
|
|
}
|
|
|
|
|
2024-10-31 19:32:54 +00:00
|
|
|
func (s *SolidarityService) GetBooking(ctx context.Context,
|
|
|
|
req *proto.GetBookingRequest) (resp *proto.GetBookingResponse, err error) {
|
2023-12-08 06:35:04 +00:00
|
|
|
log.Info().
|
|
|
|
Str("Booking ID", req.BookingId).
|
|
|
|
Msg("GetBooking")
|
2024-10-30 09:16:37 +00:00
|
|
|
resp, err = s.SolidarityClient.GetBooking(ctx, req)
|
2024-10-31 19:32:54 +00:00
|
|
|
|
2023-12-08 06:35:04 +00:00
|
|
|
return resp, err
|
|
|
|
}
|
|
|
|
|
2024-10-31 19:32:54 +00:00
|
|
|
func (s *SolidarityService) GetBookingsByStatus(ctx context.Context,
|
|
|
|
req *proto.GetBookingsByStatusRequest) (resp *proto.GetBookingsByStatusResponse, err error) {
|
|
|
|
|
2023-12-08 06:35:04 +00:00
|
|
|
log.Info().
|
|
|
|
Str("User ID", req.UserId).
|
|
|
|
Msg("GetBookingByStatus")
|
|
|
|
resp, err = s.SolidarityClient.GetBookingsByStatus(ctx, req)
|
2024-10-31 19:32:54 +00:00
|
|
|
|
2023-12-08 06:35:04 +00:00
|
|
|
return resp, err
|
|
|
|
}
|
|
|
|
|
2024-10-31 19:32:54 +00:00
|
|
|
func (s *SolidarityService) DriverJourneys(ctx context.Context,
|
|
|
|
req *proto.DriverJourneysRequest) (resp *proto.DriverJourneysResponse, err error) {
|
2023-12-08 06:35:04 +00:00
|
|
|
log.Info().
|
|
|
|
Str("Address", req.Departure.Address).
|
|
|
|
Msg("DriverJourneys")
|
|
|
|
resp, err = s.SolidarityClient.DriverJourneys(ctx, req)
|
2024-10-31 19:32:54 +00:00
|
|
|
|
2023-12-08 06:35:04 +00:00
|
|
|
return resp, err
|
|
|
|
}
|
|
|
|
|
2024-10-31 19:32:54 +00:00
|
|
|
func (s *SolidarityService) SetPassengerTrip(ctx context.Context,
|
|
|
|
req *proto.PassengerTripRequest) (resp *proto.PassengerTripResponse, err error) {
|
2023-12-08 06:35:04 +00:00
|
|
|
log.Info().
|
|
|
|
Str("Passenger ID", req.Passenger.Id).
|
|
|
|
Msg("SetPassengerTrip")
|
|
|
|
resp, err = s.SolidarityClient.SetPassengerTrip(ctx, req)
|
2024-10-31 19:32:54 +00:00
|
|
|
|
2023-12-08 06:35:04 +00:00
|
|
|
return resp, err
|
|
|
|
}
|