GET request endpoint results rider_id is null - uber-api

why is it that the riders have a null rider_id in the example? but the description says otherwise? riders[].rider_id : The hashed rider uuid. It doesnt say anything about it being may be null. Else what's the point of returning it. GET request
or is just an example, and the actual response has all of these ids not null
{
"product_id": "17cb78a7-b672-4d34-a288-a6c6e44d5315",
"request_id": "a1111c8c-c720-46c3-8534-2fcdd730040d",
"status": "accepted",
"surge_multiplier": 1.0,
"shared": true,
"driver": {
"phone_number": "(555)555-5555",
"sms_number": "(555)555-5555",
"rating": 5,
"picture_url": "https:\/\/d1w2poirtb3as9.cloudfront.net\/img.jpeg",
"name": "Bob"
},
"vehicle": {
"make": "Bugatti",
"model": "Veyron",
"license_plate": "I<3Uber",
"picture_url": "https:\/\/d1w2poirtb3as9.cloudfront.net\/car.jpeg"
},
"location": {
"latitude": 37.3382129093,
"longitude": -121.8863287568,
"bearing": 328
},
"pickup": {
"latitude": 37.3303463,
"longitude": -121.8890484,
"eta": 5
},
"destination": {
"latitude": 37.6213129,
"longitude": -122.3789554,
"eta": 19
},
"waypoints": [
{
"rider_id":null,
"latitude":37.77508531,
"type":"pickup",
"longitude":-122.3976683872
},
{
"rider_id":null,
"latitude":37.773133,
"type":"dropoff",
"longitude":-122.415069
},
{
"rider_id":"8KwsIO_YG6Y2jijSMf",
"latitude":37.7752423,
"type":"dropoff",
"longitude":-122.4175658
}
],
"riders": [
{
"rider_id":"8KwsIO_YG6Y2jijSMf",
"first_name":"Alec",
"me": true
},
{
"rider_id":null,
"first_name":"Kevin",
"me": false
}
]
}

The riders array, as specified in the GET /request/{request_id} reference page, is returned only for shared rides (uberPOOL rides). You will only be able to get a non-null rider_id if that rider account has already authenticated with your developer app.
This means that if any rider_id in the riders array is null, the rider account associated with that rider_id has not authenticated with your app.

Related

PTV Developer Routing API OpeningInterval is not applied

Im trying to calculate a route from Berlin to Rome using the Routing API with an openingInterval specified for the waypoint in Rome.
The openingInterval is not used, instead I’m getting a route violation for the openingInterval.
My request:
https://api.myptv.com/routing/v1/routes?options[trafficMode]=AVERAGE&options[startTime]=2022-01-25T13:00:00&results=VIOLATION_EVENTS,SCHEDULE_EVENTS
Body:
{
"waypoints": [
{
"offRoad": {
"latitude": 52.461790,
"longitude": 13.324184
}
},
{
"offRoad": {
"latitude": 41.889511,
"longitude": 12.381591,
"openingIntervals": [
{
"start": "2022-01-25T10:00:00",
"end": "2022-01-25T20:00:00"
}
]
}
}
]
}
I get the following response:
{
"distance": 1508861,
"travelTime": 68832,
"violated": true,
"events": [
{
"latitude": 52.461790044,
"longitude": 13.324184073,
"startsAt": "2022-01-25T13:00:00+01:00",
"distanceFromStart": 0,
"travelTimeFromStart": 0,
"countryCode": "DE",
"utcOffset": 60,
"schedule": {
"duration": 0,
"scheduleTypes": [
"SERVICE"
]
}
},
{
"latitude": 41.889511025,
"longitude": 12.381590967,
"startsAt": "2022-01-26T08:07:12+01:00",
"distanceFromStart": 1508861,
"travelTimeFromStart": 68832,
"countryCode": "IT",
"utcOffset": 60,
"violation": {
"type": "SCHEDULE",
"scheduleViolationTypes": [
"OPENING_INTERVAL"
]
},
"schedule": {
"duration": 0,
"scheduleTypes": [
"SERVICE"
]
}
}
]
}
The routing should arrive at around 7am in Rome and have to wait there for the openingInterval, but instead the route finishes without waiting.
What am I doing wrong?
While all waypoints are always open per default as soon as you set openingIntervals the waypoint will only be open during these intervals and closed otherwise.
In your case you are arriving on the next day since your route is quite long, while your openingInterval is specified for the same day.
If you don’t know if you will arrive on the same day you started the route, I suggest adding the openingInterval for the next day as well, like this:
{
"waypoints": [
{
"offRoad": {
"latitude": 52.461790,
"longitude": 13.324184
}
},
{
"offRoad": {
"latitude": 41.889511,
"longitude": 12.381591,
"openingIntervals": [
{
"start": "2021-01-25T10:00:00",
"end": "2021-01-25T20:00:00"
},
{
"start": "2021-01-26T10:00:00",
"end": "2021-01-26T20:00:00"
}
]
}
}
]
}

