เมธอด GetBulkTripOptions

เมื่อเทียบกับเมธอด GetTripOptions แล้ว เมธอด GetBulkTripOptions มีข้อดีดังนี้

  • ช่วยให้การป้อนข้อมูลลงในแคชของ Google มีประสิทธิภาพมากขึ้นโดยใช้คำขอน้อยลง และสอดคล้องกับ API ต้นทางจากผู้ให้บริการได้ดียิ่งขึ้น ซึ่งพาร์ทเนอร์อาจใช้เพื่อรับข้อมูลด้วยตนเอง
  • ช่วยให้พาร์ทเนอร์ที่มีชุดการเดินทางที่พร้อมให้บริการซึ่งกำหนดไว้ล่วงหน้า ระบุข้อมูลได้ง่ายขึ้นโดยไม่ต้องตรวจสอบแผนการเดินทางโดยละเอียด
  • สำหรับพาร์ทเนอร์ที่มีความซับซ้อนมากขึ้น Google จะยังคงให้รายการแผนการเดินทางที่ทราบ เพื่อเพิ่มการจับคู่จำนวนห้องของพาร์ทเนอร์และแผนการเดินทาง ที่สร้างโดยเครื่องมือการกำหนดเส้นทางของ Google เพื่อแสดงราคาของพาร์ทเนอร์ในแผนการเดินทางให้มากที่สุด
  • อนุญาตให้ส่งแผนการเดินทางที่ Google ยังไม่ได้ให้บริการ เพื่อ อาจปรับเครื่องมือกำหนดเส้นทางของ Google ให้ตรงกับ พื้นที่โฆษณาของพาร์ทเนอร์ได้ดียิ่งขึ้นในอนาคต

GetBulkTripOptionsRequest

คำจำกัดความของ Proto

// Request sent to partners.
message GetBulkTripOptionsRequest {
  // The MarketDates for which to return results.
  // Initially, only a single value will be supplied, representing one-way
  // trips.
  repeated MarketDate market_dates = 1;

  // List of itineraries matching market_dates that Google knows about and will
  // serve to end users. Partners should try to return results matching these
  // itineraries, as other itineraries will not be immediately useful other than
  // for analysis purposes.
  repeated ItineraryKey known_itineraries = 2;

  // If true, only the explicitly specified known_itineraries should be
  // returned. Not in use yet (always set to false).
  bool only_known_itineraries = 3;
}

message MarketDate {
  // ID of the stop where the traveler starts their journey.
  string origin_ticketing_stop_id = 1;

  // Stop ID of the ultimate journey destination of the traveler.
  string destination_ticketing_stop_id = 2;

  // Date of departure at the origin, in the timezone at the origin.
  .google.type.Date departure_date = 3;
}

// A full end-to-end journey for a traveler, including all vehicles used.
message ItineraryKey {
  // All segments together should form a single trip for which a ticket can be
  // booked.
  repeated ext.travel.transport.partner.SegmentKey segment_keys = 1;
}

ตัวอย่าง JSON

