วิธีนี้จะแสดงกลุ่มการออกตั๋วระดับสูงสำหรับการเดินทางที่ระบุ ซึ่งประกอบด้วยชุดกลุ่มที่มีชั้นบริการที่เลือกซึ่งจองได้ในตั๋วเดียวกัน รวมถึงข้อมูลค่าโดยสารและความพร้อมจำหน่ายตั๋วโดยรวม ข้อควรทราบ
- ticketing_.*_id ทั้งหมด (ส่วนหนึ่งของ SegmentKey) จะ อ้างอิงถึงข้อมูลที่ระบุไว้ในส่วนขยายการจำหน่ายตั๋ว Google Transit
- ตัวระบุต้องคงที่ และการเปลี่ยนแปลงใดๆ ในตัวระบุเหล่านี้ต้องเข้ากันได้กับเวอร์ชันก่อนหน้าตามที่ระบุไว้ในข้อกำหนดในการผสานรวม GTFS
GetTripOptionsRequest
คำจำกัดความของ Proto
// Request sent to partners. message GetTripOptionsRequest { // 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
{ "segment_keys": [ { "ticketing_trip_id": "123456", "from_ticketing_stop_time_id": "ZRH-1234", "to_ticketing_stop_time_id": "LUZ-1235", "service_date": { "year": 2022, "month": 4, "day": 6 }, "boarding_time": { "year": 2022, "month": 4, "day": 6, "hours": 14, "minutes": 25, "seconds": 0, "nanos": 0, "utc_offset": "0s" }, "arrival_time": { "year": 2022, "month": 4, "day": 6, "hours": 16, "minutes": 25, "seconds": 0, "nanos": 0, "utc_offset": "0s" } }, { "ticketing_trip_id": "234567", "from_ticketing_stop_time_id": "LUZ-2759", "to_ticketing_stop_time_id": "WOL-2455", "service_date": { "year": 2022, "month": 4, "day": 6 }, "boarding_time": { "year": 2022, "month": 4, "day": 6, "hours": 18, "minutes": 13, "seconds": 0, "nanos": 0, "utc_offset": "0s" }, "arrival_time": { "year": 2022, "month": 4, "day": 6, "hours": 20, "minutes": 13, "seconds": 0, "nanos": 0, "utc_offset": "0s" } } ] }
GetTripOptionsResponse
คำจำกัดความของ Proto
// Response received from partners. message GetTripOptionsResponse { oneof response { TripOptionsResult trip_options_result = 1; TripOptionsError trip_options_error = 2; } } // A successful partner response. message TripOptionsResult { // Note: // - A TripOption represents the fare for a combination of available service // classes for the segments in the request. // - If the seats within a service class are sold at different fares of // limited availability, a different TripOption instance with the same // sequence of segments can be returned for each fare. // Partners should also include options that are unavailable because they are // fully booked, using the appropriate Unavailable message below. 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
{ "trip_options_result": { "trip_options": [ { "segments": [ { "segment_key": { "ticketing_trip_id": "123456", "from_ticketing_stop_time_id": "ZRH-1234", "to_ticketing_stop_time_id": "LUZ-1235", "service_date": { "year": 2022, "month": 4, "day": 6 }, "boarding_time": { "year": 2022, "month": 4, "day": 6, "hours": 14, "minutes": 25, "seconds": 0, "utc_offset": "0s" }, "arrival_time": { "year": 2022, "month": 4, "day": 6, "hours": 16, "minutes": 25, "seconds": 0, "utc_offset": "0s" } }, "service_class": { "type": "FIRST_CLASS" } }, { "segment_key": { "ticketing_trip_id": "234567", "from_ticketing_stop_time_id": "LUZ-2759", "to_ticketing_stop_time_id": "WOL-2455", "service_date": { "year": 2022, "month": 4, "day": 6 }, "boarding_time": { "year": 2022, "month": 4, "day": 6, "hours": 18, "minutes": 13, "seconds": 0, "utc_offset": "0s" }, "arrival_time": { "year": 2022, "month": 4, "day": 6, "hours": 20, "minutes": 13, "seconds": 0, "utc_offset": "0s" } }, "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": 30 } } }, { "segments": [ { "segment_key": { "ticketing_trip_id": "123456", "from_ticketing_stop_time_id": "ZRH-1234", "to_ticketing_stop_time_id": "LUZ-1235", "service_date": { "year": 2022, "month": 4, "day": 6 }, "boarding_time": { "year": 2022, "month": 4, "day": 6, "hours": 14, "minutes": 25, "seconds": 0, "utc_offset": "0s" }, "arrival_time": { "year": 2022, "month": 4, "day": 6, "hours": 16, "minutes": 25, "seconds": 0, "utc_offset": "0s" } }, "service_class": { "type": "SECOND_CLASS" } }, { "segment_key": { "ticketing_trip_id": "234567", "from_ticketing_stop_time_id": "LUZ-2759", "to_ticketing_stop_time_id": "WOL-2455", "service_date": { "year": 2022, "month": 4, "day": 6 }, "boarding_time": { "year": 2022, "month": 4, "day": 6, "hours": 18, "minutes": 13, "seconds": 0, "utc_offset": "0s" }, "arrival_time": { "year": 2022, "month": 4, "day": 6, "hours": 20, "minutes": 13, "seconds": 0, "utc_offset": "0s" } }, "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 } } } ] } }
ตัวอย่างข้อผิดพลาด JSON
{ "trip_options_error": { "error_type": "SEGMENT_KEY_NOT_FOUND", "error_message": "No matching segments found, no departures at 14:25" } }
หมายเหตุเกี่ยวกับการใช้งาน API
หากพบพารามิเตอร์เพิ่มเติมในคีย์กลุ่ม ให้ส่งคืนพารามิเตอร์เหล่านั้นในการตอบกลับเสมอ เพื่อให้เข้ากันได้กับเวอร์ชันต่อๆ ไปในกรณีที่มีการเปลี่ยนแปลง มิฉะนั้น ให้ละเว้นพารามิเตอร์และถือว่าคำขอไม่มีพารามิเตอร์ จนกว่าคุณจะรองรับพารามิเตอร์นั้นๆ ได้
การตอบกลับข้อผิดพลาด
ตารางต่อไปนี้อธิบายถึงสิ่งที่คาดหวังในการรายงานข้อผิดพลาดสำหรับวิธีนี้
ประเภทข้อผิดพลาด | ลองใหม่ได้ | รหัสสถานะ HTTP | คำอธิบาย |
---|---|---|---|
SEGMENT_KEY_NOT_FOUND |
ไม่ | 404 | ไม่พบกลุ่มที่สอดคล้องกับ SegmentKey รายการใดรายการหนึ่งที่ระบุ |
TRIP_OPTION_CACHE_STALE |
ใช่ | 404 | ข้อมูลสำหรับตัวเลือกการเดินทางที่ขอไม่เป็นข้อมูลล่าสุดที่พาร์ทเนอร์ และต้องรีเฟรชเพื่อให้ Google |
INTERNAL_ERROR |
ใช่ | 500 | เกิดข้อผิดพลาดที่ไม่คาดคิดขณะดึงข้อมูลการเดินทางนี้ ซึ่งบ่งบอกถึงข้อบกพร่องที่พาร์ทเนอร์ต้องแก้ไข |
SUBOPTIMAL_ITINERARY |
ไม่ | 404 | พบการเดินทางแล้ว แต่พาร์ทเนอร์พิจารณาว่าการเดินทางดังกล่าวไม่เหมาะสมและเลือกที่จะไม่ขายตั๋วสำหรับการเดินทางนั้น |
TICKETING_PROHIBITED |
ไม่ | 404 | พบการเดินทางแล้ว แต่พาร์ทเนอร์ไม่ได้รับอนุญาตให้ขายตั๋วสำหรับการเดินทางดังกล่าวเนื่องจากข้อจำกัดในการขายตั๋วทั่วไปที่ผู้ให้บริการหรือหน่วยงานด้านรถไฟกำหนด |
BOOKING_WINDOW_NOT_SUPPORTED |
ไม่ | 404 | พาร์ทเนอร์ไม่รองรับแผนการเดินทางที่มีราคาสำหรับวันที่ที่ขอ |
ดูรายละเอียดเพิ่มเติมได้ที่
TripOptionsErrorType
ดูการแสดงรหัสสถานะในการตอบกลับ HTTP ได้ที่รหัสสถานะและการจัดการข้อผิดพลาด