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
@@ -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
+ # DirectionsGeocodedWaypoint Model.
8
+ class DirectionsGeocodedWaypoint < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # Indicates the status code resulting from the geocoding operation. This
13
+ # field may contain the following values.
14
+ # @return [GeocoderStatus]
15
+ attr_accessor :geocoder_status
16
+
17
+ # Indicates that the geocoder did not return an exact match for the original
18
+ # request, though it was able to match part of the requested address. You
19
+ # may wish to examine the original request for misspellings and/or an
20
+ # incomplete address.
21
+ # Partial matches most often occur for street addresses that do not exist
22
+ # within the locality you pass in the request. Partial matches may also be
23
+ # returned when a request matches two or more locations in the same
24
+ # locality. For example, "21 Henr St, Bristol, UK" will return a partial
25
+ # match for both Henry Street and Henrietta Street. Note that if a request
26
+ # includes a misspelled address component, the geocoding service may suggest
27
+ # an alternative address. Suggestions triggered in this way will also be
28
+ # marked as a partial match.
29
+ # @return [Object]
30
+ attr_accessor :partial_match
31
+
32
+ # A unique identifier that can be used with other Google APIs. See the
33
+ # [Place ID
34
+ # overview](https://developers.google.com/maps/documentation/places/web-serv
35
+ # ice/place-id).
36
+ # @return [String]
37
+ attr_accessor :place_id
38
+
39
+ # Indicates the address type of the geocoding result used for calculating
40
+ # directions.
41
+ # * `administrative_area_level_1` indicates a first-order civil entity below
42
+ # the country level. Within the United States, these administrative levels
43
+ # are states. Not all nations exhibit these administrative levels. In most
44
+ # cases, administrative_area_level_1 short names will closely match ISO
45
+ # 3166-2 subdivisions and other widely circulated lists; however this is not
46
+ # guaranteed as our geocoding results are based on a variety of signals and
47
+ # location data.
48
+ # * `administrative_area_level_2` indicates a second-order civil entity
49
+ # below the country level. Within the United States, these administrative
50
+ # levels are counties. Not all nations exhibit these administrative levels.
51
+ # * `administrative_area_level_3` indicates a third-order civil entity below
52
+ # the country level. This type indicates a minor civil division. Not all
53
+ # nations exhibit these administrative levels.
54
+ # * `administrative_area_level_4` indicates a fourth-order civil entity
55
+ # below the country level. This type indicates a minor civil division. Not
56
+ # all nations exhibit these administrative levels.
57
+ # * `administrative_area_level_5` indicates a fifth-order civil entity below
58
+ # the country level. This type indicates a minor civil division. Not all
59
+ # nations exhibit these administrative levels.
60
+ # * `airport` indicates an airport.
61
+ # * `colloquial_area` indicates a commonly-used alternative name for the
62
+ # entity.
63
+ # * `country` indicates the national political entity, and is typically the
64
+ # highest order type returned by the Geocoder.
65
+ # * `intersection` indicates a major intersection, usually of two major
66
+ # roads.
67
+ # * `locality` indicates an incorporated city or town political entity.
68
+ # * `natural_feature` indicates a prominent natural feature.
69
+ # * `neighborhood` indicates a named neighborhood
70
+ # * `park` indicates a named park.
71
+ # * `plus_code` indicates an encoded location reference, derived from
72
+ # latitude and longitude. Plus codes can be used as a replacement for street
73
+ # addresses in places where they do not exist (where buildings are not
74
+ # numbered or streets are not named). See
75
+ # [https://plus.codes](https://plus.codes/) for details.
76
+ # * `point_of_interest` indicates a named point of interest. Typically,
77
+ # these "POI"s are prominent local entities that don't easily fit in another
78
+ # category, such as "Empire State Building" or "Eiffel Tower".
79
+ # * `political` indicates a political entity. Usually, this type indicates a
80
+ # polygon of some civil administration.
81
+ # * `postal_code` indicates a postal code as used to address postal mail
82
+ # within the country.
83
+ # * `premise` indicates a named location, usually a building or collection
84
+ # of buildings with a common name
85
+ # * `route` indicates a named route (such as "US 101").
86
+ # * `street_address` indicates a precise street address.
87
+ # * `sublocality` indicates a first-order civil entity below a locality. For
88
+ # some locations may receive one of the additional types:
89
+ # sublocality_level_1 to sublocality_level_5. Each sublocality level is a
90
+ # civil entity. Larger numbers indicate a smaller geographic area.
91
+ # * `subpremise` indicates a first-order entity below a named location,
92
+ # usually a singular building within a collection of buildings with a common
93
+ # name
94
+ # * `tourist_attraction` indicates a tourist attraction.
95
+ # * `train_station` indicates a train station.
96
+ # * `transit_station` indicates a transit station.
97
+ # An empty list of types indicates there are no known types for the
98
+ # particular address component, for example, Lieu-dit in France.
99
+ # @return [Array[Type]]
100
+ attr_accessor :types
101
+
102
+ # A mapping from model property names to API property names.
103
+ def self.names
104
+ @_hash = {} if @_hash.nil?
105
+ @_hash['geocoder_status'] = 'geocoder_status'
106
+ @_hash['partial_match'] = 'partial_match'
107
+ @_hash['place_id'] = 'place_id'
108
+ @_hash['types'] = 'types'
109
+ @_hash
110
+ end
111
+
112
+ # An array for optional fields
113
+ def self.optionals
114
+ %w[
115
+ geocoder_status
116
+ partial_match
117
+ place_id
118
+ types
119
+ ]
120
+ end
121
+
122
+ # An array for nullable fields
123
+ def self.nullables
124
+ []
125
+ end
126
+
127
+ def initialize(geocoder_status: SKIP, partial_match: SKIP, place_id: SKIP,
128
+ types: SKIP, additional_properties: nil)
129
+ # Add additional model properties to the instance
130
+ additional_properties = {} if additional_properties.nil?
131
+
132
+ @geocoder_status = geocoder_status unless geocoder_status == SKIP
133
+ @partial_match = partial_match unless partial_match == SKIP
134
+ @place_id = place_id unless place_id == SKIP
135
+ @types = types unless types == SKIP
136
+ @additional_properties = additional_properties
137
+ end
138
+
139
+ # Creates an instance of the object from a hash.
140
+ def self.from_hash(hash)
141
+ return nil unless hash
142
+
143
+ # Extract variables from the hash.
144
+ geocoder_status =
145
+ hash.key?('geocoder_status') ? hash['geocoder_status'] : SKIP
146
+ partial_match = hash.key?('partial_match') ? hash['partial_match'] : SKIP
147
+ place_id = hash.key?('place_id') ? hash['place_id'] : SKIP
148
+ types = hash.key?('types') ? hash['types'] : SKIP
149
+
150
+ # Create a new hash for additional properties, removing known properties.
151
+ new_hash = hash.reject { |k, _| names.value?(k) }
152
+
153
+ additional_properties = APIHelper.get_additional_properties(
154
+ new_hash, proc { |value| value }
155
+ )
156
+
157
+ # Create object from extracted values.
158
+ DirectionsGeocodedWaypoint.new(geocoder_status: geocoder_status,
159
+ partial_match: partial_match,
160
+ place_id: place_id,
161
+ types: types,
162
+ additional_properties: additional_properties)
163
+ end
164
+
165
+ # Provides a human-readable string representation of the object.
166
+ def to_s
167
+ class_name = self.class.name.split('::').last
168
+ "<#{class_name} geocoder_status: #{@geocoder_status}, partial_match: #{@partial_match},"\
169
+ " place_id: #{@place_id}, types: #{@types}, additional_properties:"\
170
+ " #{@additional_properties}>"
171
+ end
172
+
173
+ # Provides a debugging-friendly string with detailed object information.
174
+ def inspect
175
+ class_name = self.class.name.split('::').last
176
+ "<#{class_name} geocoder_status: #{@geocoder_status.inspect}, partial_match:"\
177
+ " #{@partial_match.inspect}, place_id: #{@place_id.inspect}, types: #{@types.inspect},"\
178
+ " additional_properties: #{@additional_properties}>"
179
+ end
180
+ end
181
+ end
@@ -0,0 +1,224 @@
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
+ # DirectionsLeg Model.
8
+ class DirectionsLeg < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # An object containing Unix time, a time zone, and its formatted text
13
+ # representation.
14
+ # @return [TimeZoneTextValueObject]
15
+ attr_accessor :arrival_time
16
+
17
+ # An object containing Unix time, a time zone, and its formatted text
18
+ # representation.
19
+ # @return [TimeZoneTextValueObject]
20
+ attr_accessor :departure_time
21
+
22
+ # An object containing a numeric value and its formatted text
23
+ # representation.
24
+ # @return [TextValueObject]
25
+ attr_accessor :distance
26
+
27
+ # An object containing a numeric value and its formatted text
28
+ # representation.
29
+ # @return [TextValueObject]
30
+ attr_accessor :duration
31
+
32
+ # An object containing a numeric value and its formatted text
33
+ # representation.
34
+ # @return [TextValueObject]
35
+ attr_accessor :duration_in_traffic
36
+
37
+ # Contains the human-readable address (typically a street address) from
38
+ # reverse geocoding the `end_location` of this leg. This content is meant to
39
+ # be read as-is. Do not programmatically parse the formatted address.
40
+ # @return [String]
41
+ attr_accessor :end_address
42
+
43
+ # An object describing a specific location with Latitude and Longitude in
44
+ # decimal degrees.
45
+ # @return [LatLngLiteral]
46
+ attr_accessor :end_location
47
+
48
+ # Contains the human-readable address (typically a street address) resulting
49
+ # from reverse geocoding the `start_location` of this leg. This content is
50
+ # meant to be read as-is. Do not programmatically parse the formatted
51
+ # address.
52
+ # @return [String]
53
+ attr_accessor :start_address
54
+
55
+ # An object describing a specific location with Latitude and Longitude in
56
+ # decimal degrees.
57
+ # @return [LatLngLiteral]
58
+ attr_accessor :start_location
59
+
60
+ # An array of steps denoting information about each separate step of the leg
61
+ # of the journey.
62
+ # @return [Array[DirectionsStep]]
63
+ attr_accessor :steps
64
+
65
+ # Information about traffic speed along the leg.
66
+ # @return [Array[DirectionsTrafficSpeedEntry]]
67
+ attr_accessor :traffic_speed_entry
68
+
69
+ # The locations of via waypoints along this leg.
70
+ # @return [Array[DirectionsViaWaypoint]]
71
+ attr_accessor :via_waypoint
72
+
73
+ # A mapping from model property names to API property names.
74
+ def self.names
75
+ @_hash = {} if @_hash.nil?
76
+ @_hash['arrival_time'] = 'arrival_time'
77
+ @_hash['departure_time'] = 'departure_time'
78
+ @_hash['distance'] = 'distance'
79
+ @_hash['duration'] = 'duration'
80
+ @_hash['duration_in_traffic'] = 'duration_in_traffic'
81
+ @_hash['end_address'] = 'end_address'
82
+ @_hash['end_location'] = 'end_location'
83
+ @_hash['start_address'] = 'start_address'
84
+ @_hash['start_location'] = 'start_location'
85
+ @_hash['steps'] = 'steps'
86
+ @_hash['traffic_speed_entry'] = 'traffic_speed_entry'
87
+ @_hash['via_waypoint'] = 'via_waypoint'
88
+ @_hash
89
+ end
90
+
91
+ # An array for optional fields
92
+ def self.optionals
93
+ %w[
94
+ arrival_time
95
+ departure_time
96
+ distance
97
+ duration
98
+ duration_in_traffic
99
+ ]
100
+ end
101
+
102
+ # An array for nullable fields
103
+ def self.nullables
104
+ []
105
+ end
106
+
107
+ def initialize(end_address:, end_location:, start_address:, start_location:,
108
+ steps:, traffic_speed_entry:, via_waypoint:,
109
+ arrival_time: SKIP, departure_time: SKIP, distance: SKIP,
110
+ duration: SKIP, duration_in_traffic: SKIP,
111
+ additional_properties: nil)
112
+ # Add additional model properties to the instance
113
+ additional_properties = {} if additional_properties.nil?
114
+
115
+ @arrival_time = arrival_time unless arrival_time == SKIP
116
+ @departure_time = departure_time unless departure_time == SKIP
117
+ @distance = distance unless distance == SKIP
118
+ @duration = duration unless duration == SKIP
119
+ @duration_in_traffic = duration_in_traffic unless duration_in_traffic == SKIP
120
+ @end_address = end_address
121
+ @end_location = end_location
122
+ @start_address = start_address
123
+ @start_location = start_location
124
+ @steps = steps
125
+ @traffic_speed_entry = traffic_speed_entry
126
+ @via_waypoint = via_waypoint
127
+ @additional_properties = additional_properties
128
+ end
129
+
130
+ # Creates an instance of the object from a hash.
131
+ def self.from_hash(hash)
132
+ return nil unless hash
133
+
134
+ # Extract variables from the hash.
135
+ end_address = hash.key?('end_address') ? hash['end_address'] : nil
136
+ end_location = LatLngLiteral.from_hash(hash['end_location']) if hash['end_location']
137
+ start_address = hash.key?('start_address') ? hash['start_address'] : nil
138
+ start_location = LatLngLiteral.from_hash(hash['start_location']) if hash['start_location']
139
+ # Parameter is an array, so we need to iterate through it
140
+ steps = nil
141
+ unless hash['steps'].nil?
142
+ steps = []
143
+ hash['steps'].each do |structure|
144
+ steps << (DirectionsStep.from_hash(structure) if structure)
145
+ end
146
+ end
147
+
148
+ steps = nil unless hash.key?('steps')
149
+ # Parameter is an array, so we need to iterate through it
150
+ traffic_speed_entry = nil
151
+ unless hash['traffic_speed_entry'].nil?
152
+ traffic_speed_entry = []
153
+ hash['traffic_speed_entry'].each do |structure|
154
+ traffic_speed_entry << (DirectionsTrafficSpeedEntry.from_hash(structure) if structure)
155
+ end
156
+ end
157
+
158
+ traffic_speed_entry = nil unless hash.key?('traffic_speed_entry')
159
+ # Parameter is an array, so we need to iterate through it
160
+ via_waypoint = nil
161
+ unless hash['via_waypoint'].nil?
162
+ via_waypoint = []
163
+ hash['via_waypoint'].each do |structure|
164
+ via_waypoint << (DirectionsViaWaypoint.from_hash(structure) if structure)
165
+ end
166
+ end
167
+
168
+ via_waypoint = nil unless hash.key?('via_waypoint')
169
+ arrival_time = TimeZoneTextValueObject.from_hash(hash['arrival_time']) if
170
+ hash['arrival_time']
171
+ departure_time = TimeZoneTextValueObject.from_hash(hash['departure_time']) if
172
+ hash['departure_time']
173
+ distance = TextValueObject.from_hash(hash['distance']) if hash['distance']
174
+ duration = TextValueObject.from_hash(hash['duration']) if hash['duration']
175
+ duration_in_traffic = TextValueObject.from_hash(hash['duration_in_traffic']) if
176
+ hash['duration_in_traffic']
177
+
178
+ # Create a new hash for additional properties, removing known properties.
179
+ new_hash = hash.reject { |k, _| names.value?(k) }
180
+
181
+ additional_properties = APIHelper.get_additional_properties(
182
+ new_hash, proc { |value| value }
183
+ )
184
+
185
+ # Create object from extracted values.
186
+ DirectionsLeg.new(end_address: end_address,
187
+ end_location: end_location,
188
+ start_address: start_address,
189
+ start_location: start_location,
190
+ steps: steps,
191
+ traffic_speed_entry: traffic_speed_entry,
192
+ via_waypoint: via_waypoint,
193
+ arrival_time: arrival_time,
194
+ departure_time: departure_time,
195
+ distance: distance,
196
+ duration: duration,
197
+ duration_in_traffic: duration_in_traffic,
198
+ additional_properties: additional_properties)
199
+ end
200
+
201
+ # Provides a human-readable string representation of the object.
202
+ def to_s
203
+ class_name = self.class.name.split('::').last
204
+ "<#{class_name} arrival_time: #{@arrival_time}, departure_time: #{@departure_time},"\
205
+ " distance: #{@distance}, duration: #{@duration}, duration_in_traffic:"\
206
+ " #{@duration_in_traffic}, end_address: #{@end_address}, end_location: #{@end_location},"\
207
+ " start_address: #{@start_address}, start_location: #{@start_location}, steps: #{@steps},"\
208
+ " traffic_speed_entry: #{@traffic_speed_entry}, via_waypoint: #{@via_waypoint},"\
209
+ " additional_properties: #{@additional_properties}>"
210
+ end
211
+
212
+ # Provides a debugging-friendly string with detailed object information.
213
+ def inspect
214
+ class_name = self.class.name.split('::').last
215
+ "<#{class_name} arrival_time: #{@arrival_time.inspect}, departure_time:"\
216
+ " #{@departure_time.inspect}, distance: #{@distance.inspect}, duration:"\
217
+ " #{@duration.inspect}, duration_in_traffic: #{@duration_in_traffic.inspect}, end_address:"\
218
+ " #{@end_address.inspect}, end_location: #{@end_location.inspect}, start_address:"\
219
+ " #{@start_address.inspect}, start_location: #{@start_location.inspect}, steps:"\
220
+ " #{@steps.inspect}, traffic_speed_entry: #{@traffic_speed_entry.inspect}, via_waypoint:"\
221
+ " #{@via_waypoint.inspect}, additional_properties: #{@additional_properties}>"
222
+ end
223
+ end
224
+ end
@@ -0,0 +1,93 @@
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
+ # [Polyline
8
+ # encoding](https://developers.google.com/maps/documentation/utilities/polylin
9
+ # ealgorithm) is a lossy compression algorithm that allows you to store a
10
+ # series of coordinates as a single string. Point coordinates are encoded
11
+ # using signed values. If you only have a few static points, you may also wish
12
+ # to use the interactive polyline encoding utility. The encoding process
13
+ # converts a binary value into a series of character codes for ASCII
14
+ # characters using the familiar base64 encoding scheme: to ensure proper
15
+ # display of these characters, encoded values are summed with 63 (the ASCII
16
+ # character '?') before converting them into ASCII. The algorithm also checks
17
+ # for additional character codes for a given point by checking the least
18
+ # significant bit of each byte group; if this bit is set to 1, the point is
19
+ # not yet fully formed and additional data must follow. Additionally, to
20
+ # conserve space, points only include the offset from the previous point
21
+ # (except of course for the first point). All points are encoded in Base64 as
22
+ # signed integers, as latitudes and longitudes are signed values. The encoding
23
+ # format within a polyline needs to represent two coordinates representing
24
+ # latitude and longitude to a reasonable precision. Given a maximum longitude
25
+ # of +/- 180 degrees to a precision of 5 decimal places (180.00000 to
26
+ # -180.00000), this results in the need for a 32 bit signed binary integer
27
+ # value.
28
+ class DirectionsPolyline < BaseModel
29
+ SKIP = Object.new
30
+ private_constant :SKIP
31
+
32
+ # A single string representation of the polyline.
33
+ # @return [String]
34
+ attr_accessor :points
35
+
36
+ # A mapping from model property names to API property names.
37
+ def self.names
38
+ @_hash = {} if @_hash.nil?
39
+ @_hash['points'] = 'points'
40
+ @_hash
41
+ end
42
+
43
+ # An array for optional fields
44
+ def self.optionals
45
+ []
46
+ end
47
+
48
+ # An array for nullable fields
49
+ def self.nullables
50
+ []
51
+ end
52
+
53
+ def initialize(points:, additional_properties: nil)
54
+ # Add additional model properties to the instance
55
+ additional_properties = {} if additional_properties.nil?
56
+
57
+ @points = points
58
+ @additional_properties = additional_properties
59
+ end
60
+
61
+ # Creates an instance of the object from a hash.
62
+ def self.from_hash(hash)
63
+ return nil unless hash
64
+
65
+ # Extract variables from the hash.
66
+ points = hash.key?('points') ? hash['points'] : nil
67
+
68
+ # Create a new hash for additional properties, removing known properties.
69
+ new_hash = hash.reject { |k, _| names.value?(k) }
70
+
71
+ additional_properties = APIHelper.get_additional_properties(
72
+ new_hash, proc { |value| value }
73
+ )
74
+
75
+ # Create object from extracted values.
76
+ DirectionsPolyline.new(points: points,
77
+ additional_properties: additional_properties)
78
+ end
79
+
80
+ # Provides a human-readable string representation of the object.
81
+ def to_s
82
+ class_name = self.class.name.split('::').last
83
+ "<#{class_name} points: #{@points}, additional_properties: #{@additional_properties}>"
84
+ end
85
+
86
+ # Provides a debugging-friendly string with detailed object information.
87
+ def inspect
88
+ class_name = self.class.name.split('::').last
89
+ "<#{class_name} points: #{@points.inspect}, additional_properties:"\
90
+ " #{@additional_properties}>"
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,185 @@
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
+ # DirectionsResponse Model.
8
+ class DirectionsResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # Contains an array with details about the geocoding of origin, destination
13
+ # and waypoints. Elements in the geocoded_waypoints array correspond, by
14
+ # their zero-based position, to the origin, the waypoints in the order they
15
+ # are specified, and the destination.
16
+ # These details will not be present for waypoints specified as textual
17
+ # latitude/longitude values if the service returns no results. This is
18
+ # because such waypoints are only reverse geocoded to obtain their
19
+ # representative address after a route has been found. An empty JSON object
20
+ # will occupy the corresponding places in the geocoded_waypoints array.
21
+ # @return [Array[DirectionsGeocodedWaypoint]]
22
+ attr_accessor :geocoded_waypoints
23
+
24
+ # Contains an array of routes from the origin to the destination. Routes
25
+ # consist of nested Legs and Steps.
26
+ # @return [Array[DirectionsRoute]]
27
+ attr_accessor :routes
28
+
29
+ # The status field within the Directions response object contains the status
30
+ # of the request, and may contain debugging information to help you track
31
+ # down why the Directions service failed. The status field may contain the
32
+ # following values:
33
+ # - `OK` indicates the response contains a valid result.
34
+ # - `NOT_FOUND` indicates at least one of the locations specified in the
35
+ # request's origin, destination, or waypoints could not be geocoded.
36
+ # - `ZERO_RESULTS` indicates no route could be found between the origin and
37
+ # destination.
38
+ # - `MAX_WAYPOINTS_EXCEEDED` indicates that too many waypoints were provided
39
+ # in the request. For applications using the Directions API as a web
40
+ # service, or the directions service in the Maps JavaScript API, the maximum
41
+ # allowed number of waypoints is 25, plus the origin and destination.
42
+ # - `MAX_ROUTE_LENGTH_EXCEEDED` indicates the requested route is too long
43
+ # and cannot be processed. This error occurs when more complex directions
44
+ # are returned. Try reducing the number of waypoints, turns, or
45
+ # instructions.
46
+ # - `INVALID_REQUEST` indicates that the provided request was invalid.
47
+ # Common causes of this status include an invalid parameter or parameter
48
+ # value.
49
+ # - `OVER_DAILY_LIMIT` indicates any of the following:
50
+ # - The API key is missing or invalid.
51
+ # - Billing has not been enabled on your account.
52
+ # - A self-imposed usage cap has been exceeded.
53
+ # - The provided method of payment is no longer valid (for example, a
54
+ # credit card has expired).
55
+ # See the [Maps
56
+ # FAQ](https://developers.google.com/maps/faq#over-limit-key-error) to learn
57
+ # how to fix this.
58
+ # - `OVER_QUERY_LIMIT` indicates the service has received too many requests
59
+ # from your application within the allowed time period.
60
+ # - `REQUEST_DENIED` indicates that the service denied use of the directions
61
+ # service by your application.
62
+ # - `UNKNOWN_ERROR` indicates a directions request could not be processed
63
+ # due to a server error. The request may succeed if you try again.
64
+ # @return [DirectionsStatus]
65
+ attr_accessor :status
66
+
67
+ # Contains an array of available travel modes. This field is returned when a
68
+ # request specifies a travel mode and gets no results. The array contains
69
+ # the available travel modes in the countries of the given set of waypoints.
70
+ # This field is not returned if one or more of the waypoints are 'via
71
+ # waypoints'.
72
+ # @return [Array[TravelMode]]
73
+ attr_accessor :available_travel_modes
74
+
75
+ # When the service returns a status code other than `OK`, there may be an
76
+ # additional `error_message` field within the response object. This field
77
+ # contains more detailed information about the reasons behind the given
78
+ # status code. This field is not always returned, and its content is subject
79
+ # to change.
80
+ # @return [String]
81
+ attr_accessor :error_message
82
+
83
+ # A mapping from model property names to API property names.
84
+ def self.names
85
+ @_hash = {} if @_hash.nil?
86
+ @_hash['geocoded_waypoints'] = 'geocoded_waypoints'
87
+ @_hash['routes'] = 'routes'
88
+ @_hash['status'] = 'status'
89
+ @_hash['available_travel_modes'] = 'available_travel_modes'
90
+ @_hash['error_message'] = 'error_message'
91
+ @_hash
92
+ end
93
+
94
+ # An array for optional fields
95
+ def self.optionals
96
+ %w[
97
+ geocoded_waypoints
98
+ available_travel_modes
99
+ error_message
100
+ ]
101
+ end
102
+
103
+ # An array for nullable fields
104
+ def self.nullables
105
+ []
106
+ end
107
+
108
+ def initialize(routes:, status:, geocoded_waypoints: SKIP,
109
+ available_travel_modes: SKIP, error_message: SKIP,
110
+ additional_properties: nil)
111
+ # Add additional model properties to the instance
112
+ additional_properties = {} if additional_properties.nil?
113
+
114
+ @geocoded_waypoints = geocoded_waypoints unless geocoded_waypoints == SKIP
115
+ @routes = routes
116
+ @status = status
117
+ @available_travel_modes = available_travel_modes unless available_travel_modes == SKIP
118
+ @error_message = error_message unless error_message == SKIP
119
+ @additional_properties = additional_properties
120
+ end
121
+
122
+ # Creates an instance of the object from a hash.
123
+ def self.from_hash(hash)
124
+ return nil unless hash
125
+
126
+ # Extract variables from the hash.
127
+ # Parameter is an array, so we need to iterate through it
128
+ routes = nil
129
+ unless hash['routes'].nil?
130
+ routes = []
131
+ hash['routes'].each do |structure|
132
+ routes << (DirectionsRoute.from_hash(structure) if structure)
133
+ end
134
+ end
135
+
136
+ routes = nil unless hash.key?('routes')
137
+ status = hash.key?('status') ? hash['status'] : nil
138
+ # Parameter is an array, so we need to iterate through it
139
+ geocoded_waypoints = nil
140
+ unless hash['geocoded_waypoints'].nil?
141
+ geocoded_waypoints = []
142
+ hash['geocoded_waypoints'].each do |structure|
143
+ geocoded_waypoints << (DirectionsGeocodedWaypoint.from_hash(structure) if structure)
144
+ end
145
+ end
146
+
147
+ geocoded_waypoints = SKIP unless hash.key?('geocoded_waypoints')
148
+ available_travel_modes =
149
+ hash.key?('available_travel_modes') ? hash['available_travel_modes'] : SKIP
150
+ error_message = hash.key?('error_message') ? hash['error_message'] : SKIP
151
+
152
+ # Create a new hash for additional properties, removing known properties.
153
+ new_hash = hash.reject { |k, _| names.value?(k) }
154
+
155
+ additional_properties = APIHelper.get_additional_properties(
156
+ new_hash, proc { |value| value }
157
+ )
158
+
159
+ # Create object from extracted values.
160
+ DirectionsResponse.new(routes: routes,
161
+ status: status,
162
+ geocoded_waypoints: geocoded_waypoints,
163
+ available_travel_modes: available_travel_modes,
164
+ error_message: error_message,
165
+ additional_properties: additional_properties)
166
+ end
167
+
168
+ # Provides a human-readable string representation of the object.
169
+ def to_s
170
+ class_name = self.class.name.split('::').last
171
+ "<#{class_name} geocoded_waypoints: #{@geocoded_waypoints}, routes: #{@routes}, status:"\
172
+ " #{@status}, available_travel_modes: #{@available_travel_modes}, error_message:"\
173
+ " #{@error_message}, additional_properties: #{@additional_properties}>"
174
+ end
175
+
176
+ # Provides a debugging-friendly string with detailed object information.
177
+ def inspect
178
+ class_name = self.class.name.split('::').last
179
+ "<#{class_name} geocoded_waypoints: #{@geocoded_waypoints.inspect}, routes:"\
180
+ " #{@routes.inspect}, status: #{@status.inspect}, available_travel_modes:"\
181
+ " #{@available_travel_modes.inspect}, error_message: #{@error_message.inspect},"\
182
+ " additional_properties: #{@additional_properties}>"
183
+ end
184
+ end
185
+ end