{
  "market_dates": [
    {
      "origin_ticketing_stop_id": "ZRH-1234",
      "destination_ticketing_stop_id": "WOL-2455",
      "departure_date": {
        "year": 2023,
        "month": 5,
        "day": 15
      }
    }
  ],
  "known_itineraries": [
    {
      "segment_keys": [
        {
          "ticketing_trip_id": "123456",
          "from_ticketing_stop_time_id": "ZRH-1234",
          "to_ticketing_stop_time_id": "LUZ-1235",
          "service_date": {
            "year": 2023,
            "month": 5,
            "day": 15
          },
          "boarding_time": {
            "year": 2023,
            "month": 5,
            "day": 15,
            "hours": 14,
            "minutes": 25,
            "seconds": 0,
            "nanos": 0,
            "utc_offset": "0s"
          },
          "arrival_time": {
            "year": 2023,
            "month": 5,
            "day": 15,
            "hours": 16,
            "minutes": 25,
            "seconds": 0,
            "nanos": 0,
            "utc_offset": "0s"
          }
        },
        {
          "ticketing_trip_id": "988833",
          "from_ticketing_stop_time_id": "LUZ-1235",
          "to_ticketing_stop_time_id": "WOL-2455",
          "service_date": {
            "year": 2023,
            "month": 5,
            "day": 15
          },
          "boarding_time": {
            "year": 2023,
            "month": 5,
            "day": 15,
            "hours": 18,
            "minutes": 13,
            "seconds": 0,
            "nanos": 0,
            "utc_offset": "0s"
          },
          "arrival_time": {
            "year": 2023,
            "month": 5,
            "day": 15,
            "hours": 20,
            "minutes": 13,
            "seconds": 0,
            "nanos": 0,
            "utc_offset": "0s"
          }
        }
      ]
    },
    {
      "segment_keys": [
        {
          "ticketing_trip_id": "98765",
          "from_ticketing_stop_time_id": "ZRH-1234",
          "to_ticketing_stop_time_id": "ZUG-1235",
          "service_date": {
            "year": 2023,
            "month": 5,
            "day": 15
          },
          "boarding_time": {
            "year": 2023,
            "month": 5,
            "day": 15,
            "hours": 14,
            "minutes": 30,
            "seconds": 0,
            "nanos": 0,
            "utc_offset": "0s"
          },
          "arrival_time": {
            "year": 2023,
            "month": 5,
            "day": 15,
            "hours": 16,
            "minutes": 30,
            "seconds": 0,
            "nanos": 0,
            "utc_offset": "0s"
          }
        },
        {
          "ticketing_trip_id": "43210",
          "from_ticketing_stop_time_id": "ZUG-1235",
          "to_ticketing_stop_time_id": "WOL-2455",
          "service_date": {
            "year": 2023,
            "month": 5,
            "day": 15
          },
          "boarding_time": {
            "year": 2023,
            "month": 5,
            "day": 15,
            "hours": 18,
            "minutes": 13,
            "seconds": 0,
            "nanos": 0,
            "utc_offset": "0s"
          },
          "arrival_time": {
            "year": 2023,
            "month": 5,
            "day": 15,
            "hours": 20,
            "minutes": 13,
            "seconds": 0,
            "nanos": 0,
            "utc_offset": "0s"
          }
        }
      ]
    }
  ],
  "only_known_itineraries": false
}

GetBulkTripOptionsResponse

คำจำกัดความของ Proto

// Response received from partners.
message GetBulkTripOptionsResponse {
  oneof response {
    BulkTripOptionsResult bulk_trip_options_result = 1;
    BulkTripOptionsError bulk_trip_options_error = 2;
  }
}

// A message representing a successful response.
message BulkTripOptionsResult {
  // One response per entry in known_itineraries in the request, plus any
  // additional ones partners choose to return if only_known_itineraries is
  // false.
  repeated ItineraryResponse itinerary_responses = 1;
}

// A message for errors affecting the whole request.
message BulkTripOptionsError {
  enum BulkTripOptionsErrorType {
    // An unexpected error happened during retrieval of this trip.
    // This indicates a bug that needs to be fixed by the partner.
    // This error is retriable.
    // Always returns HTTP 500 status code in response.
    INTERNAL_ERROR = 1;
  }

  BulkTripOptionsErrorType error_type = 1;

  // This is not user-visible and is for logging and debugging purposes only.
  string error_message = 2;
}

// A message container for an itinerary with a set of prices for that itinerary.
message ItineraryResponse {
  // A single itinerary that this response relates to.
  ItineraryKey itinerary = 1;

  oneof response {
    // A set of prices for this itinerary.
    TripOptionSet trip_option_set = 2;

    // Error information about the retrieval of this itinerary.
    TripOptionsError trip_options_error = 3;
  }
}

// A container for multiple trip options.
message TripOptionSet {
  // To reduce the amount of data transferred, segments.segment_key can be empty
  // inside these trip_options, since the segment_key is already present in
  // ItineraryResponse.itinerary.segment_keys. This requires the number of
  // segments in to each TripOption to match exactly the number of segments
  // inside ItineraryResponse.itinerary. We then assume that the n-th
  // trip_options.segments.segment_key matches the n-th itinerary.segment_key.
  repeated TripOption trip_options = 1;
}


// A travel option for users covering the whole end-to-end journey with the
// partner.
message TripOption {
  // A series of Segments that cover the whole trip option, one for each
  // SegmentKey in the request.
  repeated Segment segments = 1;

  // This is the lowest standard fare of all seats with the specified segments.
  // This field is optional if the series of segments is unavailable.
  // This "standard fare" should be the lowest seat price where no age or other
  // booking restrictions apply. The currency should be the local currency of
  // the origin of the first segment.
  Fare lowest_standard_fare = 2;

  // The availability status for bookings of this trip option at the
  // lowest_standard_fare.
  Availability availability = 3;

  // This is used to receive optional extra data via the Travel Transport API
  // and pass it into the ticketing deep link.
  // Booking links should still work without the booking token, but the token
  // can be used to ensure price consistency between Google Search results and
  // the partner booking page.
  string booking_token = 4 [features.field_presence = EXPLICIT];
}

