google-maps-api-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.
Files changed (127) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +169 -0
  4. data/bin/console +15 -0
  5. data/lib/google_maps_platform/api_helper.rb +10 -0
  6. data/lib/google_maps_platform/client.rb +123 -0
  7. data/lib/google_maps_platform/configuration.rb +181 -0
  8. data/lib/google_maps_platform/controllers/base_controller.rb +67 -0
  9. data/lib/google_maps_platform/controllers/directions_api_controller.rb +341 -0
  10. data/lib/google_maps_platform/controllers/distance_matrix_api_controller.rb +224 -0
  11. data/lib/google_maps_platform/controllers/elevation_api_controller.rb +71 -0
  12. data/lib/google_maps_platform/controllers/geocoding_api_controller.rb +214 -0
  13. data/lib/google_maps_platform/controllers/geolocation_api_controller.rb +46 -0
  14. data/lib/google_maps_platform/controllers/places_api_controller.rb +866 -0
  15. data/lib/google_maps_platform/controllers/roads_api_controller.rb +81 -0
  16. data/lib/google_maps_platform/controllers/street_view_api_controller.rb +198 -0
  17. data/lib/google_maps_platform/controllers/time_zone_api_controller.rb +65 -0
  18. data/lib/google_maps_platform/exceptions/api_exception.rb +21 -0
  19. data/lib/google_maps_platform/exceptions/error_response_exception.rb +48 -0
  20. data/lib/google_maps_platform/exceptions/nearest_roads_error_response_exception.rb +46 -0
  21. data/lib/google_maps_platform/http/api_response.rb +19 -0
  22. data/lib/google_maps_platform/http/auth/custom_query_authentication.rb +52 -0
  23. data/lib/google_maps_platform/http/http_call_back.rb +10 -0
  24. data/lib/google_maps_platform/http/http_method_enum.rb +10 -0
  25. data/lib/google_maps_platform/http/http_request.rb +10 -0
  26. data/lib/google_maps_platform/http/http_response.rb +10 -0
  27. data/lib/google_maps_platform/http/proxy_settings.rb +22 -0
  28. data/lib/google_maps_platform/logging/configuration/api_logging_configuration.rb +186 -0
  29. data/lib/google_maps_platform/logging/sdk_logger.rb +17 -0
  30. data/lib/google_maps_platform/models/address_component.rb +97 -0
  31. data/lib/google_maps_platform/models/base_model.rb +110 -0
  32. data/lib/google_maps_platform/models/bounds.rb +85 -0
  33. data/lib/google_maps_platform/models/business_status.rb +41 -0
  34. data/lib/google_maps_platform/models/cell_tower.rb +146 -0
  35. data/lib/google_maps_platform/models/directions_geocoded_waypoint.rb +181 -0
  36. data/lib/google_maps_platform/models/directions_leg.rb +224 -0
  37. data/lib/google_maps_platform/models/directions_polyline.rb +93 -0
  38. data/lib/google_maps_platform/models/directions_response.rb +185 -0
  39. data/lib/google_maps_platform/models/directions_route.rb +188 -0
  40. data/lib/google_maps_platform/models/directions_status.rb +94 -0
  41. data/lib/google_maps_platform/models/directions_step.rb +216 -0
  42. data/lib/google_maps_platform/models/directions_traffic_speed_entry.rb +84 -0
  43. data/lib/google_maps_platform/models/directions_transit_agency.rb +95 -0
  44. data/lib/google_maps_platform/models/directions_transit_details.rb +176 -0
  45. data/lib/google_maps_platform/models/directions_transit_line.rb +152 -0
  46. data/lib/google_maps_platform/models/directions_transit_stop.rb +83 -0
  47. data/lib/google_maps_platform/models/directions_transit_vehicle.rb +126 -0
  48. data/lib/google_maps_platform/models/directions_via_waypoint.rb +99 -0
  49. data/lib/google_maps_platform/models/distance_matrix_element.rb +132 -0
  50. data/lib/google_maps_platform/models/distance_matrix_element_status.rb +48 -0
  51. data/lib/google_maps_platform/models/distance_matrix_response.rb +149 -0
  52. data/lib/google_maps_platform/models/distance_matrix_row.rb +89 -0
  53. data/lib/google_maps_platform/models/distance_matrix_status.rb +74 -0
  54. data/lib/google_maps_platform/models/elevation_response.rb +132 -0
  55. data/lib/google_maps_platform/models/elevation_result.rb +99 -0
  56. data/lib/google_maps_platform/models/elevation_status.rb +65 -0
  57. data/lib/google_maps_platform/models/error_detail.rb +135 -0
  58. data/lib/google_maps_platform/models/error_object.rb +130 -0
  59. data/lib/google_maps_platform/models/fare.rb +92 -0
  60. data/lib/google_maps_platform/models/field_violation.rb +82 -0
  61. data/lib/google_maps_platform/models/geocoder_status.rb +37 -0
  62. data/lib/google_maps_platform/models/geocoding_geometry.rb +117 -0
  63. data/lib/google_maps_platform/models/geocoding_response.rb +140 -0
  64. data/lib/google_maps_platform/models/geocoding_result.rb +174 -0
  65. data/lib/google_maps_platform/models/geocoding_status.rb +71 -0
  66. data/lib/google_maps_platform/models/geolocation_request.rb +166 -0
  67. data/lib/google_maps_platform/models/geolocation_response.rb +91 -0
  68. data/lib/google_maps_platform/models/geometry.rb +84 -0
  69. data/lib/google_maps_platform/models/inputtype.rb +36 -0
  70. data/lib/google_maps_platform/models/language.rb +240 -0
  71. data/lib/google_maps_platform/models/lat_lng_literal.rb +83 -0
  72. data/lib/google_maps_platform/models/latitude_longitude_literal.rb +83 -0
  73. data/lib/google_maps_platform/models/location_type.rb +54 -0
  74. data/lib/google_maps_platform/models/location_type1.rb +44 -0
  75. data/lib/google_maps_platform/models/maneuver.rb +110 -0
  76. data/lib/google_maps_platform/models/maps_api_elevation_json_response.rb +132 -0
  77. data/lib/google_maps_platform/models/maxprice.rb +48 -0
  78. data/lib/google_maps_platform/models/minprice.rb +48 -0
  79. data/lib/google_maps_platform/models/mode.rb +44 -0
  80. data/lib/google_maps_platform/models/nearest_roads_error.rb +90 -0
  81. data/lib/google_maps_platform/models/nearest_roads_response.rb +86 -0
  82. data/lib/google_maps_platform/models/place.rb +647 -0
  83. data/lib/google_maps_platform/models/place_autocomplete_matched_substring.rb +82 -0
  84. data/lib/google_maps_platform/models/place_autocomplete_prediction.rb +181 -0
  85. data/lib/google_maps_platform/models/place_autocomplete_structured_format.rb +136 -0
  86. data/lib/google_maps_platform/models/place_autocomplete_term.rb +83 -0
  87. data/lib/google_maps_platform/models/place_editorial_summary.rb +87 -0
  88. data/lib/google_maps_platform/models/place_opening_hours.rb +138 -0
  89. data/lib/google_maps_platform/models/place_opening_hours_period.rb +84 -0
  90. data/lib/google_maps_platform/models/place_opening_hours_period_detail.rb +108 -0
  91. data/lib/google_maps_platform/models/place_photo.rb +109 -0
  92. data/lib/google_maps_platform/models/place_review.rb +186 -0
  93. data/lib/google_maps_platform/models/place_special_day.rb +93 -0
  94. data/lib/google_maps_platform/models/places_autocomplete_response.rb +141 -0
  95. data/lib/google_maps_platform/models/places_autocomplete_status.rb +66 -0
  96. data/lib/google_maps_platform/models/places_details_response.rb +131 -0
  97. data/lib/google_maps_platform/models/places_details_status.rb +71 -0
  98. data/lib/google_maps_platform/models/places_find_place_from_text_response.rb +145 -0
  99. data/lib/google_maps_platform/models/places_nearby_search_response.rb +171 -0
  100. data/lib/google_maps_platform/models/places_query_autocomplete_response.rb +141 -0
  101. data/lib/google_maps_platform/models/places_search_status.rb +66 -0
  102. data/lib/google_maps_platform/models/places_text_search_response.rb +171 -0
  103. data/lib/google_maps_platform/models/plus_code.rb +92 -0
  104. data/lib/google_maps_platform/models/rankby.rb +36 -0
  105. data/lib/google_maps_platform/models/region.rb +1052 -0
  106. data/lib/google_maps_platform/models/result.rb +96 -0
  107. data/lib/google_maps_platform/models/result_type.rb +112 -0
  108. data/lib/google_maps_platform/models/snap_to_roads_response.rb +96 -0
  109. data/lib/google_maps_platform/models/snapped_point.rb +103 -0
  110. data/lib/google_maps_platform/models/source.rb +36 -0
  111. data/lib/google_maps_platform/models/street_view_response.rb +135 -0
  112. data/lib/google_maps_platform/models/street_view_status.rb +71 -0
  113. data/lib/google_maps_platform/models/text_value_object.rb +82 -0
  114. data/lib/google_maps_platform/models/time_zone_response.rb +154 -0
  115. data/lib/google_maps_platform/models/time_zone_status.rb +68 -0
  116. data/lib/google_maps_platform/models/time_zone_text_value_object.rb +94 -0
  117. data/lib/google_maps_platform/models/traffic_model.rb +40 -0
  118. data/lib/google_maps_platform/models/transit_routing_preference.rb +36 -0
  119. data/lib/google_maps_platform/models/travel_mode.rb +48 -0
  120. data/lib/google_maps_platform/models/type.rb +140 -0
  121. data/lib/google_maps_platform/models/type1.rb +112 -0
  122. data/lib/google_maps_platform/models/units.rb +36 -0
  123. data/lib/google_maps_platform/models/wi_fi_access_point.rb +119 -0
  124. data/lib/google_maps_platform/utilities/date_time_helper.rb +11 -0
  125. data/lib/google_maps_platform/utilities/file_wrapper.rb +28 -0
  126. data/lib/google_maps_platform.rb +154 -0
  127. metadata +210 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b72309f1e004cb72e09b8b263575e6375528e61b21b0ad4a1b1a5bfaf924ca65
