Fare specification

  • The Fare message represents a fare's total price, broken down into individual amounts.

  • The LineItem message provides details for each part of the fare, categorized by LineItemType such as BASE_FARE, SERVICE_CHARGE, and TAXES.

  • The total_amount field represents the overall cost of the fare and should be equal to the sum of all line_items.

  • A LineItemType enum is used to categorize each line item within a fare breakdown, with examples including base fare, service charge, and taxes.

  • The provided json sample shows the structure of a fare, including the total amount and a breakdown of the line items with their type and amount.

Proto Definition

// Represents a fare with a breakdown of the different amounts that compose its
// total price.
message Fare {
  // Message to represent a fare breakdown.
  message LineItem {
    // The line item type is used to provide a breakdown of the fare for display
    // to the user. If additional line item types are required please reach out
    // to the Google Transport team.
    enum LineItemType {
      BASE_FARE = 1;
      SERVICE_CHARGE = 2;
      TAXES = 3;
    }

    LineItemType line_item_type = 1;
    .google.type.Money amount = 2;
  }

  // Total amount of the fare. This is equal to the sum of all the line items.
  .google.type.Money total_amount = 1;

  // Details about the different parts that constitute the total amount. The
  // sum of all the line items must be equal to total_amount.
  repeated LineItem line_items = 2;
}

JSON Sample

{
  "total_amount": {
    "units": 2,
    "nanos": 0,
    "currency_code": "USD"
  },
  "line_items": [
    {
      "line_item_type": "BASE_FARE",
      "amount": {
        "units": 1,
        "nanos": 950000000,
        "currency_code": "USD"
      }
    },
    {
      "line_item_type": "SERVICE_CHARGE",
      "amount": {
        "units": 0,
        "nanos": 50000000,
        "currency_code": "USD"
      }
    }
  ]
}