How get total distance and time from waypoints in HERE REST API

I need to get the total distance and time from waypoints in HERE REST API.
Now i use the routing api:
https://route.api.here.com/routing/7.2/calculateroute.json
"app_id=" + API_ID
"&app_code=" + APP_CODE
"&waypoint0=geo!" + fromCoordsLocation
"&waypoint1=geo!" + toCoordsLocation
"&mode=fastest;car"
and read them from json summary object (Response->Route->Summary). This method returns all the maneuvers and for long distances the callback is slow. there is something that allows only the summary (or the total distance and time) to be received?
Check out these additional properties so you can customize the request as you want. In this case I used representation = overview, your request will be
https://route.api.here.com/routing/7.2/calculateroute.json
"app_id=" + API_ID
"&app_code=" + APP_CODE
"&waypoint0=geo!" + fromCoordsLocation
"&waypoint1=geo!" + toCoordsLocation
"&mode=fastest;car&representation=overview"
The response will be decreased to 78 lines with default 232 lines:
{
"response": {
"metaInfo": {
"timestamp": "2019-11-14T10:03:16Z",
"mapVersion": "8.30.102.151",
"moduleVersion": "7.2.201945-5699",
"interfaceVersion": "2.6.74",
"availableMapVersion": [
"8.30.102.151"
]
},
"route": [
{
"waypoint": [
{
"linkId": "-53623477",
"mappedPosition": {
"latitude": 52.4999825,
"longitude": 13.3999652
},
"originalPosition": {
"latitude": 52.5,
"longitude": 13.4
},
"type": "stopOver",
"spot": 0.3538462,
"sideOfStreet": "left",
"mappedRoadName": "Neuenburger Straße",
"label": "Neuenburger Straße",
"shapeIndex": 0,
"source": "user"
},
{
"linkId": "+1215312511",
"mappedPosition": {
"latitude": 52.4992955,
"longitude": 13.4491968
},
"originalPosition": {
"latitude": 52.5,
"longitude": 13.45
},
"type": "stopOver",
"spot": 1.0,
"sideOfStreet": "left",
"mappedRoadName": "Schlesische Straße",
"label": "Schlesische Straße",
"shapeIndex": 56,
"source": "user"
}
],
"mode": {
"type": "fastest",
"transportModes": [
"car"
],
"trafficMode": "disabled",
"feature": []
},
"summary": {
"distance": 3847,
"trafficTime": 869,
"baseTime": 667,
"flags": [
"noThroughRoad",
"builtUpArea",
"park",
"privateRoad"
],
"text": "The trip takes <span class=\"length\">3.8 km</span> and <span class=\"time\">11 mins</span>.",
"travelTime": 667,
"_type": "RouteSummaryType"
}
}
],
"language": "en-us"
}
}

How to set review for revision using Gerrit REST API

