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

时间:2019-06-28 06:43:37

标签: json sabre

我正在尝试使用BargainFindermax API搜索Saber中两个地方之间的航班。 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
            }
          }
        ]
      }
    ]
  }
}

1 个答案:

答案 0 :(得分:1)

您必须使用legDescs列表来连接您的细分,并使用这些“ ref”值。

例如:

{                 “ id”:2                 “时间表”:[                     {                         “ ref”:3                     },                     {                         “ departureDateAdjustment”:1                         “ ref”:4                     },                     {                         “ departureDateAdjustment”:1                         “参考”:1                     }                 ]             }

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

BLR-DEL DEL-AMS AMS-LCY

您会看到BLR-LCY航班。