silvermobi/servers/grpcapi/server/solidarity-service.go

78 lines
3.1 KiB
Go
Raw Normal View History

2023-12-08 06:35:04 +00:00
package grpcserver
import (
"context"
"fmt"
"git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/proto"
"github.com/rs/zerolog/log"
)
func (s *SolidarityService) SetDriverRegularAvailabilities(ctx context.Context, req *proto.DriverRegularAvailabilities) (resp *proto.DriverAvailabilitiesResponse, err error) {
log.Info().
Str("Driver ID", req.DriverRequest.Driver.Id).
Msg("SetDriverRegularAvailabilities")
resp, err = s.SolidarityClient.SetDriverRegularAvailabilities(ctx, req)
return resp, err
}
func (s *SolidarityService) SetDriverPunctualAvailabilities(ctx context.Context, req *proto.DriverPunctualAvailabilities) (resp *proto.DriverAvailabilitiesResponse, err error) {
log.Info().
Str("Driver ID", req.DriverRequest.Driver.Id).
Msg("SetDriverRegularAvailabilities")
resp, err = s.SolidarityClient.SetDriverPunctualAvailabilities(ctx, req)
return resp, err
}
2024-09-26 11:13:48 +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-09-26 11:13:48 +00:00
resp, err = s.SolidarityClient.CreateBooking(ctx, req)
2023-12-08 06:35:04 +00:00
if err == nil {
_ = 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 = 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.")
fmt.Println(err)
}
return resp, err
}
2024-09-26 11:13:48 +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-09-26 11:13:48 +00:00
resp, err = s.SolidarityClient.UpdateBooking(ctx, req)
2023-12-08 06:35:04 +00:00
return resp, err
}
2024-09-26 11:13:48 +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-09-26 11:13:48 +00:00
resp, err = s.SolidarityClient.GetBooking(ctx, req)
2023-12-08 06:35:04 +00:00
return resp, err
}
func (s *SolidarityService) GetBookingsByStatus(ctx context.Context, req *proto.GetBookingsByStatusRequest) (resp *proto.GetBookingsByStatusResponse, err error) {
log.Info().
Str("User ID", req.UserId).
Msg("GetBookingByStatus")
resp, err = s.SolidarityClient.GetBookingsByStatus(ctx, req)
return resp, err
}
func (s *SolidarityService) DriverJourneys(ctx context.Context, req *proto.DriverJourneysRequest) (resp *proto.DriverJourneysResponse, err error) {
log.Info().
Str("Address", req.Departure.Address).
Msg("DriverJourneys")
resp, err = s.SolidarityClient.DriverJourneys(ctx, req)
return resp, err
}
func (s *SolidarityService) SetPassengerTrip(ctx context.Context, req *proto.PassengerTripRequest) (resp *proto.PassengerTripResponse, err error) {
log.Info().
Str("Passenger ID", req.Passenger.Id).
Msg("SetPassengerTrip")
resp, err = s.SolidarityClient.SetPassengerTrip(ctx, req)
return resp, err
}