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-08-02 13:11:30 +00:00
func ( s * SolidarityService ) CreateBooking ( ctx context . Context , req * proto . CreateBookingSolidarityRequest ) ( resp * proto . CreateBookingSolidarityResponse , err error ) {
2023-12-08 06:35:04 +00:00
log . Info ( ) .
Str ( "Booking ID" , req . Booking . Id ) .
Msg ( "CreateBooking" )
2024-08-02 13:11:30 +00:00
resp , err = s . SolidarityClient . CreateBookingSolidarity ( 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-08-02 13:11:30 +00:00
func ( s * SolidarityService ) UpdateBooking ( ctx context . Context , req * proto . UpdateBookingSolidarityRequest ) ( resp * proto . UpdateBookingSolidarityResponse , err error ) {
2023-12-08 06:35:04 +00:00
log . Info ( ) .
Str ( "Booking ID" , req . BookingId ) .
Msg ( "UpdateBooking" )
2024-08-02 13:11:30 +00:00
resp , err = s . SolidarityClient . UpdateBookingSolidarity ( ctx , req )
2023-12-08 06:35:04 +00:00
return resp , err
}
2024-08-02 13:11:30 +00:00
func ( s * SolidarityService ) GetBooking ( ctx context . Context , req * proto . GetBookingSolidarityRequest ) ( resp * proto . GetBookingSolidarityResponse , err error ) {
2023-12-08 06:35:04 +00:00
log . Info ( ) .
Str ( "Booking ID" , req . BookingId ) .
Msg ( "GetBooking" )
2024-08-02 13:11:30 +00:00
resp , err = s . SolidarityClient . GetBookingSolidarity ( 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
}