GetTripOptions मेथड

इस तरीके से, किसी यात्रा के लिए टिकट के ग्रुप की ज़्यादा जानकारी मिलती है. इनमें, चुनी गई सेवा क्लास वाले सेगमेंट के सेट शामिल होते हैं. इन्हें एक ही टिकट पर बुक किया जा सकता है. साथ ही, इनमें पूरे टिकट के लिए किराया और उपलब्धता की जानकारी भी होती है. ध्यान दें कि:

GetTripOptionsRequest

प्रोटो की परिभाषा

// 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

प्रोटो की परिभाषा

// 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"
  }
}

एपीआई लागू करने से जुड़ी जानकारी:

संभावित बदलावों के साथ आगे की ओर काम करने के लिए, अगर सेगमेंट कुंजियों में अतिरिक्त पैरामीटर मिलते हैं, तो उन्हें हमेशा जवाब में वापस भेजें. ऐसा न होने पर, पैरामीटर को अनदेखा करें और अनुरोध को इस तरह से प्रोसेस करें जैसे कि वे मौजूद ही नहीं हैं. ऐसा तब तक करें, जब तक कि पैरामीटर के लिए खास तौर पर सहायता उपलब्ध न करा दी जाए.

गड़बड़ी के रिस्पॉन्स

इस टेबल में, इस तरीके से गड़बड़ी की रिपोर्टिंग करने के बारे में बताया गया है:

गड़बड़ी प्रकार फिर से कोशिश की जा सकती है एचटीटीपी स्टेटस कोड ब्यौरा
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 देखें

एचटीटीपी रिस्पॉन्स में स्टेटस कोड के बारे में जानने के लिए, स्टेटस कोड और गड़बड़ी ठीक करना लेख पढ़ें.