Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError on #price_estimates for coordinates over 100 miles #33

Open
Drowze opened this issue Jul 13, 2017 · 0 comments
Open

NoMethodError on #price_estimates for coordinates over 100 miles #33

Drowze opened this issue Jul 13, 2017 · 0 comments

Comments

@Drowze
Copy link

Drowze commented Jul 13, 2017

The gem breaks when the distance between two coordinates is over 100 miles.
#34 is a PR that fixes the problem just for reference - be warned that it breaks the requests endpoint (since it passes useful information on the error response, and I am simply throwing an error for any 4xx & 5xx response).

I'd like to see suggestions on a good way to catch this 100 miles error (that seems a bummer, really)

Details:

[2] pry(main)> $uber.price_estimations(start_latitude: -23.434553, start_longitude: -46.478126, end_latitude: -23.460275, end_longitude: -40)
NoMethodError: undefined method `each' for "Distance between two points exceeds 100 miles":String
from /home/giba/.rvm/gems/ruby-2.4.1/gems/uber-ruby-0.9.0/lib/uber/base.rb:12:in `initialize'

Uber API details (for reference):

Request (v1.2)

curl -H 'Authorization: Token <TOKEN>' \
     -H 'Accept-Language: en_US' \
     -H 'Content-Type: application/json' \
     'https://api.uber.com/v1.2/estimates/price?start_latitude=37.7752315&start_longitude=-122.418075&end_latitude=37.7752415&end_longitude=-120.518075'

Response (v1.2)

{
	"fields": {
		"start_longitude": "Distance between two points exceeds 100 miles",
		"end_longitude": "Distance between two points exceeds 100 miles",
		"start_latitude": "Distance between two points exceeds 100 miles",
		"end_latitude": "Distance between two points exceeds 100 miles"
	},
	"message": "Distance between two points exceeds 100 miles",
	"code": "distance_exceeded"
}

Request (v1)

curl -H 'Authorization: Token <TOKEN>' \
     -H 'Accept-Language: en_US' \
     -H 'Content-Type: application/json' \
     'https://api.uber.com/v1/estimates/price?start_latitude=37.7752315&start_longitude=-122.418075&end_latitude=37.7752415&end_longitude=-120.518075' 

Response (v1)

{
	"fields": {
		"start_longitude": "Distance between two points exceeds 100 miles",
		"end_longitude": "Distance between two points exceeds 100 miles",
		"start_latitude": "Distance between two points exceeds 100 miles",
		"end_latitude": "Distance between two points exceeds 100 miles"
	},
	"message": "Distance between two points exceeds 100 miles",
	"code": "distance_exceeded"
}
@Drowze Drowze changed the title Price estimates on over 100 miles NoMethodError on #price_estimates for coordinates over 100 miles Jul 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant