GetAlPassengers
This commit is contained in:
@@ -3,15 +3,17 @@ package grpcserver
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
"github.com/paulmach/orb"
|
||||
"github.com/paulmach/orb/geojson"
|
||||
"github.com/rs/zerolog/log"
|
||||
"solidarity-service/internal"
|
||||
"solidarity-service/servers/grpc/proto"
|
||||
"solidarity-service/utils"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
"github.com/paulmach/orb"
|
||||
"github.com/paulmach/orb/geojson"
|
||||
"github.com/rs/zerolog/log"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
)
|
||||
|
||||
func (s *SolidarityServiceServerImpl) SetDriverRegularAvailabilities(ctx context.Context, req *proto.DriverRegularAvailabilities) (resp *proto.DriverAvailabilitiesResponse, err error) {
|
||||
@@ -20,6 +22,7 @@ func (s *SolidarityServiceServerImpl) SetDriverRegularAvailabilities(ctx context
|
||||
Success: false,
|
||||
}, errors.New("missing required fields")
|
||||
}
|
||||
|
||||
driver := internal.Driver{
|
||||
Driver_departure_address: &geojson.Feature{
|
||||
Type: "Feature",
|
||||
@@ -164,10 +167,54 @@ func (s *SolidarityServiceServerImpl) SetDriverPunctualAvailabilities(ctx contex
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *SolidarityServiceServerImpl) CreateBooking(ctx context.Context, req *proto.CreateBookingSolidarityRequest) (resp *proto.CreateBookingSolidarityResponse, err error) {
|
||||
if req.Booking.DriverId == "" || req.Booking.PassengerId == "" || req.Booking.Id == "" || req.Booking.Status.String() == "" || req.Booking.DepartureAddress == nil || req.Booking.DestinationAddress == nil || req.Booking.PickupDate.Seconds == 0 {
|
||||
return nil, errors.New("missing required fields")
|
||||
func (s *SolidarityServiceServerImpl) GetAllPassengers( ctx context.Context, _ *emptypb.Empty) (resp *proto.GetAllPassengersResponse, err error) {
|
||||
passengers, err := s.Handler.GetAllPassengers(context.Background())
|
||||
resp = &proto.GetAllPassengersResponse{
|
||||
Passenger: []*proto.User{},
|
||||
}
|
||||
response := []*proto.User{}
|
||||
for _, v := range passengers {
|
||||
temp := &proto.User{
|
||||
Id: v.Passenger.ID,
|
||||
Alias: v.Passenger.Alias,
|
||||
FirstName: v.Passenger.FirstName,
|
||||
LastName: v.Passenger.LastName,
|
||||
Grade: v.Passenger.Grade,
|
||||
Picture: v.Passenger.Picture,
|
||||
Gender: v.Passenger.Gender,
|
||||
VerifiedIdentity: v.Passenger.VerifiedIdentity,
|
||||
}
|
||||
response = append(response, temp)
|
||||
}
|
||||
resp.Passenger = response
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *SolidarityServiceServerImpl) CreateBookingSolidarity(ctx context.Context, req *proto.CreateBookingSolidarityRequest) (resp *proto.CreateBookingSolidarityResponse, err error) {
|
||||
if req.Booking.DriverId == "" {
|
||||
return nil, errors.New("missing required DriverId")
|
||||
}
|
||||
if req.Booking.DepartureAddress == nil {
|
||||
return nil, errors.New("missing required DepartureAddress")
|
||||
}
|
||||
if req.Booking.DestinationAddress == nil {
|
||||
return nil, errors.New("missing required DestinationAddress")
|
||||
}
|
||||
if req.Booking.PassengerId == "" {
|
||||
return nil, errors.New("missing required PassengerId")
|
||||
}
|
||||
if req.Booking.Id == "" {
|
||||
return nil, errors.New("missing required Id")
|
||||
}
|
||||
if req.Booking.Status.String() == "" {
|
||||
return nil, errors.New("missing required Status")
|
||||
}
|
||||
|
||||
if req.Booking.PickupDate.Seconds == 0 {
|
||||
return nil, errors.New("missing required Seconds")
|
||||
}
|
||||
|
||||
|
||||
bookingRequest := internal.BookingRequest{
|
||||
ID: req.Booking.Id,
|
||||
Passenger_id: req.Booking.PassengerId,
|
||||
@@ -254,7 +301,7 @@ func (s *SolidarityServiceServerImpl) CreateBooking(ctx context.Context, req *pr
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *SolidarityServiceServerImpl) UpdateBooking(ctx context.Context, req *proto.UpdateBookingSolidarityRequest) (resp *proto.UpdateBookingSolidarityResponse, err error) {
|
||||
func (s *SolidarityServiceServerImpl) UpdateBookingSolidarity(ctx context.Context, req *proto.UpdateBookingSolidarityRequest) (resp *proto.UpdateBookingSolidarityResponse, err error) {
|
||||
if req.BookingId == "" || req.Status.String() == "" {
|
||||
return &proto.UpdateBookingSolidarityResponse{
|
||||
Success: false,
|
||||
@@ -275,7 +322,7 @@ func (s *SolidarityServiceServerImpl) UpdateBooking(ctx context.Context, req *pr
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *SolidarityServiceServerImpl) GetBooking(ctx context.Context, req *proto.GetBookingSolidarityRequest) (resp *proto.GetBookingSolidarityResponse, err error) {
|
||||
func (s *SolidarityServiceServerImpl) GetBookingSolidarity(ctx context.Context, req *proto.GetBookingSolidarityRequest) (resp *proto.GetBookingSolidarityResponse, err error) {
|
||||
if req.BookingId == "" {
|
||||
return nil, errors.New("empty booking ID")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user