Skip to content

Commit

Permalink
seat_mapv3 example
Browse files Browse the repository at this point in the history
  • Loading branch information
VjeraTurk committed Jan 14, 2025
1 parent 0206855 commit 0424d35
Showing 1 changed file with 46 additions and 44 deletions.
90 changes: 46 additions & 44 deletions examples/rpc/partner-plugin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import (
"buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/notification/v1/notificationv1grpc"
"buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/partner/v2/partnerv2grpc"
"buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/ping/v1/pingv1grpc"
"buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/seat_map/v2/seat_mapv2grpc"
"buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/seat_map/v3/seat_mapv3grpc"

"buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/transport/v2/transportv2grpc"
"buf.build/gen/go/chain4travel/camino-messenger-protocol/grpc/go/cmp/services/transport/v3/transportv3grpc"
accommodationv2 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/accommodation/v2"
Expand All @@ -35,7 +36,7 @@ import (
notificationv1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/notification/v1"
partnerv2 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/partner/v2"
pingv1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/ping/v1"
seat_mapv2 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/seat_map/v2"
seat_mapv3 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/seat_map/v3"
transportv3 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/services/transport/v3"
typesv1 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/types/v1"
typesv2 "buf.build/gen/go/chain4travel/camino-messenger-protocol/protocolbuffers/go/cmp/types/v2"
Expand All @@ -61,8 +62,8 @@ type partnerPlugin struct {
accommodationv3grpc.AccommodationSearchServiceServer
partnerv2grpc.GetPartnerConfigurationServiceServer
transportv2grpc.TransportSearchServiceServer
seat_mapv2grpc.SeatMapServiceServer
seat_mapv2grpc.SeatMapAvailabilityServiceServer
seat_mapv3grpc.SeatMapServiceServer
seat_mapv3grpc.SeatMapAvailabilityServiceServer
infov2grpc.CountryEntryRequirementsServiceServer
activityv3grpc.ActivityProductInfoServiceServer
notificationv1grpc.NotificationServiceServer
Expand Down Expand Up @@ -759,7 +760,7 @@ func (p *partnerPlugin) TransportProductList(ctx context.Context, _ *transportv3
return &response, nil
}

func (p *partnerPlugin) SeatMap(ctx context.Context, request *seat_mapv2.SeatMapRequest) (*seat_mapv2.SeatMapResponse, error) {
func (p *partnerPlugin) SeatMap(ctx context.Context, request *seat_mapv3.SeatMapRequest) (*seat_mapv3.SeatMapResponse, error) {
md := metadata.Metadata{}
err := md.ExtractMetadata(ctx)
if err != nil {
Expand All @@ -768,13 +769,13 @@ func (p *partnerPlugin) SeatMap(ctx context.Context, request *seat_mapv2.SeatMap
md.Stamp(fmt.Sprintf("%s-%s", "ext-system", "response"))
log.Printf("Responding to request: %s (SeatMap)", md.RequestID)

response := seat_mapv2.SeatMapResponse{
response := seat_mapv3.SeatMapResponse{
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
},
SeatMap: &typesv2.SeatMap{
SeatMap: &typesv3.SeatMap{
Id: md.RequestID,
Sections: []*typesv2.Section{
Sections: []*typesv3.Section{
{
Id: "123ST",
Names: []*typesv1.LocalizedString{
Expand All @@ -787,43 +788,43 @@ func (p *partnerPlugin) SeatMap(ctx context.Context, request *seat_mapv2.SeatMap
Text: "Nordtribüne",
},
},
SeatInfo: &typesv2.Section_SeatList{
SeatList: &typesv2.SeatList{
Seats: []*typesv2.Seat{
SeatInfo: &typesv3.Section_SeatList{
SeatList: &typesv3.SeatList{
Seats: []*typesv3.Seat{
{
Id: "1A",
Location: &typesv2.SeatLocation{
Location: &typesv2.SeatLocation_Vector{
Vector: &typesv2.VectorSeatLocation{
Location: &typesv3.SeatLocation{
Location: &typesv3.SeatLocation_Vector{
Vector: &typesv3.VectorSeatLocation{
Label: "section-North-Stand-26-34-2-label",
},
},
},
},
{
Id: "2A",
Location: &typesv2.SeatLocation{
Location: &typesv2.SeatLocation_Vector{
Vector: &typesv2.VectorSeatLocation{
Location: &typesv3.SeatLocation{
Location: &typesv3.SeatLocation_Vector{
Vector: &typesv3.VectorSeatLocation{
Label: "section-North-Stand-26-34-2-label",
},
},
},
Restrictions: []*typesv2.LocalizedSeatAttributeSet{
Restrictions: []*typesv3.LocalizedSeatAttributeSet{
{
Language: typesv1.Language_LANGUAGE_EN,
SeatAttributes: []*typesv2.SeatAttribute{
SeatAttributes: []*typesv3.SeatAttribute{
{
Name: "Restricted Vision",
Description: "Seat behind a column",
},
},
},
},
Features: []*typesv2.LocalizedSeatAttributeSet{
Features: []*typesv3.LocalizedSeatAttributeSet{
{
Language: typesv1.Language_LANGUAGE_EN,
SeatAttributes: []*typesv2.SeatAttribute{
SeatAttributes: []*typesv3.SeatAttribute{
{
Name: "Discount",
Description: "Discount due to restricted vision up to 80%",
Expand All @@ -833,7 +834,7 @@ func (p *partnerPlugin) SeatMap(ctx context.Context, request *seat_mapv2.SeatMap
},
{
Language: typesv1.Language_LANGUAGE_DE,
SeatAttributes: []*typesv2.SeatAttribute{
SeatAttributes: []*typesv3.SeatAttribute{
{
Name: "Rabatt",
Description: "Hinter der Säule - bis zu 80% Rabatt",
Expand All @@ -846,11 +847,12 @@ func (p *partnerPlugin) SeatMap(ctx context.Context, request *seat_mapv2.SeatMap
},
},
},
Image: &typesv2.Image{
File: &typesv2.File{
Image: &typesv3.Image{
File: &typesv3.File{
Name: "String",
Url: "https://camino.network/static/images/6HibYS9gzR-1800.webp", // TODO: replace with an actual image
LastModified: timestamppb.New(time.Now()),
Description: "Image Description",
},
Width: 50,
Height: 50,
Expand All @@ -874,24 +876,24 @@ func (p *partnerPlugin) SeatMap(ctx context.Context, request *seat_mapv2.SeatMap
Language: typesv1.Language_LANGUAGE_DE,
Text: "Osttribüne",
}},
SeatInfo: &typesv2.Section_SeatList{
SeatList: &typesv2.SeatList{
Seats: []*typesv2.Seat{
SeatInfo: &typesv3.Section_SeatList{
SeatList: &typesv3.SeatList{
Seats: []*typesv3.Seat{
{
Id: "31F",
Location: &typesv2.SeatLocation{
Location: &typesv2.SeatLocation_Vector{
Vector: &typesv2.VectorSeatLocation{
Location: &typesv3.SeatLocation{
Location: &typesv3.SeatLocation_Vector{
Vector: &typesv3.VectorSeatLocation{
Label: "section-East-Stand-26-34-2-label",
},
},
},
},
{
Id: "32F",
Location: &typesv2.SeatLocation{
Location: &typesv2.SeatLocation_Vector{
Vector: &typesv2.VectorSeatLocation{
Location: &typesv3.SeatLocation{
Location: &typesv3.SeatLocation_Vector{
Vector: &typesv3.VectorSeatLocation{
Label: "section-East-Stand-26-34-2-label",
},
},
Expand All @@ -900,8 +902,8 @@ func (p *partnerPlugin) SeatMap(ctx context.Context, request *seat_mapv2.SeatMap
},
},
},
Image: &typesv2.Image{
File: &typesv2.File{
Image: &typesv3.Image{
File: &typesv3.File{
Name: "String",
Url: "https://camino.network/static/images/6HibYS9gzR-1800.webp",
LastModified: timestamppb.New(time.Now()),
Expand Down Expand Up @@ -934,7 +936,7 @@ func (p *partnerPlugin) SeatMap(ctx context.Context, request *seat_mapv2.SeatMap
return &response, nil
}

func (p *partnerPlugin) SeatMapAvailability(ctx context.Context, request *seat_mapv2.SeatMapAvailabilityRequest) (*seat_mapv2.SeatMapAvailabilityResponse, error) {
func (p *partnerPlugin) SeatMapAvailability(ctx context.Context, request *seat_mapv3.SeatMapAvailabilityRequest) (*seat_mapv3.SeatMapAvailabilityResponse, error) {
md := metadata.Metadata{}
err := md.ExtractMetadata(ctx)
if err != nil {
Expand All @@ -943,24 +945,24 @@ func (p *partnerPlugin) SeatMapAvailability(ctx context.Context, request *seat_m
md.Stamp(fmt.Sprintf("%s-%s", "ext-system", "response"))
log.Printf("Responding to request: %s (SeatMapAvailability)", md.RequestID)

response := seat_mapv2.SeatMapAvailabilityResponse{
response := seat_mapv3.SeatMapAvailabilityResponse{
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
},
SeatMap: &typesv2.SeatMapInventory{
SeatMap: &typesv3.SeatMapInventory{
Id: "123ST",
Sections: []*typesv2.SectionInventory{
Sections: []*typesv3.SectionInventory{
{
Id: "A",
SeatInfo: &typesv2.SectionInventory_SeatList{
SeatList: &typesv2.SeatInventory{
SeatInfo: &typesv3.SectionInventory_SeatList{
SeatList: &typesv3.SeatInventory{
Ids: []string{"1A", "1B"},
},
},
},
{
Id: "B",
SeatInfo: &typesv2.SectionInventory_SeatCount{SeatCount: &wrapperspb.Int32Value{Value: 32}},
SeatInfo: &typesv3.SectionInventory_SeatCount{SeatCount: &wrapperspb.Int32Value{Value: 32}},
},
},
},
Expand Down Expand Up @@ -1153,8 +1155,8 @@ func main() {
bookv2grpc.RegisterValidationServiceServer(grpcServer, &partnerPlugin{})
transportv3grpc.RegisterTransportSearchServiceServer(grpcServer, &partnerPlugin{})
transportv3grpc.RegisterTransportProductListServiceServer(grpcServer, &partnerPlugin{})
seat_mapv2grpc.RegisterSeatMapServiceServer(grpcServer, &partnerPlugin{})
seat_mapv2grpc.RegisterSeatMapAvailabilityServiceServer(grpcServer, &partnerPlugin{})
seat_mapv3grpc.RegisterSeatMapServiceServer(grpcServer, &partnerPlugin{})
seat_mapv3grpc.RegisterSeatMapAvailabilityServiceServer(grpcServer, &partnerPlugin{})
infov2grpc.RegisterCountryEntryRequirementsServiceServer(grpcServer, &partnerPlugin{})
notificationv1grpc.RegisterNotificationServiceServer(grpcServer, &partnerPlugin{})

Expand Down

0 comments on commit 0424d35

Please sign in to comment.