4
+ data.tar.gz: b9575710ced4199609f912001357ee050144fe6c2f470052aac7ed0cd1a06def
5
+ SHA512:
6
+ metadata.gz: 4916da49f00fd6010ddfa8b69123ce602b7334884328ff692184e9d8daf9bda8b188e915acc8292468726fdada17c750a6d7bc10988cd6c80ee0ac5239c08954
7
+ data.tar.gz: 91e24aa6b9a22cab3d5913970ca317f92acc3e93f03b059d508592cf7e58d6bbcd169ee7cc186235cb4fa11e33b1bace5cf86d2b01124a4db79918eb8d329420
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-api-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-api-sdk', '1.0.0'
20
+ ```
21
+
22
+ For additional gem details, see the [RubyGems page for the google-maps-api-sdk gem](https://rubygems.org/gems/google-maps-api-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/apimatic/google-maps-api-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/apimatic/google-maps-api-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/apimatic/google-maps-api-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/apimatic/google-maps-api-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/apimatic/google-maps-api-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/apimatic/google-maps-api-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/apimatic/google-maps-api-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/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/controllers/geolocation-api.md)
139
+ * [Directions API](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/controllers/directions-api.md)
140
+ * [Elevation API](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/controllers/elevation-api.md)
141
+ * [Geocoding API](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/controllers/geocoding-api.md)
142
+ * [Time Zone API](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/controllers/time-zone-api.md)
143
+ * [Roads API](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/controllers/roads-api.md)
144
+ * [Distance Matrix API](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/controllers/distance-matrix-api.md)
145
+ * [Places API](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/controllers/places-api.md)
146
+ * [Street View API](https://www.github.com/apimatic/google-maps-api-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/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/proxy-settings.md)
153
+ * [Environment-Based Client Initialization](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/environment-based-client-initialization.md)
154
+ * [AbstractLogger](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/abstract-logger.md)
155
+ * [LoggingConfiguration](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/logging-configuration.md)
156
+ * [RequestLoggingConfiguration](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/request-logging-configuration.md)
157
+ * [ResponseLoggingConfiguration](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/response-logging-configuration.md)
158
+
159
+ ### HTTP
160
+
161
+ * [HttpResponse](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/http-response.md)
162
+ * [HttpRequest](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/http-request.md)
163
+
164
+ ### Utilities
165
+
166
+ * [ApiResponse](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/api-response.md)
167
+ * [ApiHelper](https://www.github.com/apimatic/google-maps-api-ruby-sdk/tree/1.0.0/doc/api-helper.md)
168
+ * [DateTimeHelper](https://www.github.com/apimatic/google-maps-api-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,10 @@
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
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,123 @@
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
+ # google_maps_platform client class.
8
+ class Client
9
+ include CoreLibrary
10
+ attr_reader :config, :auth_managers
11
+
12
+ def user_agent_detail
13
+ config.user_agent_detail
14
+ end
15
+
16
+ # Access to geolocation_api controller.
17
+ # @return [GeolocationApiController] Returns the controller instance.
18
+ def geolocation_api
19
+ @geolocation_api ||= GeolocationApiController.new @global_configuration
20
+ end
21
+
22
+ # Access to directions_api controller.
23
+ # @return [DirectionsApiController] Returns the controller instance.
24
+ def directions_api
25
+ @directions_api ||= DirectionsApiController.new @global_configuration
26
+ end
27
+
28
+ # Access to elevation_api controller.
29
+ # @return [ElevationApiController] Returns the controller instance.
30
+ def elevation_api
31
+ @elevation_api ||= ElevationApiController.new @global_configuration
32
+ end
33
+
34
+ # Access to geocoding_api controller.
35
+ # @return [GeocodingApiController] Returns the controller instance.
36
+ def geocoding_api
37
+ @geocoding_api ||= GeocodingApiController.new @global_configuration
38
+ end
39
+
40
+ # Access to time_zone_api controller.
41
+ # @return [TimeZoneApiController] Returns the controller instance.
42
+ def time_zone_api
43
+ @time_zone_api ||= TimeZoneApiController.new @global_configuration
44
+ end
45
+
46
+ # Access to roads_api controller.
47
+ # @return [RoadsApiController] Returns the controller instance.
48
+ def roads_api
49
+ @roads_api ||= RoadsApiController.new @global_configuration
50
+ end
51
+
52
+ # Access to distance_matrix_api controller.
53
+ # @return [DistanceMatrixApiController] Returns the controller instance.
54
+ def distance_matrix_api
55
+ @distance_matrix_api ||= DistanceMatrixApiController.new @global_configuration
56
+ end
57
+
58
+ # Access to places_api controller.
59
+ # @return [PlacesApiController] Returns the controller instance.
60
+ def places_api
61
+ @places_api ||= PlacesApiController.new @global_configuration
62
+ end
63
+
64
+ # Access to street_view_api controller.
65
+ # @return [StreetViewApiController] Returns the controller instance.
66
+ def street_view_api
67
+ @street_view_api ||= StreetViewApiController.new @global_configuration
68
+ end
69
+
70
+ def initialize(
71
+ connection: nil, adapter: :net_http_persistent, timeout: 30,
72
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
73
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
74
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
75
+ logging_configuration: nil, environment: Environment::PRODUCTION,
76
+ custom_query_authentication_credentials: nil, config: nil
77
+ )
78
+ @config = if config.nil?
79
+ Configuration.new(
80
+ connection: connection, adapter: adapter, timeout: timeout,
81
+ max_retries: max_retries, retry_interval: retry_interval,
82
+ backoff_factor: backoff_factor,
83
+ retry_statuses: retry_statuses,
84
+ retry_methods: retry_methods, http_callback: http_callback,
85
+ proxy_settings: proxy_settings,
86
+ logging_configuration: logging_configuration,
87
+ environment: environment,
88
+ custom_query_authentication_credentials: custom_query_authentication_credentials
89
+ )
90
+ else
91
+ config
92
+ end
93
+ user_agent_params = BaseController.user_agent_parameters
94
+
95
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
96
+ .base_uri_executor(@config.method(:get_base_uri))
97
+ .global_errors(BaseController::GLOBAL_ERRORS)
98
+ .user_agent(BaseController.user_agent,
99
+ agent_parameters: user_agent_params)
100
+
101
+ initialize_auth_managers(@global_configuration)
102
+ @global_configuration = @global_configuration.auth_managers(@auth_managers)
103
+ end
104
+
105
+ # Initializes the auth managers hash used for authenticating API calls.
106
+ # @param [GlobalConfiguration] global_config The global configuration of the SDK)
107
+ def initialize_auth_managers(global_config)
108
+ @auth_managers = {}
109
+ http_client_config = global_config.client_configuration
110
+ %w[ApiKeyAuth].each { |auth| @auth_managers[auth] = nil }
111
+ @auth_managers['ApiKeyAuth'] = CustomQueryAuthentication.new(
112
+ http_client_config.custom_query_authentication_credentials
113
+ )
114
+ end
115
+
116
+ # Creates a client directly from environment variables.
117
+ def self.from_env(**overrides)
118
+ default_config = Configuration.build_default_config_from_env
119
+ new_config = default_config.clone_with(**overrides)
120
+ new(config: new_config)
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,181 @@
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
+ # An enum for SDK environments.
8
+ class Environment
9
+ ENVIRONMENT = [
10
+ PRODUCTION = 'production'.freeze,
11
+ ENVIRONMENT2 = 'environment2'.freeze,
12
+ ENVIRONMENT3 = 'environment3'.freeze
13
+ ].freeze
14
+
15
+ # Converts a string or symbol into a valid Environment constant.
16
+ def self.from_value(value, default_value = PRODUCTION)
17
+ return default_value if value.nil?
18
+
19
+ str = value.to_s.strip.downcase
20
+ case str
21
+ when 'production' then PRODUCTION
22
+ when 'environment2' then ENVIRONMENT2
23
+ when 'environment3' then ENVIRONMENT3
24
+
25
+ else
26
+ warn "[Environment] Unknown environment '#{value}', falling back to #{default_value} "
27
+ default_value
28
+ end
29
+ end
30
+ end
31
+
32
+ # An enum for API servers.
33
+ class Server
34
+ SERVER = [
35
+ DEFAULT = 'default'.freeze
36
+ ].freeze
37
+
38
+ # Converts a string or symbol into a valid Server constant.
39
+ def self.from_value(value, default_value = DEFAULT)
40
+ return default_value if value.nil?
41
+
42
+ default_value
43
+ end
44
+ end
45
+
46
+ # All configuration including auth info and base URI for the API access
47
+ # are configured in this class.
48
+ class Configuration < CoreLibrary::HttpClientConfiguration
49
+ # The attribute readers for properties.
50
+ attr_reader :environment, :custom_query_authentication_credentials
51
+
52
+ class << self
53
+ attr_reader :environments
54
+ end
55
+
56
+ def initialize(
57
+ connection: nil, adapter: :net_http_persistent, timeout: 30,
58
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
59
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
60
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
61
+ logging_configuration: nil, environment: Environment::PRODUCTION,
62
+ custom_query_authentication_credentials: nil
63
+ )
64
+ super connection: connection, adapter: adapter, timeout: timeout,
65
+ max_retries: max_retries, retry_interval: retry_interval,
66
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
67
+ retry_methods: retry_methods, http_callback: http_callback,
68
+ proxy_settings: proxy_settings,
69
+ logging_configuration: logging_configuration
70
+
71
+ # Current API environment
72
+ @environment = String(environment)
73
+
74
+ # The object holding Custom Query Parameter credentials
75
+ @custom_query_authentication_credentials = custom_query_authentication_credentials
76
+
77
+ # Initializing Custom Query Parameter credentials with the provided auth parameters
78
+ @custom_query_authentication_credentials = custom_query_authentication_credentials
79
+
80
+ # The Http Client to use for making requests.
81
+ set_http_client CoreLibrary::FaradayClient.new(self)
82
+ end
83
+
84
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
85
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
86
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
87
+ proxy_settings: nil, logging_configuration: nil,
88
+ environment: nil,
89
+ custom_query_authentication_credentials: nil)
90
+ connection ||= self.connection
91
+ adapter ||= self.adapter
92
+ timeout ||= self.timeout
93
+ max_retries ||= self.max_retries
94
+ retry_interval ||= self.retry_interval
95
+ backoff_factor ||= self.backoff_factor
96
+ retry_statuses ||= self.retry_statuses
97
+ retry_methods ||= self.retry_methods
98
+ http_callback ||= self.http_callback
99
+ proxy_settings ||= self.proxy_settings
100
+ logging_configuration ||= self.logging_configuration
101
+ environment ||= self.environment
102
+ custom_query_authentication_credentials ||= self.custom_query_authentication_credentials
103
+
104
+ Configuration.new(
105
+ connection: connection, adapter: adapter, timeout: timeout,
106
+ max_retries: max_retries, retry_interval: retry_interval,
107
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
108
+ retry_methods: retry_methods, http_callback: http_callback,
109
+ proxy_settings: proxy_settings,
110
+ logging_configuration: logging_configuration, environment: environment,
111
+ custom_query_authentication_credentials: custom_query_authentication_credentials
112
+ )
113
+ end
114
+
115
+
116
+ # All the environments the SDK can run in.
117
+ ENVIRONMENTS = {
118
+ Environment::PRODUCTION => {
119
+ Server::DEFAULT => 'https://www.googleapis.com'
120
+ },
121
+ Environment::ENVIRONMENT2 => {
122
+ Server::DEFAULT => 'https://maps.googleapis.com'
123
+ },
124
+ Environment::ENVIRONMENT3 => {
125
+ Server::DEFAULT => 'https://roads.googleapis.com'
126
+ }
127
+ }.freeze
128
+
129
+ # Generates the appropriate base URI for the environment and the server.
130
+ # @param [Configuration::Server] server The server enum for which the base URI is
131
+ # required.
132
+ # @return [String] The base URI.
133
+ def get_base_uri(server = Server::DEFAULT)
134
+ ENVIRONMENTS[environment][server].clone
135
+ end
136
+
137
+ # Builds a Configuration instance using environment variables.
138
+ def self.build_default_config_from_env
139
+ # === Core environment ===
140
+ environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
141
+ timeout = (ENV['TIMEOUT'] || 30).to_f
142
+ max_retries = (ENV['MAX_RETRIES'] || 0).to_i
143
+ retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
144
+ backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
145
+ retry_statuses = ENV.fetch('RETRY_STATUSES',
146
+ '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
147
+ .split(',')
148
+ .map(&:strip)
149
+ .map do |item|
150
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
151
+ end
152
+ retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
153
+ .split(',')
154
+ .map(&:strip)
155
+ .map do |item|
156
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
157
+ end
158
+
159
+ # === Authentication credentials ===
160
+ custom_query_authentication_credentials = CustomQueryAuthenticationCredentials.from_env
161
+
162
+ # === Proxy settings ===
163
+ proxy_settings = ProxySettings.from_env
164
+ # === Logging Configuration ===
165
+ logging_configuration = LoggingConfiguration.from_env if LoggingConfiguration.any_logging_configured?
166
+
167
+ Configuration.new(
168
+ environment: environment,
169
+ timeout: timeout,
170
+ max_retries: max_retries,
171
+ retry_interval: retry_interval,
172
+ backoff_factor: backoff_factor,
173
+ retry_statuses: retry_statuses,
174
+ retry_methods: retry_methods,
175
+ custom_query_authentication_credentials: custom_query_authentication_credentials,
176
+ proxy_settings: proxy_settings,
177
+ logging_configuration: logging_configuration
178
+ )
179
+ end
180
+ end
181
+ end
@@ -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
+ # BaseController.
8
+ class BaseController
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