I'm trying to setup Teamcity building and verifying patchsets from Gerrit. The last step should set Verified to -1 if build failed. I'm playing around with Gerrit REST API and I think I found a proper command:
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#set-review
The documentation says:
As response a ReviewInfo entity is returned that describes the applied
labels.
My request looks like this:
POST <gerrit-url>/a/changes/I696f00f4968fcb35fa614ce6325499aa15367150/revisions/current/review
{
"message": "Build failed",
"labels": {
"Verified": -1
}
}
As a response I get full revision info:
{
"id": "dev_test~master~<change-id>",
"project": "dev_test",
"branch": "master",
"hashtags": [],
"change_id": "<change-id>",
"subject": "a test",
"status": "NEW",
"created": "2017-04-03 07:53:19.000000000",
"updated": "2017-04-04 08:47:34.000000000",
"submit_type": "MERGE_IF_NECESSARY",
"mergeable": true,
"insertions": 133,
"deletions": 7,
"unresolved_comment_count": 0,
"_number": 381,
"owner": {
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>",
},
"labels": {
"Code-Review": {
"all": [
{
"value": 1,
"date": "2017-04-04 08:47:34.000000000",
"permitted_voting_range": {
"min": -2,
"max": 2
},
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>"
}
],
"values": {
"-2": "This shall not be merged",
"-1": "I would prefer this is not merged as is",
" 0": "No score",
"+1": "Looks good to me, but someone else must approve",
"+2": "Looks good to me, approved"
},
"default_value": 0
},
"Verified": {
"all": [
{
"value": 0,
"permitted_voting_range": {
"min": -1,
"max": 1
},
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>"
}
],
"values": {
"-1": "Fails",
" 0": "No score",
"+1": "Verified"
},
"default_value": 0
}
},
"permitted_labels": {},
"removable_reviewers": [],
"reviewers": {
"REVIEWER": [
{
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>"
}
]
},
"current_revision": "913330441711b067899a664a60c78be518e547b4",
"revisions": {
"913330441711b067899a664a60c78be518e547b4": {
"kind": "REWORK",
"_number": 6,
"created": "2017-04-03 14:08:14.000000000",
"uploader": {
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>"
},
"ref": "refs/changes/81/381/6",
"fetch": {
"ssh": {
"url": "ssh://<url>",
"ref": "refs/changes/81/381/6"
},
"http": {
"url": "http://<url>",
"ref": "refs/changes/81/381/6"
}
}
}
}
}
It's not affected by request. Same response is returned when I send request using GET method or using POST method with invalid JSON in body(!)
Gerrit version is: 2.13.6-3008-gcdc381e
Do I something wrong?
PS. Here is similar question, but it isn't helpful: Gerrit set-review api doesn't work
EDIT:
It seems that I getting response from GET request not POST
I figured it out. It's not gerrit problem. I used http request and our server redirected to https with 301 which the Postman fallowed and returned response for GET request.

HTTP requests are tampered by other HTTP requests, with golang and standard library

cat main.go:
```
package main
import (
"encoding/json"
"log"
"net"
"net/http"
"net/http/fcgi"
"os"
)
func main() {
//setup the config
configFile := "config.json"
fd, err := os.Open(configFile)
if err != nil {
log.Fatalf("Can't open config file: %v", configFile)
}
CFG := config{}
err = json.NewDecoder(fd).Decode(&CFG)
if err != nil {
log.Fatalf("parse config error: %v", err)
}
//init DB connection
db.InitConnectionInfo(CFG.Database.Host, CFG.Database.Port, CFG.Database.Database, CFG.Database.Username, CFG.Database.Password)
//register HTTP handler
sessionHandler := &handlers.SessionHandler{}
http.Handle("/sessions", sessionHandler)
http.Handle("/sessions/", sessionHandler)
userHandler := &handlers.UserHandler{
Facebook: &oa.OAuth{AppId: CFG.Facebook.Key, Secret: CFG.Facebook.Secret},
Sina: &oa.OAuth{AppId: CFG.Sina.Key, Secret: CFG.Sina.Secret},
Google: &oa.OAuth{AppId: CFG.Google.Key, Secret: CFG.Google.Secret},
Tencent: &oa.OAuth{AppId: CFG.Tencent.Key, Secret: CFG.Tencent.Secret},
Mixpanel: &hu.Share{Token: CFG.Mixpanel.Token},
FacebookShare: &hu.Share{Token: CFG.Facebook.Token},
SinaShare: &hu.Share{Token: CFG.Sina.Token},
GoogleShare: &hu.Share{Token: CFG.Google.Token},
TencentShare: &hu.Share{Token: CFG.Tencent.Token},
}
http.Handle("/users", userHandler)
http.Handle("/users/", userHandler)
//and so on ...
//run server
log.Println("start listen: ", CFG.FcgiAddr)
l, _ := net.Listen("tcp", CFG.FcgiAddr)
log.Fatalf("server error is %v", fcgi.Serve(l, nil))
//##select {}
log.Println("end listen")
}
```
build it and deploy behind nginx.
then client query /users/1234567/places, /users/1234567, and so on...
get the response is {blank data}, {normal user(1234567) data} or {normal user(1234567) data}, {normal user(1234567) data}.
same prefix of query, and same handler, looks like it is overload the response by subsequent HTTP request.
How can I do it?
May need me to give an example of a response:
correct response is :
{
"meta": {
"code": 200,
"text": "OK"
},
"data": {
"count": 21,
"place-tag-maps": [{
"id": "95842310160384",
"place-id": "95551731663150",
"tag-id": "95551579750669",
"ct": "2014-07-01T09:07:28Z"
}, {
"id": "95842310160385",
"place-id": "95551731663150",
"tag-id": "95551579750694",
"ct": "2015-01-15T17:41:23Z"
}, {
"id": "96262389694470",
"place-id": "95551731663150",
"tag-id": "95910120456455",
"ct": "2016-07-18T13:11:39Z"
}, ...],
"places": [{
"id": "95551731663150",
"name": "Kam Fung Restaurant",
"address": "G/F, 41 Spring Garden Ln",
"coordinate": {
"latitude": 22.275576,
"longitude": 114.172582
},
"telephone": "+852 2572 0526",
"city-id": "95530516807703",
"city": "Hong Kong",
"country": "Hong Kong",
"type": "4sq",
"ref-id": "4b1613f8f964a520cdb623e3",
"ct": "2016-02-23T07:42:43.565489Z",
"mt": "2017-02-22T09:35:48.302929Z",
"rating": 7.5,
"stats": {
"foursquare": {
"count": 111,
"value": 7.5
},
"spottly": {
"save-count": 12
}
},
"permanent-close": false,
"price": ""
}, ...],
"posts": [{
"collection-id": "95551746474003",
"coordinate": {
"latitude": 22.275576,
"longitude": 114.172582
},
"ct": "2017-02-22T09:35:47Z",
"facebook-tag-users": [],
"id": "97501586849795",
"medias": [],
"message": "",
"mt": "2017-02-22T09:35:47Z",
"owner-id": "96527264645120",
"place-id": "95551731663150",
"share-to": [],
"star": 5,
"status": "Done",
"tags": []
}, ...],
"users": [{
"id": "95551581323446",
"uid": "hk_epicurus",
"uid-ignore-case": "hk_epicurus",
"name": "Hk Epicurus",
"head": "https://d278wa0j9nq2mp.cloudfront.net/uploader/54aa335ddf4e63450002919a.jpeg",
"site": "www.hkepicurus.com",
"location": "Hong Kong",
"description": "Hong Kong Food \u0026 Travel Bear.\nGrew up in Aust, Malaysia, Tokyo \u0026 HK. \nInstagram: EpicurusHongKong\nFacebook, Spottly \u0026 Twitter: HK Epicurus \n微博: 香港美食-伊比\nFacebook Fans Page: http://on.fb.me/1qDyiIk",
"ct": "2013-10-13T19:12:41Z",
"mt": "2015-11-08T15:22:45Z"
}, ...]
}
}
and
{
"meta": {
"code": 200,
"text": "OK"
},
"data": {
"friends": [{
"id": "97331335725056",
"from-id": "97273770803200",
"to-id": "96527264645120",
"ct": "2017-01-23T07:58:41Z"
}],
"user": {
"ct": "2013-04-30T23:30:05Z",
"description": "Founder and Chief Everything Officer of Spottly. Loves to eat. Have a really bad memory. Wants to remember the best places and make travel research better",
"followers": {
"count": 41291
},
"followings": {
"count": 322
},
"head": "https://d278wa0j9nq2mp.cloudfront.net/uploader/525ffac8df4e6347870145ef.jpeg",
"id": "96527264645120",
"location": "Vancouver | Hong Kong | Beijing ",
"mt": "2015-10-27T09:47:12Z",
"name": "Edwyn Chan",
"site": "http://spottly.com/edwyn",
"uid": "edwyn",
"uid-ignore-case": "edwyn"
}
}
}
but mistake response is
{
"meta": {
"code": 200,
"text": "OK"
}
}
and
{
"meta": {
"code": 200,
"text": "OK"
},
"data": {
"friends": [{
"id": "97331335725056",
"from-id": "97273770803200",
"to-id": "96527264645120",
"ct": "2017-01-23T07:58:41Z"
}],
"user": {
"ct": "2013-04-30T23:30:05Z",
"description": "Founder and Chief Everything Officer of Spottly. Loves to eat. Have a really bad memory. Wants to remember the best places and make travel research better",
"followers": {
"count": 41291
},
"followings": {
"count": 322
},
"head": "https://d278wa0j9nq2mp.cloudfront.net/uploader/525ffac8df4e6347870145ef.jpeg",
"id": "96527264645120",
"location": "Vancouver | Hong Kong | Beijing ",
"mt": "2015-10-27T09:47:12Z",
"name": "Edwyn Chan",
"site": "http://spottly.com/edwyn",
"uid": "edwyn",
"uid-ignore-case": "edwyn"
}
}
}
the first response is error. or it's same as the second response.
sequence request is correct response, parallel request is incorrect response.
problem resolved。
the basic reason is this case:
var x = &{...} //init value
fillX(..., x) //fill the fields of x pointer
//here the fields of x pointer is not same to inner of fillX func
so, change to
var x = &{...}
x = fullX(..., x)
the problem resolved.
but why go pointer is the behavior?
Finally, this problem resolved.
Because the http.Handle register path-pattern and handler pair, the handler is construct by register time only-once, not for any request of path-pattern.
if record info within handler, It will been change by after request.

Is it possible to get the country code of a user from Facebook's Graph API?

When i tried to get the current location of a user via FQL, Graph API returned something like this;
{
"data": [
{
"current_location": {
"city": "Izmir",
"state": "Izmir",
"country": "Turkey",
"zip": "",
"id": 107968765903327,
"name": "İzmir, Turkey"
}
}
]
}
Using the Graph ID above, i checked the location information from https://graph.facebook.com/107968765903327 and this time i get more data about the city;
{
"id": "107968765903327",
"name": "\u0130zmir, Turkey",
"link": "http://www.facebook.com/pages/\u0025C4\u0025B0zmir-Turkey/107968765903327",
"likes": 178460,
"category": "City",
"is_published": true,
"is_community_page": true,
"description": "\u003Cp>\u003Cb>Izmir\u003C/b> is a large ...",
"location": {
"latitude": 38.4072,
"longitude": 27.1503
},
"checkins": 9059,
"talking_about_count": 238710
}
But, as you see, there is no chance for the country code with these options. Any other suggestions?
reverse geocode could help
see https://developers.google.com/maps/documentation/geocoding/