// A segment traveled on a single vehicle in a given Service Class.
message Segment {
  SegmentKey segment_key = 1;

  // The service class used on this segment.
  ServiceClass service_class = 2;
}

ตัวอย่าง JSON

{
  "bulk_trip_options_result": {
    "itinerary_responses": [
      {
        "itinerary": {
          "segment_keys": [
            {
              "ticketing_trip_id": "123456",
              "from_ticketing_stop_time_id": "ZRH-1234",
              "to_ticketing_stop_time_id": "LUZ-1235",
              "service_date": {
                "year": 2023,
                "month": 5,
                "day": 15
              },
              "boarding_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 14,
                "minutes": 25,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              },
              "arrival_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 16,
                "minutes": 25,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              }
            },
            {
              "ticketing_trip_id": "988833",
              "from_ticketing_stop_time_id": "LUZ-1235",
              "to_ticketing_stop_time_id": "WOL-2455",
              "service_date": {
                "year": 2023,
                "month": 5,
                "day": 15
              },
              "boarding_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 18,
                "minutes": 13,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              },
              "arrival_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 20,
                "minutes": 13,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              }
            }
          ]
        },
        "trip_option_set": {
          "trip_options": [
            {
              "segments": [
                {
                  "service_class": {
                    "type": "SECOND_CLASS"
                  }
                },
                {
                  "service_class": {
                    "type": "SECOND_CLASS"
                  }
                }
              ],
              "lowest_standard_fare": {
                "total_amount": {
                  "units": 10,
                  "nanos": 0,
                  "currency_code": "CHF"
                },
                "line_items": [
                  {
                    "line_item_type": "BASE_FARE",
                    "amount": {
                      "units": 9,
                      "nanos": 750000000,
                      "currency_code": "CHF"
                    }
                  },
                  {
                    "line_item_type": "SERVICE_CHARGE",
                    "amount": {
                      "units": 0,
                      "nanos": 250000000,
                      "currency_code": "CHF"
                    }
                  }
                ]
              },
              "availability": {
                "available": {
                  "available_seat_count": 44,
                  "total_seat_count": 200
                }
              }
            },
            {
              "segments": [
                {
                  "service_class": {
                    "type": "FIRST_CLASS"
                  }
                },
                {
                  "service_class": {
                    "type": "FIRST_CLASS"
                  }
                }
              ],
              "lowest_standard_fare": {
                "total_amount": {
                  "units": 15,
                  "nanos": 0,
                  "currency_code": "CHF"
                },
                "line_items": [
                  {
                    "line_item_type": "BASE_FARE",
                    "amount": {
                      "units": 13,
                      "nanos": 950000000,
                      "currency_code": "CHF"
                    }
                  },
                  {
                    "line_item_type": "SERVICE_CHARGE",
                    "amount": {
                      "units": 1,
                      "nanos": 50000000,
                      "currency_code": "CHF"
                    }
                  }
                ]
              },
              "availability": {
                "available": {
                  "available_seat_count": 10,
                  "total_seat_count": 100
                }
              }
            }
          ]
        }
      },
      {
        "itinerary": {
          "segment_keys": [
            {
              "ticketing_trip_id": "98765",
              "from_ticketing_stop_time_id": "ZRH-1234",
              "to_ticketing_stop_time_id": "ZUG-1235",
              "service_date": {
                "year": 2023,
                "month": 5,
                "day": 15
              },
              "boarding_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 14,
                "minutes": 30,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              },
              "arrival_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 16,
                "minutes": 30,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              }
            },
            {
              "ticketing_trip_id": "43210",
              "from_ticketing_stop_time_id": "ZUG-1235",
              "to_ticketing_stop_time_id": "WOL-2455",
              "service_date": {
                "year": 2023,
                "month": 5,
                "day": 15
              },
              "boarding_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 18,
                "minutes": 13,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              },
              "arrival_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 20,
                "minutes": 13,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              }
            }
          ]
        },
        "trip_option_set": {
          "trip_options": [
            {
              "segments": [
                {
                  "service_class": {
                    "type": "SECOND_CLASS"
                  }
                },
                {
                  "service_class": {
                    "type": "SECOND_CLASS"
                  }
                }
              ],
              "lowest_standard_fare": {
                "total_amount": {
                  "units": 9,
                  "nanos": 0,
                  "currency_code": "CHF"
                },
                "line_items": [
                  {
                    "line_item_type": "BASE_FARE",
                    "amount": {
                      "units": 8,
                      "nanos": 750000000,
                      "currency_code": "CHF"
                    }
                  },
                  {
                    "line_item_type": "SERVICE_CHARGE",
                    "amount": {
                      "units": 0,
                      "nanos": 250000000,
                      "currency_code": "CHF"
                    }
                  }
                ]
              },
              "availability": {
                "available": {
                  "available_seat_count": 30,
                  "total_seat_count": 150
                }
              }
            },
            {
              "segments": [
                {
                  "service_class": {
                    "type": "FIRST_CLASS"
                  }
                },
                {
                  "service_class": {
                    "type": "FIRST_CLASS"
                  }
                }
              ],
              "lowest_standard_fare": {
                "total_amount": {
                  "units": 14,
                  "nanos": 0,
                  "currency_code": "CHF"
                },
                "line_items": [
                  {
                    "line_item_type": "BASE_FARE",
                    "amount": {
                      "units": 12,
                      "nanos": 950000000,
                      "currency_code": "CHF"
                    }
                  },
                  {
                    "line_item_type": "SERVICE_CHARGE",
                    "amount": {
                      "units": 1,
                      "nanos": 50000000,
                      "currency_code": "CHF"
                    }
                  }
                ]
              },
              "availability": {
                "available": {
                  "available_seat_count": 15,
                  "total_seat_count": 60
                }
              }
            }
          ]
        }
      }
    ]
  }
}

