qpowell / google_places

A Ruby wrapper around the Google Places API
MIT License
382 stars 188 forks source link

Is there a way to get the phone numbers? #91

Closed Lubard closed 7 years ago

Lubard commented 7 years ago

Hi there, I happened to realise that I cannot get the phone number for any results...

@formatted_phone_number=nil, @international_phone_number=nil

Is there a way to get them?

qpowell commented 7 years ago

@Lubard are you looking for the phone numbers in the client.spots(lat, lng) results? To have the phone numbers and other detailed spot information returned, be sure to pass in the detail argument like:

client.spots(latitude, longitude, detail: true)

This makes an extra call for each spot, but the collection returned will have all of the additional information you're looking for.

Also, if you just want to get this info for a single spot, you can use its place_id attribute to fetch its details:

client.spot(place_id)

Cheers!

Lubard commented 7 years ago

@qpowell

Thanks!

I was trying to find a way to fetch the details for client.spots_by_query("query")

Is this possible?

qpowell commented 7 years ago

@Lubard sorry, I just moved this week so it's been busy. I'll look at this tonight and get back to you.

qpowell commented 7 years ago

@Lubard it looks like the only way to do what you're requesting (at the moment) would be to take your collection from client.spots_by_query, and then request the detailed spot info for each item in the collection.

@edwinwills it seems pretty common for people that are requesting a collection of spots to want the full details for each spot. I have a couple of questions:

  1. Do you think it would make sense for spots_by_query to take a detail argument as well?
  2. At some point, would it make more sense to implement this at a higher level so that anything that returns a collection of spots also has the flexibility to return a collection of detailed spots?
Lubard commented 7 years ago

@qpowell Thanks ! I am currently using the query first then search for the details by id... I just worried that I may exceed the free daily limit... So I used it carefully

I thought it happens that someone wants to take details when the only thing they had was the name of the place.

edwinwills commented 7 years ago

@qpowell sorry, just been away on holiday, catching up now!

Agree that it would make sense to return the detail on the spots_by_query method, I was just a bit worried that if you called this on a large collection, you could quickly use a lot of API requests to Google, which might start to get expensive.

On 2, yeah it makes sense to refactor this all a bit so that we can just use the detail argument everywhere.

If you are happy with the increased API hits for details over a collection, I'll take a look at implementing.

qpowell commented 7 years ago

@edwinwills I agree with you about the increase in API requests. I think users could benefit from the flexibility of being able to get detailed spot information whenever they need it. I'm comfortable with providing that flexibility, as long as the docs warn the user about the downsides of requesting details on a collection.

edwinwills commented 7 years ago

@qpowell I've had a go at this, PR up at https://github.com/qpowell/google_places/pull/93 - let me know your thoughts.

edwinwills commented 7 years ago

@Lubard if you pull the latest version of the gem, you can now use the details: true argument on the spots_by_query method (although with the caveat that it will add an API call per record returned).