Skip to content

Commit

Permalink
remove nil headers from examples
Browse files Browse the repository at this point in the history
  • Loading branch information
VjeraTurk committed Jan 13, 2025
1 parent de5d03b commit 31539d5
Showing 1 changed file with 100 additions and 77 deletions.
177 changes: 100 additions & 77 deletions examples/rpc/partner-plugin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ func (p *partnerPlugin) Validation(ctx context.Context, _ *bookv2.ValidationRequ
log.Printf("Responding to request: %s (Validation)", md.RequestID)

response := bookv2.ValidationResponse{
Header: nil,
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
},
ValidationId: &typesv1.UUID{Value: md.RequestID},
ValidationObject: nil,
PriceDetail: &typesv2.PriceDetail{
Expand Down Expand Up @@ -106,7 +108,9 @@ func (p *partnerPlugin) ActivityProductInfo(ctx context.Context, request *activi
log.Printf("Responding to request: %s (ActivityProductInfo)", md.RequestID)

response := activityv2.ActivityProductInfoResponse{
Header: nil,
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
},
Activities: []*activityv2.ActivityExtendedInfo{
{
Activity: &activityv2.Activity{
Expand Down Expand Up @@ -282,7 +286,9 @@ func (p *partnerPlugin) ActivityProductList(ctx context.Context, _ *activityv2.A
log.Printf("Responding to request: %s (ActivityProductList)", md.RequestID)

response := activityv2.ActivityProductListResponse{
Header: nil,
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
},
Activities: []*activityv2.Activity{
{
Context: "ActivityTest", // context
Expand Down Expand Up @@ -319,7 +325,9 @@ func (p *partnerPlugin) ActivitySearch(ctx context.Context, _ *activityv2.Activi
log.Printf("Responding to request: %s (ActivitySearch)", md.RequestID)

response := activityv2.ActivitySearchResponse{
Header: nil,
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
},
Metadata: &typesv2.SearchResponseMetadata{SearchId: &typesv1.UUID{Value: md.RequestID}},
}
log.Printf("CMAccount %s received request from CMAccount %s", md.Recipient, md.Sender)
Expand Down Expand Up @@ -375,7 +383,9 @@ func (p *partnerPlugin) AccommodationSearch(ctx context.Context, _ *accommodatio
log.Printf("Responding to request: %s (AccommodationSearch)", md.RequestID)

response := accommodationv2.AccommodationSearchResponse{
Header: nil,
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
},
Metadata: &typesv2.SearchResponseMetadata{
SearchId: &typesv1.UUID{Value: md.RequestID},
},
Expand Down Expand Up @@ -472,7 +482,9 @@ func (p *partnerPlugin) Ping(ctx context.Context, request *pingv1.PingRequest) (
log.Printf("Responding to request: %s (Ping)", md.RequestID)

return &pingv1.PingResponse{
Header: nil,
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
},
PingMessage: fmt.Sprintf("Ping response to [%s] with request ID: %s", request.PingMessage, md.RequestID),
}, nil
}
Expand All @@ -488,7 +500,9 @@ func (p *partnerPlugin) TransportSearch(ctx context.Context, _ *transportv3.Tran

// TODO: finish example response
response := transportv3.TransportSearchResponse{
Header: nil,
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
},
Metadata: &typesv2.SearchResponseMetadata{SearchId: &typesv1.UUID{Value: md.RequestID}},
Results: []*transportv3.TransportSearchResult{{
ResultId: 0,
Expand Down Expand Up @@ -562,7 +576,9 @@ func (p *partnerPlugin) TransportProductList(ctx context.Context, _ *transportv3
log.Printf("Responding to request: %s (TransportProductList)", md.RequestID)

response := transportv3.TransportProductListResponse{
Header: nil,
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
},
Trips: []*transportv3.TripBasic{{
SupplierCode: &typesv2.SupplierProductCode{
SupplierCode: "XY",
Expand Down Expand Up @@ -608,91 +624,92 @@ func (p *partnerPlugin) TransportProductList(ctx context.Context, _ *transportv3
SupplierCode: "XY",
SupplierNumber: 456,
},
Segments: []*transportv3.Segment{{
SegmentId: "SEG456",
ProviderCode: "I2",
RetailerCode: "IB",
ProductCode: &typesv2.ProductCode{
Code: "XY",
Number: 456,
Type: typesv2.ProductCodeType_PRODUCT_CODE_TYPE_UNSPECIFIED,
},
SupplierCode: &typesv2.SupplierProductCode{
SupplierCode: "XY",
SupplierNumber: 456,
},
Departure: &transportv3.TransitEvent{
DateTime: timestamppb.New(time.Date(2024, 9, 27, 23, 55, 0, 0, time.UTC)),
LocationCode: &typesv2.LocationCode{
Code: "SIN",
Type: typesv2.LocationCodeType_LOCATION_CODE_TYPE_ICAO_CODE,
Segments: []*transportv3.Segment{
{
SegmentId: "SEG456",
ProviderCode: "I2",
RetailerCode: "IB",
ProductCode: &typesv2.ProductCode{
Code: "XY",
Number: 456,
Type: typesv2.ProductCodeType_PRODUCT_CODE_TYPE_UNSPECIFIED,
},
},
Arrival: &transportv3.TransitEvent{
DateTime: timestamppb.New(time.Date(2024, 9, 28, 9, 30, 0, 0, time.UTC)),
LocationCode: &typesv2.LocationCode{
Code: "MEL",
Type: typesv2.LocationCodeType_LOCATION_CODE_TYPE_ICAO_CODE,
SupplierCode: &typesv2.SupplierProductCode{
SupplierCode: "XY",
SupplierNumber: 456,
},
Departure: &transportv3.TransitEvent{
DateTime: timestamppb.New(time.Date(2024, 9, 27, 23, 55, 0, 0, time.UTC)),
LocationCode: &typesv2.LocationCode{
Code: "SIN",
Type: typesv2.LocationCodeType_LOCATION_CODE_TYPE_ICAO_CODE,
},
},
Arrival: &transportv3.TransitEvent{
DateTime: timestamppb.New(time.Date(2024, 9, 28, 9, 30, 0, 0, time.UTC)),
LocationCode: &typesv2.LocationCode{
Code: "MEL",
Type: typesv2.LocationCodeType_LOCATION_CODE_TYPE_ICAO_CODE,
},
},
SegmentDuration: &typesv1.Duration{
Minutes: 455,
},
SegmentDistance: &typesv1.Length{
Value: 6024,
Unit: typesv1.LengthUnit_LENGTH_UNIT_KILOMETER,
},
},
SegmentDuration: &typesv1.Duration{
Minutes: 455,
},
SegmentDistance: &typesv1.Length{
Value: 6024,
Unit: typesv1.LengthUnit_LENGTH_UNIT_KILOMETER,
},
},
},
}, {
SupplierCode: &typesv2.SupplierProductCode{
SupplierCode: "XY",
SupplierNumber: 789,
},
Segments: []*transportv3.Segment{{
SegmentId: "SEG789",
ProviderCode: "DB",
RetailerCode: "NS",
SubSupplierCode: "SNCF",
ProductCode: &typesv2.ProductCode{
Code: "XY",
Number: 789,
Type: typesv2.ProductCodeType_PRODUCT_CODE_TYPE_UNSPECIFIED,
},
SupplierCode: &typesv2.SupplierProductCode{
SupplierCode: "XY",
SupplierNumber: 789,
},
Departure: &transportv3.TransitEvent{
DateTime: timestamppb.New(time.Date(2024, 9, 27, 15, 30, 0, 0, time.UTC)),
LocationCode: &typesv2.LocationCode{
Code: "PAR",
Type: typesv2.LocationCodeType_LOCATION_CODE_TYPE_UNSPECIFIED,
Segments: []*transportv3.Segment{
{
SegmentId: "SEG789",
ProviderCode: "DB",
RetailerCode: "NS",
SubSupplierCode: "SNCF",
ProductCode: &typesv2.ProductCode{
Code: "XY",
Number: 789,
Type: typesv2.ProductCodeType_PRODUCT_CODE_TYPE_UNSPECIFIED,
},
},
Arrival: &transportv3.TransitEvent{
DateTime: timestamppb.New(time.Date(2024, 9, 28, 16, 47, 0, 0, time.UTC)),
LocationCode: &typesv2.LocationCode{
Code: "LON",
Type: typesv2.LocationCodeType_LOCATION_CODE_TYPE_UNSPECIFIED,
SupplierCode: &typesv2.SupplierProductCode{
SupplierCode: "XY",
SupplierNumber: 789,
},
Departure: &transportv3.TransitEvent{
DateTime: timestamppb.New(time.Date(2024, 9, 27, 15, 30, 0, 0, time.UTC)),
LocationCode: &typesv2.LocationCode{
Code: "PAR",
Type: typesv2.LocationCodeType_LOCATION_CODE_TYPE_UNSPECIFIED,
},
},
Arrival: &transportv3.TransitEvent{
DateTime: timestamppb.New(time.Date(2024, 9, 28, 16, 47, 0, 0, time.UTC)),
LocationCode: &typesv2.LocationCode{
Code: "LON",
Type: typesv2.LocationCodeType_LOCATION_CODE_TYPE_UNSPECIFIED,
},
},
SegmentDuration: &typesv1.Duration{
Minutes: 137,
},
SegmentDistance: &typesv1.Length{
Value: 495,
Unit: typesv1.LengthUnit_LENGTH_UNIT_KILOMETER,
},
},
SegmentDuration: &typesv1.Duration{
Minutes: 137,
},
SegmentDistance: &typesv1.Length{
Value: 495,
Unit: typesv1.LengthUnit_LENGTH_UNIT_KILOMETER,
},
},
},
}},
}
log.Printf("CMAccount %s received request from CMAccount %s", md.Recipient, md.Sender)

grpc.SendHeader(ctx, md.ToGrpcMD())
return &response, nil

}

func (p *partnerPlugin) SeatMap(ctx context.Context, request *seat_mapv2.SeatMapRequest) (*seat_mapv2.SeatMapResponse, error) {
Expand All @@ -705,7 +722,9 @@ func (p *partnerPlugin) SeatMap(ctx context.Context, request *seat_mapv2.SeatMap
log.Printf("Responding to request: %s (SeatMap)", md.RequestID)

response := seat_mapv2.SeatMapResponse{
Header: nil,
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
},
SeatMap: &typesv2.SeatMap{
Id: md.RequestID,
Sections: []*typesv2.Section{
Expand Down Expand Up @@ -878,7 +897,9 @@ func (p *partnerPlugin) SeatMapAvailability(ctx context.Context, request *seat_m
log.Printf("Responding to request: %s (SeatMapAvailability)", md.RequestID)

response := seat_mapv2.SeatMapAvailabilityResponse{
Header: nil,
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
},
SeatMap: &typesv2.SeatMapInventory{
Id: "123ST",
Sections: []*typesv2.SectionInventory{
Expand Down Expand Up @@ -914,7 +935,9 @@ func (p *partnerPlugin) CountryEntryRequirements(ctx context.Context, request *i
log.Printf("Responding to request: %s (CountryEntryRequirements)", md.RequestID)

response := infov2.CountryEntryRequirementsResponse{
Header: nil,
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_SUCCESS,
},
Categories: []*infov2.CountryEntryRequirementCategory{{
Key: "entry",
Names: []*typesv1.LocalizedString{{
Expand Down

0 comments on commit 31539d5

Please sign in to comment.