google-maps-platform-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +169 -0
- data/bin/console +15 -0
- data/lib/google_maps_platform/api_helper.rb +10 -0
- data/lib/google_maps_platform/apis/base_api.rb +67 -0
- data/lib/google_maps_platform/apis/directions_api.rb +341 -0
- data/lib/google_maps_platform/apis/distance_matrix_api.rb +224 -0
- data/lib/google_maps_platform/apis/elevation_api.rb +71 -0
- data/lib/google_maps_platform/apis/geocoding_api.rb +214 -0
- data/lib/google_maps_platform/apis/geolocation_api.rb +46 -0
- data/lib/google_maps_platform/apis/places_api.rb +866 -0
- data/lib/google_maps_platform/apis/roads_api.rb +81 -0
- data/lib/google_maps_platform/apis/street_view_api.rb +198 -0
- data/lib/google_maps_platform/apis/time_zone_api.rb +65 -0
- data/lib/google_maps_platform/client.rb +123 -0
- data/lib/google_maps_platform/configuration.rb +181 -0
- data/lib/google_maps_platform/exceptions/api_exception.rb +21 -0
- data/lib/google_maps_platform/exceptions/error_response_exception.rb +48 -0
- data/lib/google_maps_platform/exceptions/nearest_roads_error_response_exception.rb +46 -0
- data/lib/google_maps_platform/http/api_response.rb +19 -0
- data/lib/google_maps_platform/http/auth/custom_query_authentication.rb +52 -0
- data/lib/google_maps_platform/http/http_call_back.rb +10 -0
- data/lib/google_maps_platform/http/http_method_enum.rb +10 -0
- data/lib/google_maps_platform/http/http_request.rb +10 -0
- data/lib/google_maps_platform/http/http_response.rb +10 -0
- data/lib/google_maps_platform/http/proxy_settings.rb +22 -0
- data/lib/google_maps_platform/logging/configuration/api_logging_configuration.rb +186 -0
- data/lib/google_maps_platform/logging/sdk_logger.rb +17 -0
- data/lib/google_maps_platform/models/address_component.rb +97 -0
- data/lib/google_maps_platform/models/base_model.rb +110 -0
- data/lib/google_maps_platform/models/bounds.rb +85 -0
- data/lib/google_maps_platform/models/business_status.rb +41 -0
- data/lib/google_maps_platform/models/cell_tower.rb +146 -0
- data/lib/google_maps_platform/models/directions_geocoded_waypoint.rb +181 -0
- data/lib/google_maps_platform/models/directions_leg.rb +224 -0
- data/lib/google_maps_platform/models/directions_polyline.rb +93 -0
- data/lib/google_maps_platform/models/directions_response.rb +185 -0
- data/lib/google_maps_platform/models/directions_route.rb +188 -0
- data/lib/google_maps_platform/models/directions_status.rb +94 -0
- data/lib/google_maps_platform/models/directions_step.rb +216 -0
- data/lib/google_maps_platform/models/directions_traffic_speed_entry.rb +84 -0
- data/lib/google_maps_platform/models/directions_transit_agency.rb +95 -0
- data/lib/google_maps_platform/models/directions_transit_details.rb +176 -0
- data/lib/google_maps_platform/models/directions_transit_line.rb +152 -0
- data/lib/google_maps_platform/models/directions_transit_stop.rb +83 -0
- data/lib/google_maps_platform/models/directions_transit_vehicle.rb +126 -0
- data/lib/google_maps_platform/models/directions_via_waypoint.rb +99 -0
- data/lib/google_maps_platform/models/distance_matrix_element.rb +132 -0
- data/lib/google_maps_platform/models/distance_matrix_element_status.rb +48 -0
- data/lib/google_maps_platform/models/distance_matrix_response.rb +149 -0
- data/lib/google_maps_platform/models/distance_matrix_row.rb +89 -0
- data/lib/google_maps_platform/models/distance_matrix_status.rb +74 -0
- data/lib/google_maps_platform/models/elevation_response.rb +132 -0
- data/lib/google_maps_platform/models/elevation_result.rb +99 -0
- data/lib/google_maps_platform/models/elevation_status.rb +65 -0
- data/lib/google_maps_platform/models/error_detail.rb +135 -0
- data/lib/google_maps_platform/models/error_object.rb +130 -0
- data/lib/google_maps_platform/models/fare.rb +92 -0
- data/lib/google_maps_platform/models/field_violation.rb +82 -0
- data/lib/google_maps_platform/models/geocoder_status.rb +37 -0
- data/lib/google_maps_platform/models/geocoding_geometry.rb +117 -0
- data/lib/google_maps_platform/models/geocoding_response.rb +140 -0
- data/lib/google_maps_platform/models/geocoding_result.rb +174 -0
- data/lib/google_maps_platform/models/geocoding_status.rb +71 -0
- data/lib/google_maps_platform/models/geolocation_request.rb +166 -0
- data/lib/google_maps_platform/models/geolocation_response.rb +91 -0
- data/lib/google_maps_platform/models/geometry.rb +84 -0
- data/lib/google_maps_platform/models/inputtype.rb +36 -0
- data/lib/google_maps_platform/models/language.rb +240 -0
- data/lib/google_maps_platform/models/lat_lng_literal.rb +83 -0
- data/lib/google_maps_platform/models/latitude_longitude_literal.rb +83 -0
- data/lib/google_maps_platform/models/location_type.rb +54 -0
- data/lib/google_maps_platform/models/location_type1.rb +44 -0
- data/lib/google_maps_platform/models/maneuver.rb +110 -0
- data/lib/google_maps_platform/models/maps_api_elevation_json_response.rb +132 -0
- data/lib/google_maps_platform/models/maxprice.rb +48 -0
- data/lib/google_maps_platform/models/minprice.rb +48 -0
- data/lib/google_maps_platform/models/mode.rb +44 -0
- data/lib/google_maps_platform/models/nearest_roads_error.rb +90 -0
- data/lib/google_maps_platform/models/nearest_roads_response.rb +86 -0
- data/lib/google_maps_platform/models/place.rb +647 -0
- data/lib/google_maps_platform/models/place_autocomplete_matched_substring.rb +82 -0
- data/lib/google_maps_platform/models/place_autocomplete_prediction.rb +181 -0
- data/lib/google_maps_platform/models/place_autocomplete_structured_format.rb +136 -0
- data/lib/google_maps_platform/models/place_autocomplete_term.rb +83 -0
- data/lib/google_maps_platform/models/place_editorial_summary.rb +87 -0
- data/lib/google_maps_platform/models/place_opening_hours.rb +138 -0
- data/lib/google_maps_platform/models/place_opening_hours_period.rb +84 -0
- data/lib/google_maps_platform/models/place_opening_hours_period_detail.rb +108 -0
- data/lib/google_maps_platform/models/place_photo.rb +109 -0
- data/lib/google_maps_platform/models/place_review.rb +186 -0
- data/lib/google_maps_platform/models/place_special_day.rb +93 -0
- data/lib/google_maps_platform/models/places_autocomplete_response.rb +141 -0
- data/lib/google_maps_platform/models/places_autocomplete_status.rb +66 -0
- data/lib/google_maps_platform/models/places_details_response.rb +131 -0
- data/lib/google_maps_platform/models/places_details_status.rb +71 -0
- data/lib/google_maps_platform/models/places_find_place_from_text_response.rb +145 -0
- data/lib/google_maps_platform/models/places_nearby_search_response.rb +171 -0
- data/lib/google_maps_platform/models/places_query_autocomplete_response.rb +141 -0
- data/lib/google_maps_platform/models/places_search_status.rb +66 -0
- data/lib/google_maps_platform/models/places_text_search_response.rb +171 -0
- data/lib/google_maps_platform/models/plus_code.rb +92 -0
- data/lib/google_maps_platform/models/rankby.rb +36 -0
- data/lib/google_maps_platform/models/region.rb +1052 -0
- data/lib/google_maps_platform/models/result.rb +96 -0
- data/lib/google_maps_platform/models/result_type.rb +112 -0
- data/lib/google_maps_platform/models/snap_to_roads_response.rb +96 -0
- data/lib/google_maps_platform/models/snapped_point.rb +103 -0
- data/lib/google_maps_platform/models/source.rb +36 -0
- data/lib/google_maps_platform/models/street_view_response.rb +135 -0
- data/lib/google_maps_platform/models/street_view_status.rb +71 -0
- data/lib/google_maps_platform/models/text_value_object.rb +82 -0
- data/lib/google_maps_platform/models/time_zone_response.rb +154 -0
- data/lib/google_maps_platform/models/time_zone_status.rb +68 -0
- data/lib/google_maps_platform/models/time_zone_text_value_object.rb +94 -0
- data/lib/google_maps_platform/models/traffic_model.rb +40 -0
- data/lib/google_maps_platform/models/transit_routing_preference.rb +36 -0
- data/lib/google_maps_platform/models/travel_mode.rb +48 -0
- data/lib/google_maps_platform/models/type.rb +140 -0
- data/lib/google_maps_platform/models/type1.rb +112 -0
- data/lib/google_maps_platform/models/units.rb +36 -0
- data/lib/google_maps_platform/models/wi_fi_access_point.rb +119 -0
- data/lib/google_maps_platform/utilities/date_time_helper.rb +11 -0
- data/lib/google_maps_platform/utilities/file_wrapper.rb +28 -0
- data/lib/google_maps_platform.rb +153 -0
- metadata +211 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ad09d10352ee3d9940a0c508939350da344142ed26ad26df0dbaf08bf28da98c
|
|
4
|
+
data.tar.gz: c0ed41a4f1f36b6975fe444fc0a50a33717e65c6eeb803fb09943ec782f6e18e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0b7e11145415b5671aea38b5be2ff41526fddd18f97ddd15c008c186cf6b730d8f9e7d5cc22a6f515488e3e3a7045290cea366dfe3610ca065cc46ed23de02f8
|
|
7
|
+
data.tar.gz: f81232f8077101c1c1ee22a03a0cc641de54a11ec405215aceefd221cc75e5311ccbe66c8e2e4c2b6b269ca3e48c2f6d2a671b86bf2f0491252a482cb6822e2b
|
data/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
License:
|
|
2
|
+
========
|
|
3
|
+
The MIT License (MIT)
|
|
4
|
+
http://opensource.org/licenses/MIT
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2014 - 2026 APIMATIC Limited
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
|
16
|
+
all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
|
25
|
+
|
|
26
|
+
Trade Mark:
|
|
27
|
+
==========
|
|
28
|
+
APIMATIC is a trade mark for APIMATIC Limited
|
data/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
|
|
2
|
+
# Getting Started with Google Maps Platform
|
|
3
|
+
|
|
4
|
+
## Introduction
|
|
5
|
+
|
|
6
|
+
API Specification for Google Maps Platform
|
|
7
|
+
|
|
8
|
+
## Install the Package
|
|
9
|
+
|
|
10
|
+
Install the gem from the command line:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
gem install google-maps-platform-sdk -v 1.0.0
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or add the gem to your Gemfile and run `bundle`:
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
gem 'google-maps-platform-sdk', '1.0.0'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
For additional gem details, see the [RubyGems page for the google-maps-platform-sdk gem](https://rubygems.org/gems/google-maps-platform-sdk/versions/1.0.0).
|
|
23
|
+
|
|
24
|
+
## IRB Console Usage
|
|
25
|
+
|
|
26
|
+
You can explore the SDK interactively using IRB in two ways
|
|
27
|
+
|
|
28
|
+
### 1. Use IRB with Installed Gem
|
|
29
|
+
|
|
30
|
+
Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and type the following command to start the irb console.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
irb
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Now you can load the SDK in the IRB
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
require 'google_maps_platform'
|
|
40
|
+
include GoogleMapsPlatform
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Use IRB within SDK
|
|
44
|
+
|
|
45
|
+
Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and navigate to the root folder of SDK.
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
cd path/to/google_maps_platform
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Now you can start the preconfigured irb console by running the following command
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
ruby bin/console
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**_Note:_** This automatically loads the SDK from lib/
|
|
58
|
+
|
|
59
|
+
## Initialize the API Client
|
|
60
|
+
|
|
61
|
+
**_Note:_** Documentation for the client can be found [here.](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/client.md)
|
|
62
|
+
|
|
63
|
+
The following parameters are configurable for the API Client:
|
|
64
|
+
|
|
65
|
+
| Parameter | Type | Description |
|
|
66
|
+
| --- | --- | --- |
|
|
67
|
+
| environment | [`Environment`](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/README.md#environments) | The API environment. <br> **Default: `Environment.PRODUCTION`** |
|
|
68
|
+
| connection | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
|
|
69
|
+
| adapter | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
|
|
70
|
+
| timeout | `Float` | The value to use for connection timeout. <br> **Default: 30** |
|
|
71
|
+
| max_retries | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
|
|
72
|
+
| retry_interval | `Float` | Pause in seconds between retries. <br> **Default: 1** |
|
|
73
|
+
| backoff_factor | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
|
|
74
|
+
| retry_statuses | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
|
|
75
|
+
| retry_methods | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
|
|
76
|
+
| http_callback | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
|
|
77
|
+
| proxy_settings | [`ProxySettings`](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
|
|
78
|
+
| logging_configuration | [`LoggingConfiguration`](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/logging-configuration.md) | The SDK logging configuration for API calls |
|
|
79
|
+
| custom_query_authentication_credentials | [`CustomQueryAuthenticationCredentials`](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/auth/custom-query-parameter.md) | The credential object for Custom Query Parameter |
|
|
80
|
+
|
|
81
|
+
The API client can be initialized as follows:
|
|
82
|
+
|
|
83
|
+
### Code-Based Client Initialization
|
|
84
|
+
|
|
85
|
+
```ruby
|
|
86
|
+
require 'google_maps_platform'
|
|
87
|
+
include GoogleMapsPlatform
|
|
88
|
+
|
|
89
|
+
client = Client.new(
|
|
90
|
+
custom_query_authentication_credentials: CustomQueryAuthenticationCredentials.new(
|
|
91
|
+
key: 'key'
|
|
92
|
+
),
|
|
93
|
+
environment: Environment::PRODUCTION,
|
|
94
|
+
logging_configuration: LoggingConfiguration.new(
|
|
95
|
+
log_level: Logger::INFO,
|
|
96
|
+
request_logging_config: RequestLoggingConfiguration.new(
|
|
97
|
+
log_body: true
|
|
98
|
+
),
|
|
99
|
+
response_logging_config: ResponseLoggingConfiguration.new(
|
|
100
|
+
log_headers: true
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Environment-Based Client Initialization
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
require 'google_maps_platform'
|
|
110
|
+
include GoogleMapsPlatform
|
|
111
|
+
|
|
112
|
+
# Create client from environment
|
|
113
|
+
client = Client.from_env
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
See the [`Environment-Based Client Initialization`](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md) section for details.
|
|
117
|
+
|
|
118
|
+
## Environments
|
|
119
|
+
|
|
120
|
+
The SDK can be configured to use a different environment for making API calls. Available environments are:
|
|
121
|
+
|
|
122
|
+
### Fields
|
|
123
|
+
|
|
124
|
+
| Name | Description |
|
|
125
|
+
| --- | --- |
|
|
126
|
+
| PRODUCTION | **Default** |
|
|
127
|
+
| ENVIRONMENT2 | - |
|
|
128
|
+
| ENVIRONMENT3 | - |
|
|
129
|
+
|
|
130
|
+
## Authorization
|
|
131
|
+
|
|
132
|
+
This API uses the following authentication schemes.
|
|
133
|
+
|
|
134
|
+
* [`ApiKeyAuth (Custom Query Parameter)`](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/auth/custom-query-parameter.md)
|
|
135
|
+
|
|
136
|
+
## List of APIs
|
|
137
|
+
|
|
138
|
+
* [Geolocation API](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/controllers/geolocation-api.md)
|
|
139
|
+
* [Directions API](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/controllers/directions-api.md)
|
|
140
|
+
* [Elevation API](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/controllers/elevation-api.md)
|
|
141
|
+
* [Geocoding API](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/controllers/geocoding-api.md)
|
|
142
|
+
* [Time Zone API](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/controllers/time-zone-api.md)
|
|
143
|
+
* [Roads API](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/controllers/roads-api.md)
|
|
144
|
+
* [Distance Matrix API](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/controllers/distance-matrix-api.md)
|
|
145
|
+
* [Places API](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/controllers/places-api.md)
|
|
146
|
+
* [Street View API](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/controllers/street-view-api.md)
|
|
147
|
+
|
|
148
|
+
## SDK Infrastructure
|
|
149
|
+
|
|
150
|
+
### Configuration
|
|
151
|
+
|
|
152
|
+
* [ProxySettings](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/proxy-settings.md)
|
|
153
|
+
* [Environment-Based Client Initialization](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md)
|
|
154
|
+
* [AbstractLogger](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/abstract-logger.md)
|
|
155
|
+
* [LoggingConfiguration](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/logging-configuration.md)
|
|
156
|
+
* [RequestLoggingConfiguration](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/request-logging-configuration.md)
|
|
157
|
+
* [ResponseLoggingConfiguration](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/response-logging-configuration.md)
|
|
158
|
+
|
|
159
|
+
### HTTP
|
|
160
|
+
|
|
161
|
+
* [HttpResponse](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/http-response.md)
|
|
162
|
+
* [HttpRequest](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/http-request.md)
|
|
163
|
+
|
|
164
|
+
### Utilities
|
|
165
|
+
|
|
166
|
+
* [ApiResponse](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/api-response.md)
|
|
167
|
+
* [ApiHelper](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/api-helper.md)
|
|
168
|
+
* [DateTimeHelper](https://www.github.com/sdks-io/google-maps-platform-ruby-sdk/tree/1.0.0/doc/date-time-helper.md)
|
|
169
|
+
|
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# Load the lib folder into Ruby's load path
|
|
4
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
|
|
5
|
+
|
|
6
|
+
# Require the gem
|
|
7
|
+
require 'google_maps_platform'
|
|
8
|
+
|
|
9
|
+
puts 'GoogleMapsPlatform SDK loaded!'
|
|
10
|
+
puts 'You can now create a client with: client = GoogleMapsPlatform::Client.new'
|
|
11
|
+
puts 'Or use from_env: client = GoogleMapsPlatform::Client.from_env'
|
|
12
|
+
|
|
13
|
+
# Start an interactive IRB session
|
|
14
|
+
require 'irb'
|
|
15
|
+
IRB.start
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# google_maps_platform
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC
|
|
4
|
+
# v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module GoogleMapsPlatform
|
|
7
|
+
# BaseApi.
|
|
8
|
+
class BaseApi
|
|
9
|
+
include CoreLibrary
|
|
10
|
+
attr_accessor :config, :http_call_back
|
|
11
|
+
|
|
12
|
+
def self.user_agent
|
|
13
|
+
'Ruby-SDK/1.0.0 (OS: {os-info}, Engine: {engine}/{engine-version})'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.user_agent_parameters
|
|
17
|
+
{
|
|
18
|
+
'{engine}' => { 'value' => RUBY_ENGINE, 'encode' => false },
|
|
19
|
+
'{engine-version}' => { 'value' => RUBY_ENGINE_VERSION, 'encode' => false },
|
|
20
|
+
'{os-info}' => { 'value' => RUBY_PLATFORM, 'encode' => false }
|
|
21
|
+
}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
GLOBAL_ERRORS = {
|
|
25
|
+
'default' => ErrorCase.new
|
|
26
|
+
.error_message('HTTP response not OK.')
|
|
27
|
+
.exception_type(APIException)
|
|
28
|
+
}.freeze
|
|
29
|
+
|
|
30
|
+
# Initialization constructor.
|
|
31
|
+
# @param [GlobalConfiguration] global_configuration The instance of GlobalConfiguration.
|
|
32
|
+
def initialize(global_configuration)
|
|
33
|
+
@global_configuration = global_configuration
|
|
34
|
+
@config = @global_configuration.client_configuration
|
|
35
|
+
@http_call_back = @config.http_callback
|
|
36
|
+
@api_call = ApiCall.new(@global_configuration)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Creates a new instance of the request builder.
|
|
40
|
+
# @param [String] http_method The HTTP method to use in the request.
|
|
41
|
+
# @param [String] path The endpoint path to use in the request.
|
|
42
|
+
# @param [String] server The server to extract the base uri for the request.
|
|
43
|
+
# @return [RequestBuilder] The instance of RequestBuilder.
|
|
44
|
+
def new_request_builder(http_method, path, server)
|
|
45
|
+
RequestBuilder.new
|
|
46
|
+
.http_method(http_method)
|
|
47
|
+
.path(path)
|
|
48
|
+
.server(server)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Creates a new instance of the response handler.
|
|
52
|
+
# @return [ResponseHandler] The instance of ResponseHandler.
|
|
53
|
+
def new_response_handler
|
|
54
|
+
ResponseHandler.new
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Creates a new instance of the parameter.
|
|
58
|
+
# @param [String|optional] key The key of the parameter.
|
|
59
|
+
# @param [Object] value The value of the parameter.
|
|
60
|
+
# @return [Parameter] The instance of Parameter.
|
|
61
|
+
def new_parameter(value, key: nil)
|
|
62
|
+
Parameter.new
|
|
63
|
+
.key(key)
|
|
64
|
+
.value(value)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# google_maps_platform
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC
|
|
4
|
+
# v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module GoogleMapsPlatform
|
|
7
|
+
# DirectionsApi
|
|
8
|
+
class DirectionsApi < BaseApi
|
|
9
|
+
# The Directions API is a web service that uses an HTTP request to return
|
|
10
|
+
# JSON or XML-formatted directions between locations. You can receive
|
|
11
|
+
# directions for several modes of transportation, such as transit, driving,
|
|
12
|
+
# walking, or cycling.
|
|
13
|
+
# @param [String] destination Required parameter: The place ID, address, or
|
|
14
|
+
# textual latitude/longitude value to which you wish to calculate
|
|
15
|
+
# directions. The options for the destination parameter are the same as for
|
|
16
|
+
# the origin parameter.
|
|
17
|
+
# @param [String] origin Required parameter: The place ID, address, or
|
|
18
|
+
# textual latitude/longitude value from which you wish to calculate
|
|
19
|
+
# directions. * Place IDs must be prefixed with `place_id:`. You can
|
|
20
|
+
# retrieve place IDs from the Geocoding API and the Places API (including
|
|
21
|
+
# Place Autocomplete). For an example using place IDs from Place
|
|
22
|
+
# Autocomplete, see [Place Autocomplete and
|
|
23
|
+
# Directions](https://developers.google.com/maps/documentation/javascript/ex
|
|
24
|
+
# amples/places-autocomplete-directions). For more about place IDs, see the
|
|
25
|
+
# [Place ID
|
|
26
|
+
# overview](https://developers.google.com/maps/documentation/places/web-serv
|
|
27
|
+
# ice/place-id). ``` origin=place_id:ChIJ3S-JXmauEmsRUcIaWtf4MzE
|
|
28
|
+
# ``` * If you pass an address, the Directions service geocodes the
|
|
29
|
+
# string and converts it to a latitude/longitude coordinate to calculate
|
|
30
|
+
# directions. This coordinate may be different from that returned by the
|
|
31
|
+
# Geocoding API, for example a building entrance rather than its center.
|
|
32
|
+
# ``` origin=24+Sussex+Drive+Ottawa+ON ``` Using place IDs is
|
|
33
|
+
# preferred over using addresses or latitude/longitude coordinates. Using
|
|
34
|
+
# coordinates will always result in the point being snapped to the road
|
|
35
|
+
# nearest to those coordinates - which may not be an access point to the
|
|
36
|
+
# property, or even a road that will quickly or safely lead to the
|
|
37
|
+
# destination. * If you pass coordinates, the point will snap to the nearest
|
|
38
|
+
# road. Passing a place ID is preferred. If you do pass coordinates, ensure
|
|
39
|
+
# that no space exists between the latitude and longitude values. ```
|
|
40
|
+
# origin=41.43206,-81.38992 ``` * Plus codes must be formatted as a
|
|
41
|
+
# global code or a compound code. Format plus codes as shown here (plus
|
|
42
|
+
# signs are url-escaped to `%2B` and spaces are url-escaped to `%20`).
|
|
43
|
+
# * **Global code** is a 4 character area code and 6 character or longer
|
|
44
|
+
# local code (849VCWC8+R9 is `849VCWC8%2BR9`). * **Compound code** is a 6
|
|
45
|
+
# character or longer local code with an explicit location (CWC8+R9 Mountain
|
|
46
|
+
# View, CA, USA is `CWC8%2BR9%20Mountain%20View%20CA%20USA`). <div
|
|
47
|
+
# class="note">Note: For efficiency and accuracy, use place ID's when
|
|
48
|
+
# possible. These ID's are uniquely explicit like a lat/lng value pair and
|
|
49
|
+
# provide geocoding benefits for routing such as access points and traffic
|
|
50
|
+
# variables. Unlike an address, ID's do not require the service to perform a
|
|
51
|
+
# search or an intermediate request for place details; therefore,
|
|
52
|
+
# performance is better.</div>
|
|
53
|
+
# @param [Float] arrival_time Optional parameter: Specifies the desired time
|
|
54
|
+
# of arrival for transit directions, in seconds since midnight, January 1,
|
|
55
|
+
# 1970 UTC. You can specify either `departure_time` or `arrival_time`, but
|
|
56
|
+
# not both. Note that `arrival_time` must be specified as an integer.
|
|
57
|
+
# @param [Float] departure_time Optional parameter: Specifies the desired
|
|
58
|
+
# time of departure. You can specify the time as an integer in seconds since
|
|
59
|
+
# midnight, January 1, 1970 UTC. If a `departure_time` later than
|
|
60
|
+
# 9999-12-31T23:59:59.999999999Z is specified, the API will fall back the
|
|
61
|
+
# `departure_time` to 9999-12-31T23:59:59.999999999Z. Alternatively, you can
|
|
62
|
+
# specify a value of now, which sets the departure time to the current time
|
|
63
|
+
# (correct to the nearest second). The departure time may be specified in
|
|
64
|
+
# two cases: * For requests where the travel mode is transit: You can
|
|
65
|
+
# optionally specify one of `departure_time` or `arrival_time`. If neither
|
|
66
|
+
# time is specified, the `departure_time` defaults to now (that is, the
|
|
67
|
+
# departure time defaults to the current time). * For requests where the
|
|
68
|
+
# travel mode is driving: You can specify the `departure_time` to receive a
|
|
69
|
+
# route and trip duration (response field: duration_in_traffic) that take
|
|
70
|
+
# traffic conditions into account. The `departure_time` must be set to the
|
|
71
|
+
# current time or some time in the future. It cannot be in the past. <div
|
|
72
|
+
# class="note">Note: If departure time is not specified, choice of route and
|
|
73
|
+
# duration are based on road network and average time-independent traffic
|
|
74
|
+
# conditions. Results for a given request may vary over time due to changes
|
|
75
|
+
# in the road network, updated average traffic conditions, and the
|
|
76
|
+
# distributed nature of the service. Results may also vary between
|
|
77
|
+
# nearly-equivalent routes at any time or frequency.</div> <div
|
|
78
|
+
# class="note">Note: Distance Matrix requests specifying `departure_time`
|
|
79
|
+
# when `mode=driving` are limited to a maximum of 100 elements per request.
|
|
80
|
+
# The number of origins times the number of destinations defines the number
|
|
81
|
+
# of elements.</div>
|
|
82
|
+
# @param [TrueClass | FalseClass] alternatives Optional parameter: If set to
|
|
83
|
+
# `true`, specifies that the Directions service may provide more than one
|
|
84
|
+
# route alternative in the response. Note that providing route alternatives
|
|
85
|
+
# may increase the response time from the server. This is only available for
|
|
86
|
+
# requests without intermediate waypoints. For more information, see the
|
|
87
|
+
# [guide to
|
|
88
|
+
# waypoints](https://developers.google.com/maps/documentation/directions/get
|
|
89
|
+
# -directions#Waypoints).
|
|
90
|
+
# @param [String] avoid Optional parameter: Indicates that the calculated
|
|
91
|
+
# route(s) should avoid the indicated features. This parameter supports the
|
|
92
|
+
# following arguments: * `tolls` indicates that the calculated route should
|
|
93
|
+
# avoid toll roads/bridges. * `highways` indicates that the calculated route
|
|
94
|
+
# should avoid highways. * `ferries` indicates that the calculated route
|
|
95
|
+
# should avoid ferries. * `indoor` indicates that the calculated route
|
|
96
|
+
# should avoid indoor steps for walking and transit directions. It's
|
|
97
|
+
# possible to request a route that avoids any combination of tolls, highways
|
|
98
|
+
# and ferries by passing multiple restrictions to the avoid parameter. For
|
|
99
|
+
# example: ``` avoid=tolls|highways|ferries. ```
|
|
100
|
+
# @param [Units] units Optional parameter: Specifies the unit system to use
|
|
101
|
+
# when displaying results. Directions results contain text within distance
|
|
102
|
+
# fields that may be displayed to the user to indicate the distance of a
|
|
103
|
+
# particular "step" of the route. By default, this text uses the unit system
|
|
104
|
+
# of the origin's country or region. For example, a route from "Chicago,
|
|
105
|
+
# IL" to "Toronto, ONT" will display results in miles, while the reverse
|
|
106
|
+
# route will display results in kilometers. You may override this unit
|
|
107
|
+
# system by setting one explicitly within the request's units parameter,
|
|
108
|
+
# passing one of the following values: * `metric` specifies usage of the
|
|
109
|
+
# metric system. Textual distances are returned using kilometers and meters.
|
|
110
|
+
# * `imperial` specifies usage of the Imperial (English) system. Textual
|
|
111
|
+
# distances are returned using miles and feet. <div class="note">Note: this
|
|
112
|
+
# unit system setting only affects the text displayed within distance
|
|
113
|
+
# fields. The distance fields also contain values which are always expressed
|
|
114
|
+
# in meters.</div>
|
|
115
|
+
# @param [String] waypoints Optional parameter: <div
|
|
116
|
+
# class="caution">Caution: Requests using more than 10 waypoints (between 11
|
|
117
|
+
# and 25), or waypoint optimization, are billed at a higher rate. <a
|
|
118
|
+
# href="https://developers.google.com/maps/billing-and-pricing/pricing#direc
|
|
119
|
+
# tions-advanced">Learn more about billing</a> for Google Maps Platform
|
|
120
|
+
# products.</div> Specifies an array of intermediate locations to include
|
|
121
|
+
# along the route between the origin and destination points as pass through
|
|
122
|
+
# or stopover locations. Waypoints alter a route by directing it through the
|
|
123
|
+
# specified location(s). The API supports waypoints for these travel modes:
|
|
124
|
+
# driving, walking and bicycling; not transit. You can supply one or more
|
|
125
|
+
# locations separated by the pipe character (`|` or `%7C`), in the form of a
|
|
126
|
+
# place ID, an address, or latitude/longitude coordinates. By default, the
|
|
127
|
+
# Directions service calculates a route using the waypoints in the order
|
|
128
|
+
# they are given. The precedence for parsing the value of the waypoint is
|
|
129
|
+
# place ID, latitude/longitude coordinates, then address. * If you pass a
|
|
130
|
+
# place ID, you must prefix it with `place_id:`. You can retrieve place IDs
|
|
131
|
+
# from the Geocoding API and the Places API (including Place Autocomplete).
|
|
132
|
+
# For an example using place IDs from Place Autocomplete, see [Place
|
|
133
|
+
# Autocomplete and
|
|
134
|
+
# Directions](/maps/documentation/javascript/examples/places-autocomplete-di
|
|
135
|
+
# rections). For more about place IDs, see the [Place ID
|
|
136
|
+
# overview](/maps/documentation/places/web-service/place-id). <div
|
|
137
|
+
# class="note">For efficiency and accuracy, use place ID's when possible.
|
|
138
|
+
# These ID's are uniquely explicit like a lat/lng value pair and provide
|
|
139
|
+
# geocoding benefits for routing such as access points and traffic
|
|
140
|
+
# variables. Unlike an address, ID's do not require the service to perform a
|
|
141
|
+
# search or an intermediate request for place details; therefore,
|
|
142
|
+
# performance is better.</div> * If you pass latitude/longitude coordinates,
|
|
143
|
+
# the values go directly to the front-end server to calculate directions
|
|
144
|
+
# without geocoding. The points are snapped to roads and might not provide
|
|
145
|
+
# the accuracy your app needs. Use coordinates when you are confident the
|
|
146
|
+
# values truly specify the points your app needs for routing without regard
|
|
147
|
+
# to possible access points or additional geocoding details. Ensure that a
|
|
148
|
+
# comma (`%2C`) and not a space (`%20`) separates the latitude and longitude
|
|
149
|
+
# values. * If you pass an address, the Directions service will geocode the
|
|
150
|
+
# string and convert it into latitude/longitude coordinates to calculate
|
|
151
|
+
# directions. If the address value is ambiguous, the value might evoke a
|
|
152
|
+
# search to disambiguate from similar addresses. For example, "1st Street"
|
|
153
|
+
# could be a complete value or a partial value for "1st street NE" or "1st
|
|
154
|
+
# St SE". This result may be different from that returned by the Geocoding
|
|
155
|
+
# API. You can avoid possible misinterpretations using place IDs. *
|
|
156
|
+
# Alternatively, you can supply an encoded set of points using the [Encoded
|
|
157
|
+
# Polyline
|
|
158
|
+
# Algorithm](https://developers.google.com/maps/documentation/utilities/poly
|
|
159
|
+
# linealgorithm). You will find an encoded set is useful for a large number
|
|
160
|
+
# of waypoints, because the URL is significantly shorter. All web services
|
|
161
|
+
# have a URL limit of 8192 characters. * Encoded polylines must be
|
|
162
|
+
# prefixed with `enc:` and followed by a colon (`:`). For example:
|
|
163
|
+
# `waypoints=enc:gfo}EtohhU:`. * You can also include multiple encoded
|
|
164
|
+
# polylines, separated by the pipe character (`|`). For example,
|
|
165
|
+
# `waypoints=via:enc:wc~oAwquwMdlTxiKtqLyiK:|enc:c~vnAamswMvlTor@tjGi}L:|
|
|
166
|
+
# via:enc:udymA{~bxM:` ##### Influence routes with stopover and pass
|
|
167
|
+
# through points For each waypoint in the request, the directions response
|
|
168
|
+
# appends an entry to the `legs` array to provide the details for stopovers
|
|
169
|
+
# on that leg of the journey. If you'd like to influence the route using
|
|
170
|
+
# waypoints without adding a stopover, add the prefix `via:` to the
|
|
171
|
+
# waypoint. Waypoints prefixed with `via:` will not add an entry to the
|
|
172
|
+
# `legs` array, but will route the journey through the waypoint. The
|
|
173
|
+
# following URL modifies the previous request such that the journey is
|
|
174
|
+
# routed through Lexington without stopping: ```
|
|
175
|
+
# https://maps.googleapis.com/maps/api/directions/json?
|
|
176
|
+
# origin=Boston,MA&destination=Concord,MA
|
|
177
|
+
# &waypoints=Charlestown,MA|via:Lexington,MA ``` The `via:` prefix is
|
|
178
|
+
# most effective when creating routes in response to the user dragging the
|
|
179
|
+
# waypoints on the map. Doing so allows the user to see how the final route
|
|
180
|
+
# may look in real-time and helps ensure that waypoints are placed in
|
|
181
|
+
# locations that are accessible to the Directions API. <div
|
|
182
|
+
# class="caution">Caution: Using the `via:` prefix to avoid stopovers
|
|
183
|
+
# results in directions that are strict in their interpretation of the
|
|
184
|
+
# waypoint. This interpretation may result in severe detours on the route or
|
|
185
|
+
# `ZERO_RESULTS` in the response status code if the Directions API is unable
|
|
186
|
+
# to create directions through that point.</div> ##### Optimize your
|
|
187
|
+
# waypoints By default, the Directions service calculates a route through
|
|
188
|
+
# the provided waypoints in their given order. Optionally, you may pass
|
|
189
|
+
# `optimize:true` as the first argument within the waypoints parameter to
|
|
190
|
+
# allow the Directions service to optimize the provided route by rearranging
|
|
191
|
+
# the waypoints in a more efficient order. (This optimization is an
|
|
192
|
+
# application of the traveling salesperson problem.) Travel time is the
|
|
193
|
+
# primary factor which is optimized, but other factors such as distance,
|
|
194
|
+
# number of turns and many more may be taken into account when deciding
|
|
195
|
+
# which route is the most efficient. All waypoints must be stopovers for the
|
|
196
|
+
# Directions service to optimize their route. If you instruct the
|
|
197
|
+
# Directions service to optimize the order of its waypoints, their order
|
|
198
|
+
# will be returned in the `waypoint_order` field within the routes object.
|
|
199
|
+
# The `waypoint_order` field returns values which are zero-based. The
|
|
200
|
+
# following example calculates a road journey from Adelaide, South Australia
|
|
201
|
+
# to each of South Australia's main wine regions using route optimization.
|
|
202
|
+
# ``` https://maps.googleapis.com/maps/api/directions/json?
|
|
203
|
+
# origin=Adelaide,SA&destination=Adelaide,SA
|
|
204
|
+
# &waypoints=optimize:true|Barossa+Valley,SA|Clare,SA|Connawarra,SA|McLaren+
|
|
205
|
+
# Vale,SA ``` Inspection of the calculated route will indicate that
|
|
206
|
+
# calculation uses waypoints in the following waypoint order: ```
|
|
207
|
+
# "waypoint_order": [ 3, 2, 0, 1 ] ``` <div class="caution">Caution:
|
|
208
|
+
# Requests using waypoint optimization are billed at a higher rate. <a
|
|
209
|
+
# href="https://developers.google.com/maps/billing-and-pricing/pricing#direc
|
|
210
|
+
# tions-advanced">Learn more about how Google Maps Platform products are
|
|
211
|
+
# billed.</a></div>
|
|
212
|
+
# @param [Language] language Optional parameter: The language in which to
|
|
213
|
+
# return results. * See the [list of supported
|
|
214
|
+
# languages](https://developers.google.com/maps/faq#languagesupport). Google
|
|
215
|
+
# often updates the supported languages, so this list may not be exhaustive.
|
|
216
|
+
# * If `language` is not supplied, the API attempts to use the preferred
|
|
217
|
+
# language as specified in the `Accept-Language` header. * The API does its
|
|
218
|
+
# best to provide a street address that is readable for both the user and
|
|
219
|
+
# locals. To achieve that goal, it returns street addresses in the local
|
|
220
|
+
# language, transliterated to a script readable by the user if necessary,
|
|
221
|
+
# observing the preferred language. All other addresses are returned in the
|
|
222
|
+
# preferred language. Address components are all returned in the same
|
|
223
|
+
# language, which is chosen from the first component. * If a name is not
|
|
224
|
+
# available in the preferred language, the API uses the closest match. * The
|
|
225
|
+
# preferred language has a small influence on the set of results that the
|
|
226
|
+
# API chooses to return, and the order in which they are returned. The
|
|
227
|
+
# geocoder interprets abbreviations differently depending on language, such
|
|
228
|
+
# as the abbreviations for street types, or synonyms that may be valid in
|
|
229
|
+
# one language but not in another. For example, _utca_ and _tér_ are
|
|
230
|
+
# synonyms for street in Hungarian.
|
|
231
|
+
# @param [Mode] mode Optional parameter: For the calculation of distances
|
|
232
|
+
# and directions, you may specify the transportation mode to use. By
|
|
233
|
+
# default, `DRIVING` mode is used. By default, directions are calculated as
|
|
234
|
+
# driving directions. The following travel modes are supported: * `driving`
|
|
235
|
+
# (default) indicates standard driving directions or distance using the road
|
|
236
|
+
# network. * `walking` requests walking directions or distance via
|
|
237
|
+
# pedestrian paths & sidewalks (where available). * `bicycling` requests
|
|
238
|
+
# bicycling directions or distance via bicycle paths & preferred streets
|
|
239
|
+
# (where available). * `transit` requests directions or distance via public
|
|
240
|
+
# transit routes (where available). Transit trips are available for up to 7
|
|
241
|
+
# days in the past or 100 days in the future. If you set the mode to
|
|
242
|
+
# transit, you can optionally specify either a `departure_time` or an
|
|
243
|
+
# `arrival_time`. If neither time is specified, the `departure_time`
|
|
244
|
+
# defaults to now (that is, the departure time defaults to the current
|
|
245
|
+
# time). You can also optionally include a `transit_mode` and/or a
|
|
246
|
+
# `transit_routing_preference`. <div class="note">Note: Both walking and
|
|
247
|
+
# bicycling directions may sometimes not include clear pedestrian or
|
|
248
|
+
# bicycling paths, so these directions will return warnings in the returned
|
|
249
|
+
# result which you must display to the user.</div>
|
|
250
|
+
# @param [Region] region Optional parameter: The region code, specified as a
|
|
251
|
+
# [ccTLD ("top-level
|
|
252
|
+
# domain")](https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains
|
|
253
|
+
# #Country_code_top-level_domains) two-character value. Most ccTLD codes are
|
|
254
|
+
# identical to ISO 3166-1 codes, with some notable exceptions. For example,
|
|
255
|
+
# the United Kingdom's ccTLD is "uk" (.co.uk) while its ISO 3166-1 code is
|
|
256
|
+
# "gb" (technically for the entity of "The United Kingdom of Great Britain
|
|
257
|
+
# and Northern Ireland").
|
|
258
|
+
# @param [TrafficModel] traffic_model Optional parameter: Specifies the
|
|
259
|
+
# assumptions to use when calculating time in traffic. This setting affects
|
|
260
|
+
# the value returned in the duration_in_traffic field in the response, which
|
|
261
|
+
# contains the predicted time in traffic based on historical averages. The
|
|
262
|
+
# `traffic_model` parameter may only be specified for driving directions
|
|
263
|
+
# where the request includes a `departure_time`. The available values for
|
|
264
|
+
# this parameter are: * `best_guess` (default) indicates that the returned
|
|
265
|
+
# duration_in_traffic should be the best estimate of travel time given what
|
|
266
|
+
# is known about both historical traffic conditions and live traffic. Live
|
|
267
|
+
# traffic becomes more important the closer the `departure_time` is to now.
|
|
268
|
+
# * `pessimistic` indicates that the returned duration_in_traffic should be
|
|
269
|
+
# longer than the actual travel time on most days, though occasional days
|
|
270
|
+
# with particularly bad traffic conditions may exceed this value. *
|
|
271
|
+
# `optimistic` indicates that the returned duration_in_traffic should be
|
|
272
|
+
# shorter than the actual travel time on most days, though occasional days
|
|
273
|
+
# with particularly good traffic conditions may be faster than this value.
|
|
274
|
+
# The default value of `best_guess` will give the most useful predictions
|
|
275
|
+
# for the vast majority of use cases. It is possible the `best_guess` travel
|
|
276
|
+
# time prediction may be shorter than `optimistic`, or alternatively, longer
|
|
277
|
+
# than `pessimistic`, due to the way the `best_guess` prediction model
|
|
278
|
+
# integrates live traffic information.
|
|
279
|
+
# @param [String] transit_mode Optional parameter: Specifies one or more
|
|
280
|
+
# preferred modes of transit. This parameter may only be specified for
|
|
281
|
+
# transit directions. The parameter supports the following arguments: *
|
|
282
|
+
# `bus` indicates that the calculated route should prefer travel by bus. *
|
|
283
|
+
# `subway` indicates that the calculated route should prefer travel by
|
|
284
|
+
# subway. * `train` indicates that the calculated route should prefer travel
|
|
285
|
+
# by train. * `tram` indicates that the calculated route should prefer
|
|
286
|
+
# travel by tram and light rail. * `rail` indicates that the calculated
|
|
287
|
+
# route should prefer travel by train, tram, light rail, and subway. This is
|
|
288
|
+
# equivalent to `transit_mode=train|tram|subway`.
|
|
289
|
+
# @param [TransitRoutingPreference] transit_routing_preference Optional
|
|
290
|
+
# parameter: Specifies preferences for transit routes. Using this parameter,
|
|
291
|
+
# you can bias the options returned, rather than accepting the default best
|
|
292
|
+
# route chosen by the API. This parameter may only be specified for transit
|
|
293
|
+
# directions. The parameter supports the following arguments: *
|
|
294
|
+
# `less_walking` indicates that the calculated route should prefer limited
|
|
295
|
+
# amounts of walking. * `fewer_transfers` indicates that the calculated
|
|
296
|
+
# route should prefer a limited number of transfers.
|
|
297
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
298
|
+
def directions(destination,
|
|
299
|
+
origin,
|
|
300
|
+
arrival_time: nil,
|
|
301
|
+
departure_time: nil,
|
|
302
|
+
alternatives: nil,
|
|
303
|
+
avoid: nil,
|
|
304
|
+
units: nil,
|
|
305
|
+
waypoints: nil,
|
|
306
|
+
language: Language::EN,
|
|
307
|
+
mode: nil,
|
|
308
|
+
region: Region::EN,
|
|
309
|
+
traffic_model: TrafficModel::BEST_GUESS,
|
|
310
|
+
transit_mode: nil,
|
|
311
|
+
transit_routing_preference: nil)
|
|
312
|
+
@api_call
|
|
313
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
314
|
+
'/maps/api/directions/json',
|
|
315
|
+
Server::DEFAULT)
|
|
316
|
+
.query_param(new_parameter(destination, key: 'destination')
|
|
317
|
+
.is_required(true))
|
|
318
|
+
.query_param(new_parameter(origin, key: 'origin')
|
|
319
|
+
.is_required(true))
|
|
320
|
+
.query_param(new_parameter(arrival_time, key: 'arrival_time'))
|
|
321
|
+
.query_param(new_parameter(departure_time, key: 'departure_time'))
|
|
322
|
+
.query_param(new_parameter(alternatives, key: 'alternatives'))
|
|
323
|
+
.query_param(new_parameter(avoid, key: 'avoid'))
|
|
324
|
+
.query_param(new_parameter(units, key: 'units'))
|
|
325
|
+
.query_param(new_parameter(waypoints, key: 'waypoints'))
|
|
326
|
+
.query_param(new_parameter(language, key: 'language'))
|
|
327
|
+
.query_param(new_parameter(mode, key: 'mode'))
|
|
328
|
+
.query_param(new_parameter(region, key: 'region'))
|
|
329
|
+
.query_param(new_parameter(traffic_model, key: 'traffic_model'))
|
|
330
|
+
.query_param(new_parameter(transit_mode, key: 'transit_mode'))
|
|
331
|
+
.query_param(new_parameter(transit_routing_preference, key: 'transit_routing_preference'))
|
|
332
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
333
|
+
.auth(Single.new('ApiKeyAuth')))
|
|
334
|
+
.response(new_response_handler
|
|
335
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
336
|
+
.deserialize_into(DirectionsResponse.method(:from_hash))
|
|
337
|
+
.is_api_response(true))
|
|
338
|
+
.execute
|
|
339
|
+
end
|
|
340
|
+
end
|
|
341
|
+
end
|