refactoring
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
syntax = "proto3";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/struct.proto";
|
||||
option go_package = "git.coopgo.io/coopgo-apps/silvermobi/grpcapi/proto";
|
||||
|
||||
service SilvermobiGRPC {
|
||||
@@ -16,10 +17,28 @@ service SilvermobiGRPC {
|
||||
rpc SetKeyValue(KeyValueRequest) returns (KeyValueResponse) {}
|
||||
rpc GetKeyValue(KeyRequest) returns (ValueResponse) {}
|
||||
rpc GetValidation(ValidationRequest) returns (ValidationResponse) {}
|
||||
|
||||
|
||||
rpc GeoAutocomplete( GeoAutocompleteRequest) returns (GeoAutocompleteResponse) {}
|
||||
rpc GeoRoute(GeoRouteRequest) returns (GeoRouteResponse) {}
|
||||
rpc GeoRouteWithReturn(GeoRouteWithReturnRequest) returns (GeoRouteWithReturnResponse) {}
|
||||
rpc PutFirebaseToken(FirebaseTokenRequest) returns (FirebaseTokenResponse) {}
|
||||
rpc GetAccountInfo(AccountInfoRequest) returns (AccountInfoResponse) {}
|
||||
}
|
||||
|
||||
message AccountInfoRequest {
|
||||
|
||||
}
|
||||
message AccountInfoResponse{
|
||||
string first_name = 1;
|
||||
string last_name = 2;
|
||||
}
|
||||
|
||||
message FirebaseTokenRequest {
|
||||
string token = 1;
|
||||
string device_platform = 2;
|
||||
}
|
||||
message FirebaseTokenResponse {
|
||||
bool result = 1;
|
||||
}
|
||||
message AuthLoginRequest {
|
||||
string username = 1;
|
||||
string password = 2;
|
||||
@@ -61,20 +80,20 @@ message UpdatePasswordResponse{
|
||||
}
|
||||
|
||||
message SetPhoneNumberRequest {
|
||||
string phone_number = 1;
|
||||
string phone_number = 1;
|
||||
}
|
||||
|
||||
message SetPhoneNumberResponse {
|
||||
bool ok = 1;
|
||||
bool ok = 1;
|
||||
}
|
||||
|
||||
message VerifyPhoneNumberRequest {
|
||||
string phone_number = 1;
|
||||
string verification_code = 2;
|
||||
string phone_number = 1;
|
||||
string verification_code = 2;
|
||||
}
|
||||
|
||||
message VerifyPhoneNumberResponse {
|
||||
bool ok = 1;
|
||||
bool ok = 1;
|
||||
}
|
||||
|
||||
message BirthDateRequest {
|
||||
@@ -126,4 +145,56 @@ message AccountTypeResponse {
|
||||
DRIVER = 1;
|
||||
}
|
||||
optional AccountType type = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message GeoAutocompleteRequest {
|
||||
string text = 60;
|
||||
double lat = 61;
|
||||
double lon = 62;
|
||||
}
|
||||
|
||||
message GeoAutocompleteResponse {
|
||||
oneof feature_collection {
|
||||
string feature_collection_raw = 1;
|
||||
FeatureCollection feature_collection_impl = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message GeoRouteRequest {
|
||||
oneof locations {
|
||||
string locations_raw = 1;
|
||||
FeatureCollection locations_impl = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message GeoRouteResponse {
|
||||
string polyline = 1;
|
||||
}
|
||||
|
||||
message GeoRouteWithReturnRequest {
|
||||
oneof locations {
|
||||
string locations_raw = 1;
|
||||
FeatureCollection locations_impl = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message GeoRouteWithReturnResponse {
|
||||
string polyline = 1;
|
||||
string return_polyline = 2;
|
||||
}
|
||||
|
||||
message FeatureCollection {
|
||||
string type = 1;
|
||||
repeated double bbox = 2;
|
||||
repeated Feature_ features = 3;
|
||||
}
|
||||
|
||||
message Feature_ {
|
||||
string id = 1;
|
||||
string type = 2;
|
||||
repeated double bbox = 3;
|
||||
Geometry geometry = 4;
|
||||
google.protobuf.Struct properties = 5;
|
||||
}
|
||||
|
||||
message Geometry {}
|
||||
@@ -19,18 +19,23 @@ import (
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
const (
|
||||
SilvermobiGRPC_AuthLogin_FullMethodName = "/SilvermobiGRPC/AuthLogin"
|
||||
SilvermobiGRPC_AuthRegister_FullMethodName = "/SilvermobiGRPC/AuthRegister"
|
||||
SilvermobiGRPC_ForgetAccount_FullMethodName = "/SilvermobiGRPC/ForgetAccount"
|
||||
SilvermobiGRPC_UpdatePassword_FullMethodName = "/SilvermobiGRPC/UpdatePassword"
|
||||
SilvermobiGRPC_SetPhoneNumber_FullMethodName = "/SilvermobiGRPC/SetPhoneNumber"
|
||||
SilvermobiGRPC_VerifyPhoneNumber_FullMethodName = "/SilvermobiGRPC/VerifyPhoneNumber"
|
||||
SilvermobiGRPC_SetBirthDate_FullMethodName = "/SilvermobiGRPC/SetBirthDate"
|
||||
SilvermobiGRPC_SetAccountType_FullMethodName = "/SilvermobiGRPC/SetAccountType"
|
||||
SilvermobiGRPC_GetAccountType_FullMethodName = "/SilvermobiGRPC/GetAccountType"
|
||||
SilvermobiGRPC_SetKeyValue_FullMethodName = "/SilvermobiGRPC/SetKeyValue"
|
||||
SilvermobiGRPC_GetKeyValue_FullMethodName = "/SilvermobiGRPC/GetKeyValue"
|
||||
SilvermobiGRPC_GetValidation_FullMethodName = "/SilvermobiGRPC/GetValidation"
|
||||
SilvermobiGRPC_AuthLogin_FullMethodName = "/SilvermobiGRPC/AuthLogin"
|
||||
SilvermobiGRPC_AuthRegister_FullMethodName = "/SilvermobiGRPC/AuthRegister"
|
||||
SilvermobiGRPC_ForgetAccount_FullMethodName = "/SilvermobiGRPC/ForgetAccount"
|
||||
SilvermobiGRPC_UpdatePassword_FullMethodName = "/SilvermobiGRPC/UpdatePassword"
|
||||
SilvermobiGRPC_SetPhoneNumber_FullMethodName = "/SilvermobiGRPC/SetPhoneNumber"
|
||||
SilvermobiGRPC_VerifyPhoneNumber_FullMethodName = "/SilvermobiGRPC/VerifyPhoneNumber"
|
||||
SilvermobiGRPC_SetBirthDate_FullMethodName = "/SilvermobiGRPC/SetBirthDate"
|
||||
SilvermobiGRPC_SetAccountType_FullMethodName = "/SilvermobiGRPC/SetAccountType"
|
||||
SilvermobiGRPC_GetAccountType_FullMethodName = "/SilvermobiGRPC/GetAccountType"
|
||||
SilvermobiGRPC_SetKeyValue_FullMethodName = "/SilvermobiGRPC/SetKeyValue"
|
||||
SilvermobiGRPC_GetKeyValue_FullMethodName = "/SilvermobiGRPC/GetKeyValue"
|
||||
SilvermobiGRPC_GetValidation_FullMethodName = "/SilvermobiGRPC/GetValidation"
|
||||
SilvermobiGRPC_GeoAutocomplete_FullMethodName = "/SilvermobiGRPC/GeoAutocomplete"
|
||||
SilvermobiGRPC_GeoRoute_FullMethodName = "/SilvermobiGRPC/GeoRoute"
|
||||
SilvermobiGRPC_GeoRouteWithReturn_FullMethodName = "/SilvermobiGRPC/GeoRouteWithReturn"
|
||||
SilvermobiGRPC_PutFirebaseToken_FullMethodName = "/SilvermobiGRPC/PutFirebaseToken"
|
||||
SilvermobiGRPC_GetAccountInfo_FullMethodName = "/SilvermobiGRPC/GetAccountInfo"
|
||||
)
|
||||
|
||||
// SilvermobiGRPCClient is the client API for SilvermobiGRPC service.
|
||||
@@ -49,6 +54,11 @@ type SilvermobiGRPCClient interface {
|
||||
SetKeyValue(ctx context.Context, in *KeyValueRequest, opts ...grpc.CallOption) (*KeyValueResponse, error)
|
||||
GetKeyValue(ctx context.Context, in *KeyRequest, opts ...grpc.CallOption) (*ValueResponse, error)
|
||||
GetValidation(ctx context.Context, in *ValidationRequest, opts ...grpc.CallOption) (*ValidationResponse, error)
|
||||
GeoAutocomplete(ctx context.Context, in *GeoAutocompleteRequest, opts ...grpc.CallOption) (*GeoAutocompleteResponse, error)
|
||||
GeoRoute(ctx context.Context, in *GeoRouteRequest, opts ...grpc.CallOption) (*GeoRouteResponse, error)
|
||||
GeoRouteWithReturn(ctx context.Context, in *GeoRouteWithReturnRequest, opts ...grpc.CallOption) (*GeoRouteWithReturnResponse, error)
|
||||
PutFirebaseToken(ctx context.Context, in *FirebaseTokenRequest, opts ...grpc.CallOption) (*FirebaseTokenResponse, error)
|
||||
GetAccountInfo(ctx context.Context, in *AccountInfoRequest, opts ...grpc.CallOption) (*AccountInfoResponse, error)
|
||||
}
|
||||
|
||||
type silvermobiGRPCClient struct {
|
||||
@@ -167,6 +177,51 @@ func (c *silvermobiGRPCClient) GetValidation(ctx context.Context, in *Validation
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *silvermobiGRPCClient) GeoAutocomplete(ctx context.Context, in *GeoAutocompleteRequest, opts ...grpc.CallOption) (*GeoAutocompleteResponse, error) {
|
||||
out := new(GeoAutocompleteResponse)
|
||||
err := c.cc.Invoke(ctx, SilvermobiGRPC_GeoAutocomplete_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *silvermobiGRPCClient) GeoRoute(ctx context.Context, in *GeoRouteRequest, opts ...grpc.CallOption) (*GeoRouteResponse, error) {
|
||||
out := new(GeoRouteResponse)
|
||||
err := c.cc.Invoke(ctx, SilvermobiGRPC_GeoRoute_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *silvermobiGRPCClient) GeoRouteWithReturn(ctx context.Context, in *GeoRouteWithReturnRequest, opts ...grpc.CallOption) (*GeoRouteWithReturnResponse, error) {
|
||||
out := new(GeoRouteWithReturnResponse)
|
||||
err := c.cc.Invoke(ctx, SilvermobiGRPC_GeoRouteWithReturn_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *silvermobiGRPCClient) PutFirebaseToken(ctx context.Context, in *FirebaseTokenRequest, opts ...grpc.CallOption) (*FirebaseTokenResponse, error) {
|
||||
out := new(FirebaseTokenResponse)
|
||||
err := c.cc.Invoke(ctx, SilvermobiGRPC_PutFirebaseToken_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *silvermobiGRPCClient) GetAccountInfo(ctx context.Context, in *AccountInfoRequest, opts ...grpc.CallOption) (*AccountInfoResponse, error) {
|
||||
out := new(AccountInfoResponse)
|
||||
err := c.cc.Invoke(ctx, SilvermobiGRPC_GetAccountInfo_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// SilvermobiGRPCServer is the server API for SilvermobiGRPC service.
|
||||
// All implementations must embed UnimplementedSilvermobiGRPCServer
|
||||
// for forward compatibility
|
||||
@@ -183,6 +238,11 @@ type SilvermobiGRPCServer interface {
|
||||
SetKeyValue(context.Context, *KeyValueRequest) (*KeyValueResponse, error)
|
||||
GetKeyValue(context.Context, *KeyRequest) (*ValueResponse, error)
|
||||
GetValidation(context.Context, *ValidationRequest) (*ValidationResponse, error)
|
||||
GeoAutocomplete(context.Context, *GeoAutocompleteRequest) (*GeoAutocompleteResponse, error)
|
||||
GeoRoute(context.Context, *GeoRouteRequest) (*GeoRouteResponse, error)
|
||||
GeoRouteWithReturn(context.Context, *GeoRouteWithReturnRequest) (*GeoRouteWithReturnResponse, error)
|
||||
PutFirebaseToken(context.Context, *FirebaseTokenRequest) (*FirebaseTokenResponse, error)
|
||||
GetAccountInfo(context.Context, *AccountInfoRequest) (*AccountInfoResponse, error)
|
||||
mustEmbedUnimplementedSilvermobiGRPCServer()
|
||||
}
|
||||
|
||||
@@ -226,6 +286,21 @@ func (UnimplementedSilvermobiGRPCServer) GetKeyValue(context.Context, *KeyReques
|
||||
func (UnimplementedSilvermobiGRPCServer) GetValidation(context.Context, *ValidationRequest) (*ValidationResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetValidation not implemented")
|
||||
}
|
||||
func (UnimplementedSilvermobiGRPCServer) GeoAutocomplete(context.Context, *GeoAutocompleteRequest) (*GeoAutocompleteResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GeoAutocomplete not implemented")
|
||||
}
|
||||
func (UnimplementedSilvermobiGRPCServer) GeoRoute(context.Context, *GeoRouteRequest) (*GeoRouteResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GeoRoute not implemented")
|
||||
}
|
||||
func (UnimplementedSilvermobiGRPCServer) GeoRouteWithReturn(context.Context, *GeoRouteWithReturnRequest) (*GeoRouteWithReturnResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GeoRouteWithReturn not implemented")
|
||||
}
|
||||
func (UnimplementedSilvermobiGRPCServer) PutFirebaseToken(context.Context, *FirebaseTokenRequest) (*FirebaseTokenResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PutFirebaseToken not implemented")
|
||||
}
|
||||
func (UnimplementedSilvermobiGRPCServer) GetAccountInfo(context.Context, *AccountInfoRequest) (*AccountInfoResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetAccountInfo not implemented")
|
||||
}
|
||||
func (UnimplementedSilvermobiGRPCServer) mustEmbedUnimplementedSilvermobiGRPCServer() {}
|
||||
|
||||
// UnsafeSilvermobiGRPCServer may be embedded to opt out of forward compatibility for this service.
|
||||
@@ -455,6 +530,96 @@ func _SilvermobiGRPC_GetValidation_Handler(srv interface{}, ctx context.Context,
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SilvermobiGRPC_GeoAutocomplete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GeoAutocompleteRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SilvermobiGRPCServer).GeoAutocomplete(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SilvermobiGRPC_GeoAutocomplete_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SilvermobiGRPCServer).GeoAutocomplete(ctx, req.(*GeoAutocompleteRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SilvermobiGRPC_GeoRoute_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GeoRouteRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SilvermobiGRPCServer).GeoRoute(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SilvermobiGRPC_GeoRoute_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SilvermobiGRPCServer).GeoRoute(ctx, req.(*GeoRouteRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SilvermobiGRPC_GeoRouteWithReturn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GeoRouteWithReturnRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SilvermobiGRPCServer).GeoRouteWithReturn(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SilvermobiGRPC_GeoRouteWithReturn_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SilvermobiGRPCServer).GeoRouteWithReturn(ctx, req.(*GeoRouteWithReturnRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SilvermobiGRPC_PutFirebaseToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(FirebaseTokenRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SilvermobiGRPCServer).PutFirebaseToken(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SilvermobiGRPC_PutFirebaseToken_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SilvermobiGRPCServer).PutFirebaseToken(ctx, req.(*FirebaseTokenRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SilvermobiGRPC_GetAccountInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AccountInfoRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SilvermobiGRPCServer).GetAccountInfo(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SilvermobiGRPC_GetAccountInfo_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SilvermobiGRPCServer).GetAccountInfo(ctx, req.(*AccountInfoRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// SilvermobiGRPC_ServiceDesc is the grpc.ServiceDesc for SilvermobiGRPC service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@@ -510,6 +675,26 @@ var SilvermobiGRPC_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "GetValidation",
|
||||
Handler: _SilvermobiGRPC_GetValidation_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GeoAutocomplete",
|
||||
Handler: _SilvermobiGRPC_GeoAutocomplete_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GeoRoute",
|
||||
Handler: _SilvermobiGRPC_GeoRoute_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GeoRouteWithReturn",
|
||||
Handler: _SilvermobiGRPC_GeoRouteWithReturn_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "PutFirebaseToken",
|
||||
Handler: _SilvermobiGRPC_PutFirebaseToken_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetAccountInfo",
|
||||
Handler: _SilvermobiGRPC_GetAccountInfo_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "silvermobi-service.proto",
|
||||
|
||||
1740
servers/grpcapi/proto/solidarity-api-types.pb.go
Normal file
1740
servers/grpcapi/proto/solidarity-api-types.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
137
servers/grpcapi/proto/solidarity-api-types.proto
Normal file
137
servers/grpcapi/proto/solidarity-api-types.proto
Normal file
@@ -0,0 +1,137 @@
|
||||
syntax = "proto3";
|
||||
option go_package = "git.coopgo.io/coopgo-platform/solidarity-service/servers/grpc/proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
|
||||
|
||||
message Feature {
|
||||
double lat = 1;
|
||||
double long = 2;
|
||||
string address = 3;
|
||||
}
|
||||
|
||||
message DriverJourney {
|
||||
User user = 1;
|
||||
optional Car car = 2;
|
||||
google.protobuf.Timestamp driver_departure_Date = 3;
|
||||
optional Price price = 4;
|
||||
string driver_departure_Address = 5;
|
||||
oneof availabilities {
|
||||
RepeatedPunctualAvailabilitySlot repeated_punctual_availabilities = 6;
|
||||
RepeatedRegularAvailabilitySlot repeated_regular_availabilities = 7;
|
||||
}
|
||||
}
|
||||
message RepeatedPunctualAvailabilitySlot {
|
||||
repeated PunctualAvailabilitySlot punctual_availabilities = 1;
|
||||
}
|
||||
|
||||
message RepeatedRegularAvailabilitySlot {
|
||||
repeated RegularAvailabilitySlot regular_availabilities = 1;
|
||||
}
|
||||
|
||||
message DriverRequest{
|
||||
Feature driver_address = 1;
|
||||
int32 driver_radius = 2;
|
||||
User driver = 3;
|
||||
optional Preferences preferences = 4;
|
||||
optional Car car = 5;
|
||||
}
|
||||
|
||||
message PunctualAvailabilitySlot {
|
||||
google.protobuf.Timestamp date = 1;
|
||||
string startTime = 2;
|
||||
string endTime = 3;
|
||||
}
|
||||
message RegularAvailabilitySlot {
|
||||
DayOfWeek dayOfWeek = 1;
|
||||
string startTime = 2;
|
||||
string endTime = 3;
|
||||
}
|
||||
|
||||
enum DayOfWeek {
|
||||
MON = 0;
|
||||
TUE = 1;
|
||||
WED = 3;
|
||||
THU = 4;
|
||||
FRI = 5;
|
||||
SAT = 6;
|
||||
SUN = 7;
|
||||
}
|
||||
|
||||
message BookingRequest {
|
||||
string id = 1;
|
||||
string passengerId = 2;
|
||||
string driverId = 3;
|
||||
BookingStatus status = 4;
|
||||
Feature departure_address =5;
|
||||
Feature destination_address = 6;
|
||||
google.protobuf.Timestamp pickup_date = 7;
|
||||
}
|
||||
|
||||
message Booking {
|
||||
string id = 1;
|
||||
User driver = 2;
|
||||
User passenger = 3;
|
||||
google.protobuf.Timestamp passengerPickupDate =4;
|
||||
Feature passenger_departure_route = 5;
|
||||
Feature passenger_destination_route = 6;
|
||||
BookingStatus status = 7;
|
||||
optional int64 duration = 8;
|
||||
optional int64 distance = 9;
|
||||
Price price = 10;
|
||||
optional Car car = 11;
|
||||
google.protobuf.Timestamp pickup_date = 12;
|
||||
}
|
||||
|
||||
|
||||
message Car {
|
||||
optional string model = 1;
|
||||
optional string brand = 2;
|
||||
}
|
||||
|
||||
message Preferences {
|
||||
optional bool smoking = 1;
|
||||
optional bool animals = 2;
|
||||
optional bool music = 3;
|
||||
optional bool is_talker = 4;
|
||||
optional int64 luggage_size = 5;
|
||||
}
|
||||
|
||||
|
||||
enum PriceType {
|
||||
FREE = 0;
|
||||
PAYING = 1;
|
||||
UNKNOWN = 2;
|
||||
}
|
||||
|
||||
message Price {
|
||||
optional PriceType type = 1;
|
||||
optional double amount = 2;
|
||||
optional string currency = 3;
|
||||
}
|
||||
|
||||
message User {
|
||||
string id = 1;
|
||||
string alias = 2;
|
||||
optional string first_name = 3;
|
||||
optional string last_name = 4;
|
||||
optional int64 grade = 5;
|
||||
optional string picture = 6;
|
||||
optional string gender = 7;
|
||||
optional bool verified_identity = 8;
|
||||
}
|
||||
|
||||
enum BookingStatus {
|
||||
INITIATED = 0;
|
||||
WAITING_DRIVER_CONFIRMATION = 1;
|
||||
WAITING_PASSENGER_CONFIRMATION = 2;
|
||||
CONFIRMED = 3;
|
||||
CANCELLED = 4;
|
||||
COMPLETED_PENDING_VALIDATION = 5;
|
||||
VALIDATED = 6;
|
||||
}
|
||||
|
||||
enum UserType{
|
||||
driver = 0;
|
||||
passenger = 1;
|
||||
}
|
||||
1261
servers/grpcapi/proto/solidarity-api.pb.go
Normal file
1261
servers/grpcapi/proto/solidarity-api.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
88
servers/grpcapi/proto/solidarity-api.proto
Normal file
88
servers/grpcapi/proto/solidarity-api.proto
Normal file
@@ -0,0 +1,88 @@
|
||||
syntax = "proto3";
|
||||
option go_package = "git.coopgo.io/coopgo-platform/solidarity-service/servers/grpc/proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "solidarity-api-types.proto";
|
||||
|
||||
service SolidarityService {
|
||||
rpc SetDriverRegularAvailabilities(DriverRegularAvailabilities) returns (DriverAvailabilitiesResponse) {}
|
||||
rpc SetDriverPunctualAvailabilities(DriverPunctualAvailabilities) returns (DriverAvailabilitiesResponse) {}
|
||||
rpc CreateBooking(CreateBookingRequest) returns (CreateBookingResponse) {}
|
||||
rpc UpdateBooking(UpdateBookingRequest) returns (UpdateBookingResponse) {}
|
||||
rpc GetBooking(GetBookingRequest) returns (GetBookingResponse) {}
|
||||
rpc GetBookingsByStatus(GetBookingsByStatusRequest) returns (GetBookingsByStatusResponse) {}
|
||||
rpc DriverJourneys(DriverJourneysRequest) returns (DriverJourneysResponse) {}
|
||||
rpc SetPassengerTrip(PassengerTripRequest) returns (PassengerTripResponse) {}
|
||||
}
|
||||
|
||||
|
||||
message PassengerTripRequest{
|
||||
User passenger = 1;
|
||||
optional Preferences preferences = 2;
|
||||
}
|
||||
|
||||
message DriverRegularAvailabilities{
|
||||
|
||||
DriverRequest driver_request = 1;
|
||||
repeated RegularAvailabilitySlot driver_availabilities = 2;
|
||||
}
|
||||
|
||||
message DriverPunctualAvailabilities{
|
||||
DriverRequest driver_request = 1;
|
||||
repeated PunctualAvailabilitySlot driver_availabilities = 2;
|
||||
}
|
||||
|
||||
message PassengerTripResponse {
|
||||
bool success = 1;
|
||||
optional string message = 2;
|
||||
}
|
||||
|
||||
message DriverAvailabilitiesResponse {
|
||||
bool success = 1;
|
||||
optional string message = 2;
|
||||
}
|
||||
|
||||
message CreateBookingRequest {
|
||||
BookingRequest booking = 1;
|
||||
}
|
||||
message CreateBookingResponse {
|
||||
Booking booking = 1;
|
||||
}
|
||||
|
||||
message UpdateBookingRequest {
|
||||
string booking_id = 1;
|
||||
BookingStatus status = 2;
|
||||
optional string message = 3;
|
||||
}
|
||||
|
||||
message UpdateBookingResponse {
|
||||
bool success = 1;
|
||||
optional string message = 2;
|
||||
}
|
||||
|
||||
message GetBookingRequest {
|
||||
string booking_id = 1;
|
||||
}
|
||||
|
||||
|
||||
message GetBookingResponse {
|
||||
Booking booking = 1;
|
||||
}
|
||||
|
||||
message GetBookingsByStatusRequest{
|
||||
BookingStatus status = 1;
|
||||
UserType type = 2;
|
||||
string user_id = 3;
|
||||
}
|
||||
|
||||
message DriverJourneysRequest {
|
||||
Feature departure = 1;
|
||||
google.protobuf.Timestamp departure_date = 2;
|
||||
}
|
||||
|
||||
message DriverJourneysResponse {
|
||||
repeated DriverJourney driver_journeys = 1;
|
||||
}
|
||||
|
||||
message GetBookingsByStatusResponse{
|
||||
repeated Booking booking = 1;
|
||||
}
|
||||
368
servers/grpcapi/proto/solidarity-api_grpc.pb.go
Normal file
368
servers/grpcapi/proto/solidarity-api_grpc.pb.go
Normal file
@@ -0,0 +1,368 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc v3.12.4
|
||||
// source: solidarity-api.proto
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
const (
|
||||
SolidarityService_SetDriverRegularAvailabilities_FullMethodName = "/SolidarityService/SetDriverRegularAvailabilities"
|
||||
SolidarityService_SetDriverPunctualAvailabilities_FullMethodName = "/SolidarityService/SetDriverPunctualAvailabilities"
|
||||
SolidarityService_CreateBooking_FullMethodName = "/SolidarityService/CreateBooking"
|
||||
SolidarityService_UpdateBooking_FullMethodName = "/SolidarityService/UpdateBooking"
|
||||
SolidarityService_GetBooking_FullMethodName = "/SolidarityService/GetBooking"
|
||||
SolidarityService_GetBookingsByStatus_FullMethodName = "/SolidarityService/GetBookingsByStatus"
|
||||
SolidarityService_DriverJourneys_FullMethodName = "/SolidarityService/DriverJourneys"
|
||||
SolidarityService_SetPassengerTrip_FullMethodName = "/SolidarityService/SetPassengerTrip"
|
||||
)
|
||||
|
||||
// SolidarityServiceClient is the client API for SolidarityService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type SolidarityServiceClient interface {
|
||||
SetDriverRegularAvailabilities(ctx context.Context, in *DriverRegularAvailabilities, opts ...grpc.CallOption) (*DriverAvailabilitiesResponse, error)
|
||||
SetDriverPunctualAvailabilities(ctx context.Context, in *DriverPunctualAvailabilities, opts ...grpc.CallOption) (*DriverAvailabilitiesResponse, error)
|
||||
CreateBooking(ctx context.Context, in *CreateBookingRequest, opts ...grpc.CallOption) (*CreateBookingResponse, error)
|
||||
UpdateBooking(ctx context.Context, in *UpdateBookingRequest, opts ...grpc.CallOption) (*UpdateBookingResponse, error)
|
||||
GetBooking(ctx context.Context, in *GetBookingRequest, opts ...grpc.CallOption) (*GetBookingResponse, error)
|
||||
GetBookingsByStatus(ctx context.Context, in *GetBookingsByStatusRequest, opts ...grpc.CallOption) (*GetBookingsByStatusResponse, error)
|
||||
DriverJourneys(ctx context.Context, in *DriverJourneysRequest, opts ...grpc.CallOption) (*DriverJourneysResponse, error)
|
||||
SetPassengerTrip(ctx context.Context, in *PassengerTripRequest, opts ...grpc.CallOption) (*PassengerTripResponse, error)
|
||||
}
|
||||
|
||||
type solidarityServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewSolidarityServiceClient(cc grpc.ClientConnInterface) SolidarityServiceClient {
|
||||
return &solidarityServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *solidarityServiceClient) SetDriverRegularAvailabilities(ctx context.Context, in *DriverRegularAvailabilities, opts ...grpc.CallOption) (*DriverAvailabilitiesResponse, error) {
|
||||
out := new(DriverAvailabilitiesResponse)
|
||||
err := c.cc.Invoke(ctx, SolidarityService_SetDriverRegularAvailabilities_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *solidarityServiceClient) SetDriverPunctualAvailabilities(ctx context.Context, in *DriverPunctualAvailabilities, opts ...grpc.CallOption) (*DriverAvailabilitiesResponse, error) {
|
||||
out := new(DriverAvailabilitiesResponse)
|
||||
err := c.cc.Invoke(ctx, SolidarityService_SetDriverPunctualAvailabilities_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *solidarityServiceClient) CreateBooking(ctx context.Context, in *CreateBookingRequest, opts ...grpc.CallOption) (*CreateBookingResponse, error) {
|
||||
out := new(CreateBookingResponse)
|
||||
err := c.cc.Invoke(ctx, SolidarityService_CreateBooking_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *solidarityServiceClient) UpdateBooking(ctx context.Context, in *UpdateBookingRequest, opts ...grpc.CallOption) (*UpdateBookingResponse, error) {
|
||||
out := new(UpdateBookingResponse)
|
||||
err := c.cc.Invoke(ctx, SolidarityService_UpdateBooking_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *solidarityServiceClient) GetBooking(ctx context.Context, in *GetBookingRequest, opts ...grpc.CallOption) (*GetBookingResponse, error) {
|
||||
out := new(GetBookingResponse)
|
||||
err := c.cc.Invoke(ctx, SolidarityService_GetBooking_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *solidarityServiceClient) GetBookingsByStatus(ctx context.Context, in *GetBookingsByStatusRequest, opts ...grpc.CallOption) (*GetBookingsByStatusResponse, error) {
|
||||
out := new(GetBookingsByStatusResponse)
|
||||
err := c.cc.Invoke(ctx, SolidarityService_GetBookingsByStatus_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *solidarityServiceClient) DriverJourneys(ctx context.Context, in *DriverJourneysRequest, opts ...grpc.CallOption) (*DriverJourneysResponse, error) {
|
||||
out := new(DriverJourneysResponse)
|
||||
err := c.cc.Invoke(ctx, SolidarityService_DriverJourneys_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *solidarityServiceClient) SetPassengerTrip(ctx context.Context, in *PassengerTripRequest, opts ...grpc.CallOption) (*PassengerTripResponse, error) {
|
||||
out := new(PassengerTripResponse)
|
||||
err := c.cc.Invoke(ctx, SolidarityService_SetPassengerTrip_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// SolidarityServiceServer is the server API for SolidarityService service.
|
||||
// All implementations must embed UnimplementedSolidarityServiceServer
|
||||
// for forward compatibility
|
||||
type SolidarityServiceServer interface {
|
||||
SetDriverRegularAvailabilities(context.Context, *DriverRegularAvailabilities) (*DriverAvailabilitiesResponse, error)
|
||||
SetDriverPunctualAvailabilities(context.Context, *DriverPunctualAvailabilities) (*DriverAvailabilitiesResponse, error)
|
||||
CreateBooking(context.Context, *CreateBookingRequest) (*CreateBookingResponse, error)
|
||||
UpdateBooking(context.Context, *UpdateBookingRequest) (*UpdateBookingResponse, error)
|
||||
GetBooking(context.Context, *GetBookingRequest) (*GetBookingResponse, error)
|
||||
GetBookingsByStatus(context.Context, *GetBookingsByStatusRequest) (*GetBookingsByStatusResponse, error)
|
||||
DriverJourneys(context.Context, *DriverJourneysRequest) (*DriverJourneysResponse, error)
|
||||
SetPassengerTrip(context.Context, *PassengerTripRequest) (*PassengerTripResponse, error)
|
||||
mustEmbedUnimplementedSolidarityServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedSolidarityServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedSolidarityServiceServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedSolidarityServiceServer) SetDriverRegularAvailabilities(context.Context, *DriverRegularAvailabilities) (*DriverAvailabilitiesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SetDriverRegularAvailabilities not implemented")
|
||||
}
|
||||
func (UnimplementedSolidarityServiceServer) SetDriverPunctualAvailabilities(context.Context, *DriverPunctualAvailabilities) (*DriverAvailabilitiesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SetDriverPunctualAvailabilities not implemented")
|
||||
}
|
||||
func (UnimplementedSolidarityServiceServer) CreateBooking(context.Context, *CreateBookingRequest) (*CreateBookingResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateBooking not implemented")
|
||||
}
|
||||
func (UnimplementedSolidarityServiceServer) UpdateBooking(context.Context, *UpdateBookingRequest) (*UpdateBookingResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateBooking not implemented")
|
||||
}
|
||||
func (UnimplementedSolidarityServiceServer) GetBooking(context.Context, *GetBookingRequest) (*GetBookingResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetBooking not implemented")
|
||||
}
|
||||
func (UnimplementedSolidarityServiceServer) GetBookingsByStatus(context.Context, *GetBookingsByStatusRequest) (*GetBookingsByStatusResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetBookingsByStatus not implemented")
|
||||
}
|
||||
func (UnimplementedSolidarityServiceServer) DriverJourneys(context.Context, *DriverJourneysRequest) (*DriverJourneysResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DriverJourneys not implemented")
|
||||
}
|
||||
func (UnimplementedSolidarityServiceServer) SetPassengerTrip(context.Context, *PassengerTripRequest) (*PassengerTripResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SetPassengerTrip not implemented")
|
||||
}
|
||||
func (UnimplementedSolidarityServiceServer) mustEmbedUnimplementedSolidarityServiceServer() {}
|
||||
|
||||
// UnsafeSolidarityServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to SolidarityServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeSolidarityServiceServer interface {
|
||||
mustEmbedUnimplementedSolidarityServiceServer()
|
||||
}
|
||||
|
||||
func RegisterSolidarityServiceServer(s grpc.ServiceRegistrar, srv SolidarityServiceServer) {
|
||||
s.RegisterService(&SolidarityService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _SolidarityService_SetDriverRegularAvailabilities_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DriverRegularAvailabilities)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SolidarityServiceServer).SetDriverRegularAvailabilities(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SolidarityService_SetDriverRegularAvailabilities_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SolidarityServiceServer).SetDriverRegularAvailabilities(ctx, req.(*DriverRegularAvailabilities))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SolidarityService_SetDriverPunctualAvailabilities_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DriverPunctualAvailabilities)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SolidarityServiceServer).SetDriverPunctualAvailabilities(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SolidarityService_SetDriverPunctualAvailabilities_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SolidarityServiceServer).SetDriverPunctualAvailabilities(ctx, req.(*DriverPunctualAvailabilities))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SolidarityService_CreateBooking_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateBookingRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SolidarityServiceServer).CreateBooking(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SolidarityService_CreateBooking_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SolidarityServiceServer).CreateBooking(ctx, req.(*CreateBookingRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SolidarityService_UpdateBooking_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateBookingRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SolidarityServiceServer).UpdateBooking(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SolidarityService_UpdateBooking_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SolidarityServiceServer).UpdateBooking(ctx, req.(*UpdateBookingRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SolidarityService_GetBooking_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetBookingRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SolidarityServiceServer).GetBooking(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SolidarityService_GetBooking_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SolidarityServiceServer).GetBooking(ctx, req.(*GetBookingRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SolidarityService_GetBookingsByStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetBookingsByStatusRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SolidarityServiceServer).GetBookingsByStatus(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SolidarityService_GetBookingsByStatus_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SolidarityServiceServer).GetBookingsByStatus(ctx, req.(*GetBookingsByStatusRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SolidarityService_DriverJourneys_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DriverJourneysRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SolidarityServiceServer).DriverJourneys(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SolidarityService_DriverJourneys_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SolidarityServiceServer).DriverJourneys(ctx, req.(*DriverJourneysRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SolidarityService_SetPassengerTrip_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(PassengerTripRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SolidarityServiceServer).SetPassengerTrip(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SolidarityService_SetPassengerTrip_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SolidarityServiceServer).SetPassengerTrip(ctx, req.(*PassengerTripRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// SolidarityService_ServiceDesc is the grpc.ServiceDesc for SolidarityService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var SolidarityService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "SolidarityService",
|
||||
HandlerType: (*SolidarityServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "SetDriverRegularAvailabilities",
|
||||
Handler: _SolidarityService_SetDriverRegularAvailabilities_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SetDriverPunctualAvailabilities",
|
||||
Handler: _SolidarityService_SetDriverPunctualAvailabilities_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateBooking",
|
||||
Handler: _SolidarityService_CreateBooking_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateBooking",
|
||||
Handler: _SolidarityService_UpdateBooking_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetBooking",
|
||||
Handler: _SolidarityService_GetBooking_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetBookingsByStatus",
|
||||
Handler: _SolidarityService_GetBookingsByStatus_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DriverJourneys",
|
||||
Handler: _SolidarityService_DriverJourneys_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SetPassengerTrip",
|
||||
Handler: _SolidarityService_SetPassengerTrip_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "solidarity-api.proto",
|
||||
}
|
||||
35
servers/grpcapi/server/account.go
Normal file
35
servers/grpcapi/server/account.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package grpcserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
grpcproto "git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/proto"
|
||||
"github.com/rs/zerolog/log"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (s SilvermobiGRPCService) GetAccountInfo(ctx context.Context, req *grpcproto.AccountInfoRequest) (res *grpcproto.AccountInfoResponse, err error) {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing metadata")
|
||||
}
|
||||
authHeader, ok := md["authorization"]
|
||||
if !ok || len(authHeader) == 0 {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing authorization header")
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
account, err := s.Handler.GetAccountInfos(context.Background(), id)
|
||||
log.Info().
|
||||
Str("ID", account.ID).
|
||||
Msg("GetAccountInfo")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &grpcproto.AccountInfoResponse{
|
||||
FirstName: account.FirstName,
|
||||
LastName: account.LastName,
|
||||
}, nil
|
||||
}
|
||||
46
servers/grpcapi/server/firebase.go
Normal file
46
servers/grpcapi/server/firebase.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package grpcserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
grpcproto "git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/proto"
|
||||
"github.com/rs/zerolog/log"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (s SilvermobiGRPCService) PutFirebaseToken(ctx context.Context, req *grpcproto.FirebaseTokenRequest) (resp *grpcproto.FirebaseTokenResponse, err error) {
|
||||
|
||||
if req.Token == "" || req.DevicePlatform == "" {
|
||||
return &grpcproto.FirebaseTokenResponse{
|
||||
Result: false,
|
||||
}, nil
|
||||
}
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return &grpcproto.FirebaseTokenResponse{
|
||||
Result: false,
|
||||
}, status.Errorf(codes.Unauthenticated, "Missing metadata")
|
||||
}
|
||||
authHeader, ok := md["authorization"]
|
||||
if !ok || len(authHeader) == 0 {
|
||||
return &grpcproto.FirebaseTokenResponse{
|
||||
Result: false,
|
||||
}, status.Errorf(codes.Unauthenticated, "Missing authorization header")
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
log.Info().
|
||||
Str("User ID", id).
|
||||
Msg("PutFirebaseToken")
|
||||
err = s.Handler.PutFirebase(context.Background(), id, req.Token, req.DevicePlatform)
|
||||
if err != nil {
|
||||
return &grpcproto.FirebaseTokenResponse{
|
||||
Result: false,
|
||||
}, status.Errorf(codes.Unknown, "Database error")
|
||||
}
|
||||
return &grpcproto.FirebaseTokenResponse{
|
||||
Result: true,
|
||||
}, nil
|
||||
}
|
||||
99
servers/grpcapi/server/geo.go
Normal file
99
servers/grpcapi/server/geo.go
Normal file
@@ -0,0 +1,99 @@
|
||||
package grpcserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
grpcproto "git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/proto"
|
||||
"github.com/google/uuid"
|
||||
"github.com/paulmach/orb/geojson"
|
||||
"github.com/rs/zerolog/log"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"io"
|
||||
)
|
||||
|
||||
func (s SilvermobiGRPCService) GeoAutocomplete(ctx context.Context, in *grpcproto.GeoAutocompleteRequest) (resp *grpcproto.GeoAutocompleteResponse, err error) {
|
||||
log.Info().
|
||||
Str("text", in.Text).
|
||||
Msg("GeoAutocompleteRequest")
|
||||
requestid := uuid.NewString()
|
||||
log.Debug().Str("requestid", requestid).Msg("GRPC GeoAutocomplete start")
|
||||
|
||||
if err == io.EOF {
|
||||
log.Debug().Str("requestid", requestid).Msg("GRPC GeoAutocomplete EOF")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Error().Str("requestid", requestid).Err(err).Msg("GRPC GeoAutocomplete other error")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
results, err := s.Handler.GeoAutocomplete(in.Text, in.Lat, in.Lon)
|
||||
if err != nil {
|
||||
log.Error().Str("requestid", requestid).Err(err).Msg("GRPC GeoAutocomplete geocoding error")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rawfc, err := results.MarshalJSON()
|
||||
if err != nil {
|
||||
log.Error().Str("requestid", requestid).Err(err).Msg("GRPC GeoAutocomplete protocol buffer conversion error")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp = &grpcproto.GeoAutocompleteResponse{
|
||||
FeatureCollection: &grpcproto.GeoAutocompleteResponse_FeatureCollectionRaw{
|
||||
FeatureCollectionRaw: string(rawfc),
|
||||
},
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
||||
}
|
||||
|
||||
func (s SilvermobiGRPCService) GeoRoute(ctx context.Context, req *grpcproto.GeoRouteRequest) (*grpcproto.GeoRouteResponse, error) {
|
||||
locations_raw, ok := req.Locations.(*grpcproto.GeoRouteRequest_LocationsRaw)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "could not read departure")
|
||||
}
|
||||
|
||||
locations, err := geojson.UnmarshalFeatureCollection([]byte(locations_raw.LocationsRaw))
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
route, err := s.Handler.GeoRoute(*locations)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &grpcproto.GeoRouteResponse{
|
||||
Polyline: route.Polyline.String(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s SilvermobiGRPCService) GeoRouteWithReturn(ctx context.Context, req *grpcproto.GeoRouteWithReturnRequest) (*grpcproto.GeoRouteWithReturnResponse, error) {
|
||||
locations_raw, ok := req.Locations.(*grpcproto.GeoRouteWithReturnRequest_LocationsRaw)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "could not read departure")
|
||||
}
|
||||
|
||||
locations, err := geojson.UnmarshalFeatureCollection([]byte(locations_raw.LocationsRaw))
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
route, err := s.Handler.GeoRoute(*locations)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return_route, err := s.Handler.GeoReturnRoute(*locations)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &grpcproto.GeoRouteWithReturnResponse{
|
||||
Polyline: route.Polyline.String(),
|
||||
ReturnPolyline: return_route.Polyline.String(),
|
||||
}, nil
|
||||
}
|
||||
@@ -4,7 +4,9 @@ import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
grpcproto "git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/proto"
|
||||
"github.com/rs/zerolog/log"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -24,6 +26,9 @@ func (s SilvermobiGRPCService) SetPhoneNumber(ctx context.Context, req *grpcprot
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
log.Info().
|
||||
Str("User ID", id).
|
||||
Msg("SetPhoneNumber")
|
||||
if err = s.Handler.UpdatePhoneNumber(
|
||||
context.Background(),
|
||||
id,
|
||||
@@ -40,13 +45,15 @@ func (s SilvermobiGRPCService) VerifyPhoneNumber(ctx context.Context, req *grpcp
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing metadata")
|
||||
}
|
||||
|
||||
authHeader, ok := md["authorization"]
|
||||
if !ok || len(authHeader) == 0 {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing authorization header")
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
log.Info().
|
||||
Str("User ID", id).
|
||||
Msg("VerifyPhoneNumber")
|
||||
if err = s.Handler.VerifyPhoneNumber(
|
||||
context.Background(),
|
||||
id,
|
||||
@@ -71,6 +78,9 @@ func (s SilvermobiGRPCService) SetBirthDate(ctx context.Context, req *grpcproto.
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
log.Info().
|
||||
Str("User ID", id).
|
||||
Msg("SetBirthDate")
|
||||
birthdate := time.Unix(req.Birthdate.Seconds, int64(req.Birthdate.Nanos)).UTC()
|
||||
birthdateString := birthdate.Format("2006-01-02T15:04:05Z")
|
||||
if err = s.Handler.UpdateBirthDate(ctx, id, birthdateString); err != nil {
|
||||
@@ -93,6 +103,9 @@ func (s SilvermobiGRPCService) SetAccountType(ctx context.Context, req *grpcprot
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
log.Info().
|
||||
Str("User ID", id).
|
||||
Msg("SetAccountType")
|
||||
if req.GetType() != grpcproto.AccountTypeRequest_PASSENGER && req.GetType() != grpcproto.AccountTypeRequest_DRIVER {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "Type should be PASSENGER or DRIVER")
|
||||
}
|
||||
@@ -116,6 +129,9 @@ func (s SilvermobiGRPCService) GetAccountType(ctx context.Context, req *grpcprot
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
log.Info().
|
||||
Str("User ID", id).
|
||||
Msg("GetAccountType")
|
||||
if req.Request == nil || !*req.Request {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "request arg should be true")
|
||||
}
|
||||
@@ -146,13 +162,13 @@ func (s SilvermobiGRPCService) GetValidation(ctx context.Context, req *grpcproto
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing metadata")
|
||||
}
|
||||
|
||||
authHeader, ok := md["authorization"]
|
||||
if !ok || len(authHeader) == 0 {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing authorization header")
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
fmt.Println(id)
|
||||
phone_validation, birth_validation, type_validation, err := s.Handler.CheckValidation(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -2,6 +2,7 @@ package grpcserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.coopgo.io/coopgo-apps/silvermobi/handler"
|
||||
grpcproto "git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/proto"
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
@@ -28,6 +29,9 @@ func NoAuth(method string) bool {
|
||||
"/SilvermobiGRPC/UpdatePassword",
|
||||
"/SilvermobiGRPC/AuthRegister",
|
||||
"/SilvermobiGRPC/AuthLogin",
|
||||
"/SilvermobiGRPC/GeoAutocomplete",
|
||||
"/SilvermobiGRPC/GeoRouteWithReturn",
|
||||
"/SilvermobiGRPC/GeoRoute",
|
||||
}
|
||||
|
||||
for _, m := range noAuthMethods {
|
||||
@@ -53,6 +57,7 @@ func UnaryAuthServerInterceptor(authFunc grpc_auth.AuthFunc) grpc.UnaryServerInt
|
||||
return handler(newCtx, req)
|
||||
}
|
||||
}
|
||||
|
||||
func StreamAuthServerInterceptor(authFunc grpc_auth.AuthFunc) grpc.StreamServerInterceptor {
|
||||
return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
if NoAuth(info.FullMethod) {
|
||||
@@ -78,6 +83,28 @@ type SilvermobiGRPCService struct {
|
||||
grpcproto.UnimplementedSilvermobiGRPCServer
|
||||
}
|
||||
|
||||
type SolidarityService struct {
|
||||
Config *viper.Viper
|
||||
Handler *handler.SilvermobiHandler
|
||||
SolidarityClient grpcproto.SolidarityServiceClient
|
||||
grpcproto.UnimplementedSolidarityServiceServer // Add this client
|
||||
}
|
||||
|
||||
func NewSolidarityService(cfg *viper.Viper, handler *handler.SilvermobiHandler) SolidarityService {
|
||||
solidarityServiceAddress := cfg.GetString("solidarity_service.address")
|
||||
conn, err := grpc.Dial(solidarityServiceAddress, grpc.WithInsecure())
|
||||
if err != nil {
|
||||
log.Fatal().Err(err)
|
||||
}
|
||||
|
||||
solidarityClient := grpcproto.NewSolidarityServiceClient(conn)
|
||||
return SolidarityService{
|
||||
Config: cfg,
|
||||
Handler: handler,
|
||||
SolidarityClient: solidarityClient,
|
||||
}
|
||||
}
|
||||
|
||||
func NewSilvermobiGRPCService(cfg *viper.Viper, handler *handler.SilvermobiHandler) SilvermobiGRPCService {
|
||||
return SilvermobiGRPCService{
|
||||
Config: cfg,
|
||||
@@ -87,7 +114,7 @@ func NewSilvermobiGRPCService(cfg *viper.Viper, handler *handler.SilvermobiHandl
|
||||
|
||||
func Run(done chan error, cfg *viper.Viper, handler *handler.SilvermobiHandler) {
|
||||
var (
|
||||
address = "0.0.0.0:" + cfg.GetString("services.external.grpc.port")
|
||||
address = cfg.GetString("services.external.grpc.ip") + ":" + cfg.GetString("services.external.grpc.port")
|
||||
jwt_secret = cfg.GetString("identification.local.jwt_secret")
|
||||
)
|
||||
|
||||
@@ -104,8 +131,11 @@ func Run(done chan error, cfg *viper.Viper, handler *handler.SilvermobiHandler)
|
||||
)),
|
||||
)
|
||||
|
||||
service := NewSilvermobiGRPCService(cfg, handler)
|
||||
grpcproto.RegisterSilvermobiGRPCServer(server, service)
|
||||
solidarity_service := NewSolidarityService(cfg, handler)
|
||||
|
||||
silvermobi_service := NewSilvermobiGRPCService(cfg, handler)
|
||||
grpcproto.RegisterSilvermobiGRPCServer(server, silvermobi_service)
|
||||
grpcproto.RegisterSolidarityServiceServer(server, &solidarity_service)
|
||||
l, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err)
|
||||
@@ -128,6 +158,7 @@ func GRPCAuthFunc(jwtKey string) grpc_auth.AuthFunc {
|
||||
return []byte(jwtKey), nil
|
||||
})
|
||||
if err != nil || !token.Valid {
|
||||
fmt.Println(err)
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Invalid or expired token")
|
||||
}
|
||||
ctx = context.WithValue(ctx, contextKeyUser, claims["sub"].(string))
|
||||
|
||||
77
servers/grpcapi/server/solidarity-service.go
Normal file
77
servers/grpcapi/server/solidarity-service.go
Normal file
@@ -0,0 +1,77 @@
|
||||
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
|
||||
}
|
||||
|
||||
func (s *SolidarityService) CreateBooking(ctx context.Context, req *proto.CreateBookingRequest) (resp *proto.CreateBookingResponse, err error) {
|
||||
log.Info().
|
||||
Str("Booking ID", req.Booking.Id).
|
||||
Msg("CreateBooking")
|
||||
resp, err = s.SolidarityClient.CreateBooking(ctx, req)
|
||||
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
|
||||
}
|
||||
|
||||
func (s *SolidarityService) UpdateBooking(ctx context.Context, req *proto.UpdateBookingRequest) (resp *proto.UpdateBookingResponse, err error) {
|
||||
log.Info().
|
||||
Str("Booking ID", req.BookingId).
|
||||
Msg("UpdateBooking")
|
||||
resp, err = s.SolidarityClient.UpdateBooking(ctx, req)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (s *SolidarityService) GetBooking(ctx context.Context, req *proto.GetBookingRequest) (resp *proto.GetBookingResponse, err error) {
|
||||
log.Info().
|
||||
Str("Booking ID", req.BookingId).
|
||||
Msg("GetBooking")
|
||||
resp, err = s.SolidarityClient.GetBooking(ctx, req)
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user