如何在 Bargain Finder Max 中对航班 segments/legs 进行分组?

How to group flight segments/legs in Bargain Finder Max?

我正在尝试使用 BargainFindermax API 搜索 Sabre 两地之间的航班。 API 为我提供了所有航班的列表。但是,与链接的航班没有直接关系。

例如,我搜索了 BLR > LCY 之间的航班。我得到的回复包括 AMS > LCYBLR > DELBLR > DELDEL > AMSAMS > LCY

的航班

据此,我可以构建以下路线BLR > DEL > AMS > LCY。但是 BLR > DELAMS > LCY.

有两个航班

我如何确定这些航班中哪些是相关的?

这是完整的 JSON 回复,

{
  "groupedItineraryResponse": {
    "version": "5.2.0",
    "messages": [
      {
        "severity": "Info",
        "type": "WORKERTHREAD",
        "code": "TRANSACTIONID",
        "text": "2074398531853061390"
      },
      {
        "severity": "Info",
        "type": "SERVER",
        "code": "ASE032LPSCIL9UM.IDM.SGDCCERT.SABRE.COM",
        "text": "27036"
      },
      {
        "severity": "Info",
        "type": "DRE",
        "code": "RULEID",
        "text": "17203"
      },
      {
        "severity": "Info",
        "type": "DEFAULT",
        "code": "RULEID",
        "text": "25238"
      }
    ],
    "statistics": {
      "itineraryCount": 2
    },
    "scheduleDescs": [
      {
        "id": 1,
        "frequency": "*MTWTFS",
        "stopCount": 0,
        "eTicketable": true,
        "totalMilesFlown": 257,
        "departure": {
          "airport": "AMS",
          "city": "AMS",
          "country": "NL",
          "time": "08:45:00+02:00"
        },
        "arrival": {
          "airport": "LCY",
          "city": "LON",
          "country": "GB",
          "time": "08:50:00+01:00"
        },
        "carrier": {
          "marketing": "KL",
          "marketingFlightNumber": 985,
          "operating": "KL",
          "operatingFlightNumber": 985,
          "codeShared": "/KLM CITYHOPPER",
          "equipment": {
            "code": "E90",
            "typeForFirstLeg": "N",
            "typeForLastLeg": "N"
          }
        }
      },
      {
        "id": 2,
        "trafficRestriction": "G",
        "frequency": "SMTWTFS",
        "stopCount": 0,
        "eTicketable": true,
        "totalMilesFlown": 1058,
        "departure": {
          "airport": "BLR",
          "city": "BLR",
          "country": "IN",
          "time": "19:50:00+05:30"
        },
        "arrival": {
          "airport": "DEL",
          "city": "DEL",
          "country": "IN",
          "time": "22:50:00+05:30",
          "terminal": "3"
        },
        "carrier": {
          "marketing": "KL",
          "marketingFlightNumber": 3798,
          "operating": "9W",
          "operatingFlightNumber": 812,
          "disclosure": "9W",
          "equipment": {
            "code": "73H",
            "typeForFirstLeg": "N",
            "typeForLastLeg": "N"
          }
        }
      },
      {
        "id": 3,
        "trafficRestriction": "G",
        "frequency": "SMTWTFS",
        "stopCount": 0,
        "eTicketable": true,
        "totalMilesFlown": 1058,
        "departure": {
          "airport": "BLR",
          "city": "BLR",
          "country": "IN",
          "time": "18:55:00+05:30"
        },
        "arrival": {
          "airport": "DEL",
          "city": "DEL",
          "country": "IN",
          "time": "22:00:00+05:30",
          "terminal": "3"
        },
        "carrier": {
          "marketing": "KL",
          "marketingFlightNumber": 3703,
          "operating": "9W",
          "operatingFlightNumber": 833,
          "disclosure": "9W",
          "equipment": {
            "code": "738",
            "typeForFirstLeg": "N",
            "typeForLastLeg": "N"
          }
        }
      },
      {
        "id": 4,
        "frequency": "*M**T**",
        "stopCount": 0,
        "eTicketable": true,
        "totalMilesFlown": 3961,
        "departure": {
          "airport": "DEL",
          "city": "DEL",
          "country": "IN",
          "time": "02:10:00+05:30",
          "terminal": "3"
        },
        "arrival": {
          "airport": "AMS",
          "city": "AMS",
          "country": "NL",
          "time": "07:40:00+02:00"
        },
        "carrier": {
          "marketing": "KL",
          "marketingFlightNumber": 3817,
          "operating": "9W",
          "operatingFlightNumber": 234,
          "disclosure": "9W",
          "equipment": {
            "code": "333",
            "typeForFirstLeg": "W",
            "typeForLastLeg": "W"
          }
        }
      },
      {
        "id": 5,
        "frequency": "*MTWTFS",
        "stopCount": 0,
        "eTicketable": true,
        "totalMilesFlown": 257,
        "departure": {
          "airport": "AMS",
          "city": "AMS",
          "country": "NL",
          "time": "09:25:00+02:00"
        },
        "arrival": {
          "airport": "LCY",
          "city": "LON",
          "country": "GB",
          "time": "09:30:00+01:00"
        },
        "carrier": {
          "marketing": "KL",
          "marketingFlightNumber": 987,
          "operating": "KL",
          "operatingFlightNumber": 987,
          "codeShared": "/KLM CITYHOPPER",
          "equipment": {
            "code": "E90",
            "typeForFirstLeg": "N",
            "typeForLastLeg": "N"
          }
        }
      }
    ],
    "taxDescs": [
      {
        "id": 1,
        "code": "YRI",
        "amount": 160,
        "currency": "USD",
        "description": "SERVICE FEE - CARRIER-IMPOSED MISC",
        "publishedAmount": 160,
        "publishedCurrency": "USD",
        "station": "DEL"
      },
      {
        "id": 2,
        "code": "YQI",
        "amount": 13.3,
        "currency": "USD",
        "description": "SERVICE FEE - INSURANCE",
        "publishedAmount": 925,
        "publishedCurrency": "INR",
        "station": "BLR"
      },
      {
        "id": 3,
        "code": "WO",
        "amount": 3.8,
        "currency": "USD",
        "description": "PASSENGER SERVICE FEE",
        "publishedAmount": 3.8,
        "publishedCurrency": "USD",
        "station": "BLR",
        "country": "IN"
      },
      {
        "id": 4,
        "code": "K38",
        "amount": 11.5,
        "currency": "USD",
        "description": "GOODS AND SERVICE TAX INTERIM DOMESTIC AND INTERNATIONAL",
        "publishedAmount": 799,
        "publishedCurrency": "INR",
        "station": "BLR",
        "country": "IN"
      },
      {
        "id": 5,
        "code": "CJ",
        "amount": 7.4,
        "currency": "USD",
        "description": "SECURITY SERVICE CHARGE",
        "publishedAmount": 6.5,
        "publishedCurrency": "EUR",
        "station": "AMS",
        "country": "NL"
      },
      {
        "id": 6,
        "code": "RN",
        "amount": 7.3,
        "currency": "USD",
        "description": "PASSENGER SERVICE CHARGE",
        "publishedAmount": 6.4,
        "publishedCurrency": "EUR",
        "station": "AMS",
        "country": "NL"
      },
      {
        "id": 7,
        "code": "IN",
        "amount": 5.2,
        "currency": "USD",
        "description": "USER DEVELOPMENT FEE DEPARTURES",
        "publishedAmount": 362,
        "publishedCurrency": "INR",
        "station": "BLR",
        "country": "IN"
      }
    ],
    "taxSummaryDescs": [
      {
        "id": 1,
        "code": "YRI",
        "amount": 160,
        "currency": "USD",
        "description": "SERVICE FEE - CARRIER-IMPOSED MISC",
        "publishedAmount": 160,
        "publishedCurrency": "USD",
        "station": "DEL"
      },
      {
        "id": 2,
        "code": "YQI",
        "amount": 13.3,
        "currency": "USD",
        "description": "SERVICE FEE - INSURANCE",
        "publishedAmount": 925,
        "publishedCurrency": "INR",
        "station": "BLR"
      },
      {
        "id": 3,
        "code": "WO",
        "amount": 3.8,
        "currency": "USD",
        "description": "PASSENGER SERVICE FEE",
        "publishedAmount": 3.8,
        "publishedCurrency": "USD",
        "station": "BLR",
        "country": "IN"
      },
      {
        "id": 4,
        "code": "K38",
        "amount": 11.5,
        "currency": "USD",
        "description": "GOODS AND SERVICE TAX INTERIM DOMESTIC AND INTERNATIONAL",
        "publishedAmount": 0.05,
        "publishedCurrency": "INR",
        "station": "BLR",
        "country": "IN"
      },
      {
        "id": 5,
        "code": "CJ",
        "amount": 7.4,
        "currency": "USD",
        "description": "SECURITY SERVICE CHARGE",
        "publishedAmount": 6.5,
        "publishedCurrency": "EUR",
        "station": "AMS",
        "country": "NL"
      },
      {
        "id": 6,
        "code": "RN",
        "amount": 7.3,
        "currency": "USD",
        "description": "PASSENGER SERVICE CHARGE",
        "publishedAmount": 6.4,
        "publishedCurrency": "EUR",
        "station": "AMS",
        "country": "NL"
      },
      {
        "id": 7,
        "code": "IN",
        "amount": 5.2,
        "currency": "USD",
        "description": "USER DEVELOPMENT FEE DEPARTURES",
        "publishedAmount": 362,
        "publishedCurrency": "INR",
        "station": "BLR",
        "country": "IN"
      }
    ],
    "fareComponentDescs": [
      {
        "id": 1,
        "governingCarrier": "KL",
        "fareAmount": 24.65,
        "fareCurrency": "INR",
        "fareBasisCode": "XPLWIA",
        "farePassengerType": "ADT",
        "publishedFareAmount": 1717,
        "oneWayFare": true,
        "directionality": "FROM",
        "direction": "EH",
        "notValidBefore": "2019-07-21",
        "notValidAfter": "2019-07-21",
        "applicablePricingCategories": "4 5 6 7 8 10 12 16 18",
        "vendorCode": "ATP",
        "fareTypeBitmap": "00",
        "fareType": "PRU",
        "fareTariff": "4",
        "fareRule": "INPL",
        "segments": [
          {
            "segment": {
              "surcharges": [
                {
                  "amount": 28.71,
                  "currency": "NUC",
                  "description": "MISCELLANEOUS/OTHER",
                  "type": "Q"
                }
              ]
            }
          },
          {
            "segment": {}
          },
          {
            "segment": {}
          }
        ]
      }
    ],
    "validatingCarrierDescs": [
      {
        "id": 1,
        "settlementMethod": "ARC",
        "newVcxProcess": true,
        "default": {
          "code": "DL"
        }
      }
    ],
    "baggageAllowanceDescs": [
      {
        "id": 1,
        "pieceCount": 1
      }
    ],
    "legDescs": [
      {
        "id": 1,
        "schedules": [
          {
            "ref": 2
          },
          {
            "ref": 4,
            "departureDateAdjustment": 1
          },
          {
            "ref": 5,
            "departureDateAdjustment": 1
          }
        ]
      },
      {
        "id": 2,
        "schedules": [
          {
            "ref": 3
          },
          {
            "ref": 4,
            "departureDateAdjustment": 1
          },
          {
            "ref": 1,
            "departureDateAdjustment": 1
          }
        ]
      }
    ],
    "itineraryGroups": [
      {
        "groupDescription": {
          "legDescriptions": [
            {
              "departureDate": "2019-07-21",
              "departureLocation": "BLR",
              "arrivalLocation": "LCY"
            }
          ]
        },
        "itineraries": [
          {
            "id": 1,
            "pricingSource": "ADVJR1",
            "legs": [
              {
                "ref": 2
              }
            ],
            "pricingInformation": [
              {
                "pricingSubsource": "MIP",
                "fare": {
                  "validatingCarrierCode": "DL",
                  "vita": true,
                  "eTicketable": true,
                  "lastTicketDate": "2019-07-05",
                  "governingCarriers": "KL",
                  "passengerInfoList": [
                    {
                      "passengerInfo": {
                        "passengerType": "ADT",
                        "passengerNumber": 1,
                        "nonRefundable": true,
                        "fareComponents": [
                          {
                            "ref": 1,
                            "segments": [
                              {
                                "segment": {
                                  "bookingCode": "X",
                                  "cabinCode": "Y",
                                  "mealCode": "D",
                                  "seatsAvailable": 9
                                }
                              },
                              {
                                "segment": {
                                  "bookingCode": "X",
                                  "cabinCode": "Y",
                                  "mealCode": "RB",
                                  "seatsAvailable": 9
                                }
                              },
                              {
                                "segment": {
                                  "bookingCode": "L",
                                  "cabinCode": "Y",
                                  "mealCode": "M",
                                  "seatsAvailable": 9,
                                  "availabilityBreak": true
                                }
                              }
                            ]
                          }
                        ],
                        "taxes": [
                          {
                            "ref": 2
                          },
                          {
                            "ref": 1
                          },
                          {
                            "ref": 7
                          },
                          {
                            "ref": 4
                          },
                          {
                            "ref": 3
                          },
                          {
                            "ref": 5
                          },
                          {
                            "ref": 6
                          }
                        ],
                        "taxSummaries": [
                          {
                            "ref": 2
                          },
                          {
                            "ref": 1
                          },
                          {
                            "ref": 3
                          },
                          {
                            "ref": 4
                          },
                          {
                            "ref": 7
                          },
                          {
                            "ref": 5
                          },
                          {
                            "ref": 6
                          }
                        ],
                        "currencyConversion": {
                          "from": "INR",
                          "to": "USD",
                          "exchangeRateUsed": 0.01442679
                        },
                        "fareMessages": [
                          {
                            "type": "N",
                            "code": "0",
                            "carrier": "KL",
                            "info": "FARE RESTRICTIONS APPLY/CARRIER RESTRICTIONS APPLY"
                          },
                          {
                            "type": "W",
                            "code": "0",
                            "info": "VALIDATING CARRIER - DL PER GSA AGREEMENT WITH KL"
                          }
                        ],
                        "passengerTotalFare": {
                          "totalFare": 264.5,
                          "totalTaxAmount": 208.5,
                          "currency": "USD",
                          "baseFareAmount": 3875,
                          "baseFareCurrency": "INR",
                          "equivalentAmount": 56,
                          "equivalentCurrency": "USD",
                          "constructionAmount": 55.59,
                          "constructionCurrency": "NUC",
                          "commissionPercentage": 0,
                          "commissionAmount": 0,
                          "exchangeRateOne": 69.651352
                        },
                        "baggageInformation": [
                          {
                            "provisionType": "A",
                            "airlineCode": "KL",
                            "segments": [
                              {
                                "id": 0
                              },
                              {
                                "id": 1
                              },
                              {
                                "id": 2
                              }
                            ],
                            "allowance": {
                              "ref": 1
                            }
                          }
                        ]
                      }
                    }
                  ],
                  "totalFare": {
                    "totalPrice": 264.5,
                    "totalTaxAmount": 208.5,
                    "currency": "USD",
                    "baseFareAmount": 3875,
                    "baseFareCurrency": "INR",
                    "constructionAmount": 55.59,
                    "constructionCurrency": "NUC",
                    "equivalentAmount": 56,
                    "equivalentCurrency": "USD"
                  },
                  "validatingCarriers": [
                    {
                      "ref": 1
                    }
                  ]
                }
              }
            ],
            "diversitySwapper": {
              "weighedPrice": 409.855
            }
          },
          {
            "id": 2,
            "pricingSource": "ADVJR1",
            "legs": [
              {
                "ref": 1
              }
            ],
            "pricingInformation": [
              {
                "pricingSubsource": "MIP",
                "fare": {
                  "validatingCarrierCode": "DL",
                  "vita": true,
                  "eTicketable": true,
                  "lastTicketDate": "2019-07-05",
                  "governingCarriers": "KL",
                  "passengerInfoList": [
                    {
                      "passengerInfo": {
                        "passengerType": "ADT",
                        "passengerNumber": 1,
                        "nonRefundable": true,
                        "fareComponents": [
                          {
                            "ref": 1,
                            "segments": [
                              {
                                "segment": {
                                  "bookingCode": "X",
                                  "cabinCode": "Y",
                                  "mealCode": "D",
                                  "seatsAvailable": 9
                                }
                              },
                              {
                                "segment": {
                                  "bookingCode": "X",
                                  "cabinCode": "Y",
                                  "mealCode": "RB",
                                  "seatsAvailable": 9
                                }
                              },
                              {
                                "segment": {
                                  "bookingCode": "L",
                                  "cabinCode": "Y",
                                  "mealCode": "M",
                                  "seatsAvailable": 9,
                                  "availabilityBreak": true
                                }
                              }
                            ]
                          }
                        ],
                        "taxes": [
                          {
                            "ref": 2
                          },
                          {
                            "ref": 1
                          },
                          {
                            "ref": 7
                          },
                          {
                            "ref": 4
                          },
                          {
                            "ref": 3
                          },
                          {
                            "ref": 5
                          },
                          {
                            "ref": 6
                          }
                        ],
                        "taxSummaries": [
                          {
                            "ref": 2
                          },
                          {
                            "ref": 1
                          },
                          {
                            "ref": 3
                          },
                          {
                            "ref": 4
                          },
                          {
                            "ref": 7
                          },
                          {
                            "ref": 5
                          },
                          {
                            "ref": 6
                          }
                        ],
                        "currencyConversion": {
                          "from": "INR",
                          "to": "USD",
                          "exchangeRateUsed": 0.01442679
                        },
                        "fareMessages": [
                          {
                            "type": "N",
                            "code": "0",
                            "carrier": "KL",
                            "info": "FARE RESTRICTIONS APPLY/CARRIER RESTRICTIONS APPLY"
                          },
                          {
                            "type": "W",
                            "code": "0",
                            "info": "VALIDATING CARRIER - DL PER GSA AGREEMENT WITH KL"
                          }
                        ],
                        "passengerTotalFare": {
                          "totalFare": 264.5,
                          "totalTaxAmount": 208.5,
                          "currency": "USD",
                          "baseFareAmount": 3875,
                          "baseFareCurrency": "INR",
                          "equivalentAmount": 56,
                          "equivalentCurrency": "USD",
                          "constructionAmount": 55.59,
                          "constructionCurrency": "NUC",
                          "commissionPercentage": 0,
                          "commissionAmount": 0,
                          "exchangeRateOne": 69.651352
                        },
                        "baggageInformation": [
                          {
                            "provisionType": "A",
                            "airlineCode": "KL",
                            "segments": [
                              {
                                "id": 0
                              },
                              {
                                "id": 1
                              },
                              {
                                "id": 2
                              }
                            ],
                            "allowance": {
                              "ref": 1
                            }
                          }
                        ]
                      }
                    }
                  ],
                  "totalFare": {
                    "totalPrice": 264.5,
                    "totalTaxAmount": 208.5,
                    "currency": "USD",
                    "baseFareAmount": 3875,
                    "baseFareCurrency": "INR",
                    "constructionAmount": 55.59,
                    "constructionCurrency": "NUC",
                    "equivalentAmount": 56,
                    "equivalentCurrency": "USD"
                  },
                  "validatingCarriers": [
                    {
                      "ref": 1
                    }
                  ]
                }
              }
            ],
            "diversitySwapper": {
              "weighedPrice": 367.631
            }
          }
        ]
      }
    ]
  }
}

您必须使用 legDescs 列表来连接您的段,并使用那些 "ref" 值。

例如:

{ "id": 2, "schedules":[ { "ref": 3 }, { "departureDateAdjustment": 1, "ref": 4 }, { "departureDateAdjustment": 1, "ref": 1 } ] }

意味着,您 ID = 2 的航班包含 3 个航段,ID 为 3 - 4 和 1。当您在 "scheduleDescs" 对象中搜索编号航段时,您可以看到路线为:

BLR-删除 德尔-AMS AMS-LCY

如您所见,您获得了 BLR - LCY 航班。