feat(distance): add Distance API support #7
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds full Distance API support to the Ruby SDK, matching the PHP SDK implementation. This enables distance calculations between coordinates with support for multiple coordinate formats, driving mode, and async job processing.
Changes
New Methods
distance(origin, destinations, options)- Calculate distances from single origin to multiple destinationsdistanceMatrix(origins, destinations, options)- Calculate full distance matrix (multiple origins × destinations)createDistanceMatrixJob(name, origins, destinations, options)- Create async distance matrix jobsdistanceMatrixJobStatus(id)- Check job statusdistanceMatrixJobs(page)- List all distance jobs (paginated)getDistanceMatrixJobResults(id)- Get completed job results as parsed JSONdownloadDistanceMatrixJob(id, file_path)- Download results to filedeleteDistanceMatrixJob(id)- Delete a jobEnhanced Methods
geocode()- Added optional distance parameters via keyword argumentsreverse()- Added optional distance parameters via keyword argumentsFeatures
"lat,lng,id"), array ([lat, lng, id]), hash ({lat:, lng:, id:}):straightline(default),:driving(with duration),:haversine:miles(default),:kilometers/:kmmax_results,max_distance,min_distance,max_duration,min_durationorder_by(:distance/:duration),sort(:asc/:desc)Infrastructure
Test Plan
distance()with string coordinatesdistance()with array coordinate formatdistance()with hash coordinate formatdistance()with driving mode (includes duration)distance()with kilometers unitdistance()with filtering options (max_results, order_by, sort)distanceMatrix()with multiple origins/destinationsdistanceMatrix()with driving modecreateDistanceMatrixJob()with coordinatesdistanceMatrixJobStatus()returns job datadistanceMatrixJobs()returns paginated listgeocode()with destinations parameterreverse()with destinations parameterAll tests verified against local API server using
manual_test.rb.