ตัวอย่างข้อผิดพลาด JSON

{
  "bulk_trip_options_error": {
    "error_type": "INTERNAL_ERROR",
    "error_message": "Unexpected RoutingException during trip lookup."
  }
}

ข้อผิดพลาดบางส่วนของ JSON

{
  "bulk_trip_options_result": {
    "itinerary_responses": [
      {
        "itinerary": {
          "segment_keys": [
            {
              "ticketing_trip_id": "123456",
              "from_ticketing_stop_time_id": "ZRH-1234",
              "to_ticketing_stop_time_id": "LUZ-1235",
              "service_date": {
                "year": 2023,
                "month": 5,
                "day": 15
              },
              "boarding_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 14,
                "minutes": 25,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              },
              "arrival_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 16,
                "minutes": 25,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              }
            },
            {
              "ticketing_trip_id": "988833",
              "from_ticketing_stop_time_id": "LUZ-1235",
              "to_ticketing_stop_time_id": "WOL-2455",
              "service_date": {
                "year": 2023,
                "month": 5,
                "day": 15
              },
              "boarding_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 18,
                "minutes": 13,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              },
              "arrival_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 20,
                "minutes": 13,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              }
            }
          ]
        },
        "trip_option_set": {
          "trip_options": [
            {
              "segments": [
                {
                  "service_class": {
                    "type": "SECOND_CLASS"
                  }
                },
                {
                  "service_class": {
                    "type": "SECOND_CLASS"
                  }
                }
              ],
              "lowest_standard_fare": {
                "total_amount": {
                  "units": 10,
                  "nanos": 0,
                  "currency_code": "CHF"
                },
                "line_items": [
                  {
                    "line_item_type": "BASE_FARE",
                    "amount": {
                      "units": 9,
                      "nanos": 750000000,
                      "currency_code": "CHF"
                    }
                  },
                  {
                    "line_item_type": "SERVICE_CHARGE",
                    "amount": {
                      "units": 0,
                      "nanos": 250000000,
                      "currency_code": "CHF"
                    }
                  }
                ]
              },
              "availability": {
                "available": {
                  "available_seat_count": 44,
                  "total_seat_count": 200
                }
              }
            },
            {
              "segments": [
                {
                  "service_class": {
                    "type": "FIRST_CLASS"
                  }
                },
                {
                  "service_class": {
                    "type": "FIRST_CLASS"
                  }
                }
              ],
              "lowest_standard_fare": {
                "total_amount": {
                  "units": 15,
                  "nanos": 0,
                  "currency_code": "CHF"
                },
                "line_items": [
                  {
                    "line_item_type": "BASE_FARE",
                    "amount": {
                      "units": 13,
                      "nanos": 950000000,
                      "currency_code": "CHF"
                    }
                  },
                  {
                    "line_item_type": "SERVICE_CHARGE",
                    "amount": {
                      "units": 1,
                      "nanos": 50000000,
                      "currency_code": "CHF"
                    }
                  }
                ]
              },
              "availability": {
                "available": {
                  "available_seat_count": 10,
                  "total_seat_count": 100
                }
              }
            }
          ]
        }
      },
      {
        "itinerary": {
          "segment_keys": [
            {
              "ticketing_trip_id": "98765",
              "from_ticketing_stop_time_id": "ZRH-1234",
              "to_ticketing_stop_time_id": "ZUG-1235",
              "service_date": {
                "year": 2023,
                "month": 5,
                "day": 15
              },
              "boarding_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 14,
                "minutes": 30,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              },
              "arrival_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 16,
                "minutes": 30,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              }
            },
            {
              "ticketing_trip_id": "43210",
              "from_ticketing_stop_time_id": "ZUG-1235",
              "to_ticketing_stop_time_id": "WOL-2455",
              "service_date": {
                "year": 2023,
                "month": 5,
                "day": 15
              },
              "boarding_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 18,
                "minutes": 13,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              },
              "arrival_time": {
                "year": 2023,
                "month": 5,
                "day": 15,
                "hours": 20,
                "minutes": 13,
                "seconds": 0,
                "nanos": 0,
                "utc_offset": "0s"
              }
            }
          ]
        },
        "trip_options_error": {
          "error_type": "SEGMENT_KEY_NOT_FOUND",
          "error_message": "No matching segments found, no departures at 14:30"
        }
      }
    ]
  }
}

สถานการณ์ทั่วไป

เราคาดการณ์สถานการณ์ต่อไปนี้พร้อมกับรูปร่างคำขอที่เฉพาะเจาะจงสำหรับ API

  • สำหรับพาร์ทเนอร์ที่มีความเชี่ยวชาญด้านเทคนิคไม่มาก ให้ระบุเฉพาะ market_date พาร์ทเนอร์เหล่านี้สามารถใช้การค้นหาที่อิงตาม market_date กับข้อมูลต้นทาง และแสดงผลลัพธ์ทั้งหมดที่แมปกับรูปแบบข้อมูลของเรา Google สามารถกรองผลการค้นหาให้แสดงเฉพาะแผนการเดินทางที่คาดไว้

  • สำหรับพาร์ทเนอร์ที่มีความเชี่ยวชาญด้านเทคนิคมากขึ้น เราขอแนะนำให้ระบุทั้ง market_date และ known_itineraries พาร์ทเนอร์สามารถค้นหาข้อมูลโดยละเอียดในฐานข้อมูลภายใน เพื่อให้สามารถกำหนดราคาแผนการเดินทางที่คาดไว้ได้อย่างแม่นยำ ระบบจะแสดงknown_itinerariesที่ขอทั้งหมดต่อผู้ใช้ เพื่อให้พาร์ทเนอร์เพิ่มจำนวนแผนการเดินทางที่แสดงราคาและลิงก์การจองได้สูงสุด พาร์ทเนอร์ยังคงมีตัวเลือกในการแสดงแผนการเดินทางเพิ่มเติมเพื่อช่วยให้ Google จับคู่พื้นที่โฆษณาของตนเอง (ที่ได้รับการโปรโมต) ได้ดียิ่งขึ้น

Error Reporting

คุณควรรายงานข้อผิดพลาดสำหรับการเดินทางแต่ละครั้งแยกกัน ดังนั้น คำตอบที่ต้องการคือ BulkTripOptionsResult (HTTP 200) ซึ่งระบุข้อผิดพลาดต่อการเดินทางใน bulk_trip_options_result.itinerary_responses[i].trip_options_error หากbulk_trip_options_errorทั้งคำขอไม่สำเร็จโดยไม่คาดคิด ให้ใช้ BulkTripOptionsErrorType.INTERNAL_ERROR (HTTP 500)

ดูรายละเอียดเพิ่มเติมได้ที่ TripOptionsErrorType

ดูการแสดงรหัสสถานะในการตอบกลับ HTTP ได้ที่รหัสสถานะและการจัดการข้อผิดพลาด

หมายเหตุ

MarketDate.departure_date ระบุวันในปฏิทิน การดำเนินการนี้จะใช้เขตเวลาที่ต้นทางเพื่อให้ตรงกับ API ของผู้ให้บริการมากขึ้น อย่างไรก็ตาม SegmentKey จะยังคงระบุเวลาขึ้นเครื่องและเวลาถึงที่หมายโดยใช้ UTC เพื่อให้สอดคล้องกับ GetTripOptions