diff --git a/carpool-service b/carpool-service new file mode 100755 index 0000000..ab7f443 Binary files /dev/null and b/carpool-service differ diff --git a/handler/bookings.go b/handler/bookings.go index f83c11c..98b9416 100644 --- a/handler/bookings.go +++ b/handler/bookings.go @@ -11,7 +11,7 @@ import ( ) // Book handles the booking flow -func (h *CarpoolServiceHandler) Book(booking ocss.Booking) (*internal.Booking, error) { +func (h *CarpoolServiceHandler) Book(booking ocss.Booking, motivation *string) (*internal.Booking, error) { log.Debug().Any("booking", booking).Msg("handler - Book") log.Debug().Str("passengerPickupDate", booking.PassengerPickupDate.ToTime().Format(time.RFC3339)).Msg("handler - Book") log.Debug().Str("internal_operator_id", h.InternalOperatorID).Str("driver_operator", booking.Driver.Operator).Str("passenger_operator", booking.Passenger.Operator).Msg("operator comparison") @@ -62,6 +62,7 @@ func (h *CarpoolServiceHandler) Book(booking ocss.Booking) (*internal.Booking, e } futureBooking.Booking = booking + futureBooking.Motivation = motivation err := h.Storage.CreateBooking(futureBooking) if err != nil { diff --git a/internal/booking.go b/internal/booking.go index 68ab762..e1d80ea 100644 --- a/internal/booking.go +++ b/internal/booking.go @@ -11,4 +11,5 @@ type Booking struct { DriverRoute *geojson.FeatureCollection `bson:"driver_route,omitempty"` PassengerRoute *geojson.FeatureCollection `bson:"passenger_route,omitempty"` + Motivation *string `bson:"motivation,omitempty" json:"motivation,omitempty"` } diff --git a/servers/grpc/proto/carpool-service-types.pb.go b/servers/grpc/proto/carpool-service-types.pb.go index 858ecf8..ecec982 100644 --- a/servers/grpc/proto/carpool-service-types.pb.go +++ b/servers/grpc/proto/carpool-service-types.pb.go @@ -1278,6 +1278,7 @@ type CarpoolServiceBooking struct { DriverDepartureDate *timestamppb.Timestamp `protobuf:"bytes,32,opt,name=driverDepartureDate,proto3,oneof" json:"driverDepartureDate,omitempty"` DriverCompensationAmount *float64 `protobuf:"fixed64,33,opt,name=driver_compensation_amount,json=driverCompensationAmount,proto3,oneof" json:"driver_compensation_amount,omitempty"` DriverCompensationCurrency *string `protobuf:"bytes,34,opt,name=driver_compensation_currency,json=driverCompensationCurrency,proto3,oneof" json:"driver_compensation_currency,omitempty"` + Motivation *string `protobuf:"bytes,35,opt,name=motivation,proto3,oneof" json:"motivation,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -1473,6 +1474,13 @@ func (x *CarpoolServiceBooking) GetDriverCompensationCurrency() string { return "" } +func (x *CarpoolServiceBooking) GetMotivation() string { + if x != nil && x.Motivation != nil { + return *x.Motivation + } + return "" +} + type CarpoolServicePreferences struct { state protoimpl.MessageState `protogen:"open.v1"` Smoking *bool `protobuf:"varint,1,opt,name=smoking,proto3,oneof" json:"smoking,omitempty"` @@ -2107,7 +2115,7 @@ const file_carpool_service_types_proto_rawDesc = "" + "\x11_journey_polylineB\n" + "\n" + "\b_web_urlB\x0e\n" + - "\f_preferences\"\xa8\v\n" + + "\f_preferences\"\xdc\v\n" + "\x15CarpoolServiceBooking\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12+\n" + "\x06driver\x18\x02 \x01(\v2\x13.CarpoolServiceUserR\x06driver\x121\n" + @@ -2133,7 +2141,10 @@ const file_carpool_service_types_proto_rawDesc = "" + "\x13driverDepartureDate\x18 \x01(\v2\x1a.google.protobuf.TimestampH\bR\x13driverDepartureDate\x88\x01\x01\x12A\n" + "\x1adriver_compensation_amount\x18! \x01(\x01H\tR\x18driverCompensationAmount\x88\x01\x01\x12E\n" + "\x1cdriver_compensation_currency\x18\" \x01(\tH\n" + - "R\x1adriverCompensationCurrency\x88\x01\x01B\x1b\n" + + "R\x1adriverCompensationCurrency\x88\x01\x01\x12#\n" + + "\n" + + "motivation\x18# \x01(\tH\vR\n" + + "motivation\x88\x01\x01B\x1b\n" + "\x19_passenger_pickup_addressB\x19\n" + "\x17_passenger_drop_addressB\v\n" + "\t_distanceB\v\n" + @@ -2145,7 +2156,8 @@ const file_carpool_service_types_proto_rawDesc = "" + "\x10_passenger_routeB\x16\n" + "\x14_driverDepartureDateB\x1d\n" + "\x1b_driver_compensation_amountB\x1f\n" + - "\x1d_driver_compensation_currency\"\xff\x01\n" + + "\x1d_driver_compensation_currencyB\r\n" + + "\v_motivation\"\xff\x01\n" + "\x19CarpoolServicePreferences\x12\x1d\n" + "\asmoking\x18\x01 \x01(\bH\x00R\asmoking\x88\x01\x01\x12\x1d\n" + "\aanimals\x18\x02 \x01(\bH\x01R\aanimals\x88\x01\x01\x12\x19\n" + diff --git a/servers/grpc/proto/carpool-service-types.proto b/servers/grpc/proto/carpool-service-types.proto index cbbbcec..72ba552 100644 --- a/servers/grpc/proto/carpool-service-types.proto +++ b/servers/grpc/proto/carpool-service-types.proto @@ -156,6 +156,7 @@ message CarpoolServiceBooking { optional google.protobuf.Timestamp driverDepartureDate = 32; optional double driver_compensation_amount = 33; optional string driver_compensation_currency = 34; + optional string motivation = 35; } message CarpoolServicePreferences { diff --git a/servers/grpc/proto/helpers.go b/servers/grpc/proto/helpers.go index 50b064f..ecc15e6 100644 --- a/servers/grpc/proto/helpers.go +++ b/servers/grpc/proto/helpers.go @@ -378,6 +378,8 @@ func BookingFromInternal(b internal.Booking) *CarpoolServiceBooking { } } + booking.Motivation = b.Motivation + return booking } diff --git a/servers/grpc/server/book.go b/servers/grpc/server/book.go index 52cb484..937f59c 100644 --- a/servers/grpc/server/book.go +++ b/servers/grpc/server/book.go @@ -12,7 +12,7 @@ import ( func (s *CarpoolServiceServerImpl) CreateBooking(ctx context.Context, req *proto.CreateCarpoolBookingRequest) (*proto.CreateCarpoolBookingResponse, error) { booking := req.Booking.ToOCSS() - createdBooking, err := s.Handler.Book(booking) + createdBooking, err := s.Handler.Book(booking, req.Booking.Motivation) if err != nil { return nil, status.Errorf(codes.Internal, "could not create booking - %s", err.Error()) } diff --git a/servers/ocss-api/book.go b/servers/ocss-api/book.go index 0860c1c..5048c6c 100644 --- a/servers/ocss-api/book.go +++ b/servers/ocss-api/book.go @@ -8,7 +8,7 @@ import ( ) func (s *OCSSApiService) PostBookings(ctx context.Context, booking ocss.Booking) (*ocss.Booking, error) { - result, err := s.Handler.Book(booking) + result, err := s.Handler.Book(booking, nil) if err != nil { log.Error().Err(err).Msg("issue in booking") return nil, err