答案 0 :(得分:1)
激增基于特定的位置和产品设置 - 因此,如果您尝试以下请求:
"prices": [
{
"localized_display_name": "uberX",
"distance": 7.76,
"display_name": "uberX",
"product_id": "2d1d002b-d4d0-4411-98e1-673b244878b2",
"high_estimate": 35,
"surge_multiplier": 1,
"minimum": 9,
"low_estimate": 26,
"duration": 1260,
"estimate": "A$26-35",
"currency_code": "AUD"
},
如果您尝试不同的位置:
start_latitude = 37.7752315&安培; start_longitude = -122.418075&安培; end_latitude = 37.7752415&安培; end_longitude = -122.518075
如果没有'surge_multiplier'参数,您将获得响应:
{
"localized_display_name": "uberXL",
"distance": 6.62,
"display_name": "uberXL",
"product_id": "821415d8-3bd5-4e27-9604-194e4359a449",
"high_estimate": 28,
"low_estimate": 22,
"duration": 1380,
"estimate": "$22-28",
"currency_code": "USD"
},
有关激增的更多信息,请阅读我们的documetation
编辑于02/15/2018完成:
如果您使用的是v1.2请求 - 我们将根据产品设置获得响应。如果估计请求中使用的产品配置为“upfront_fare_enabled”:true,那么我们将获得一个fare_id - 而不是估计。所以这是预期的,如在v1.2中使用upfront_fare_enabled:true,永远不会有浪涌信息(因为你获得了真正的票价+ fare_id)。
请查看我们关于“POST /v1.2/requests/estimate”端点的文档中的以下句子:
您应该在请求之前使用此端点获取前期票价 载一程。在某些产品中,未启用前期票价,因此您可以使用 该终点确定浪涌定价是否对该生效有效 产品/位置。在尝试提出乘车要求之前这样做 您可以通过发送给用户预先让用户确认激增 响应中提供的surge_confirmation_href。这个端点 将返回前期票价(在票价键中)或范围 估计(在估计密钥中)取决于的配置 产品
因此,您要回复的响应具体取决于产品配置:“upfront_fare_enabled”字段。如果有前期票价设置(upfront_fare_enabled = true),则响应中不会有“surge_confirmation_href” - 响应类型将是一个“票价”:{}响应 - 示例如下:
{
"fare": {
"value": 5.73,
"fare_id": "d30e732b8bba22c9cdc10513ee86380087cb4a6f89e37ad21ba2a39f3a1ba960",
"expires_at": 1476953293,
"display": "$5.73",
"currency_code": "USD",
"breakdown": [
{
"type": "promotion",
"value": -2.00,
"name": "Promotion"
},
{
"type": "base_fare",
"notice": "Fares are slightly higher due to increased demand",
"value": 7.73,
"name": "Base Fare"
}
]
},
"trip": {
"distance_unit": "mile",
"duration_estimate": 540,
"distance_estimate": 2.39
},
"pickup_estimate": 2
}
正如您所看到的,没有“surge_confirmation_href”可用。
如果您的产品有“upfront_fare_enabled”:false,您将通过surge_confirmation_id和surge_confirmation_href获得估算响应,如下所示:
{
"estimate": {
"surge_confirmation_href": "https:\/\/api.uber.com\/v1\/surge-confirmations\/7d604f5e",
"high_estimate": 11,
"surge_confirmation_id": "7d604f5e",
"minimum": 5,
"low_estimate": 8,
"fare_breakdown": [
{
"low_amount": 1.25,
"high_amount": 1.25,
"display_amount": "1.25",
"display_name": "Base Fare"
},
{
"low_amount": 1.92,
"high_amount": 2.57,
"display_amount": "1.92-2.57",
"display_name": "Distance"
},
{
"low_amount": 2.50,
"high_amount": 3.50,
"display_amount": "2.50-3.50",
"display_name": "Surge x1.5"
},
{
"low_amount": 1.25,
"high_amount": 1.25,
"display_amount": "1.25",
"display_name": "Booking Fee"
},
{
"low_amount": 1.36,
"high_amount": 1.81,
"display_amount": "1.36-1.81",
"display_name": "Time"
}
],
"surge_multiplier": 1.5,
"display": "$8-11",
"currency_code": "USD"
},
"trip": {
"distance_unit": "mile",
"duration_estimate": 480,
"distance_estimate": 1.95
},
"pickup_estimate": 2
}
最后,如果您将产品更新为“surge_multiplier”> 1,产品有“upfront_fare_enabled = true”,你会得到“票价”回复 - 但你不会知道飙升到位 - 直到你做骑车请求。在这种情况下,您将得到以下响应:“status”:409和“title”:“此产品的电涌定价当前有效。”和包含“href”的“surge_confirmation”信息:“https://sandbox-api.uber.com/surge-confirmations/ride_request_id”。因此,为了完成您的乘车请求 - 您需要将用户重定向到该URL - 用户需要确认激增。之后,您将能够创建新的乘车请求。
resposne->
{
"meta": {
"surge_confirmation": {
"href": "https://sandbox-api.uber.com/surge-confirmations/48165d0e-f2f4-457d-98d0-058a31b15cd7",
"expires_at": 1510684778,
"multiplier": 1.2,
"surge_confirmation_id": "48165d0e-f2f4-457d-98d0-058a31b15cd7"
}
},
"errors": [
{
"status": 409,
"code": "surge",
"title": "Surge pricing is currently in effect for this product."
}
]
}