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,132 @@
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
+ # DistanceMatrixElement Model.
8
+ class DistanceMatrixElement < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # The total fare for the route.
13
+ # ```
14
+ # {
15
+ # "currency" : "USD",
16
+ # "value" : 6,
17
+ # "text" : "$6.00"
18
+ # }
19
+ # ```
20
+ # @return [Fare]
21
+ attr_accessor :fare
22
+
23
+ # An object containing a numeric value and its formatted text
24
+ # representation.
25
+ # @return [TextValueObject]
26
+ attr_accessor :distance
27
+
28
+ # An object containing a numeric value and its formatted text
29
+ # representation.
30
+ # @return [TextValueObject]
31
+ attr_accessor :duration_in_traffic
32
+
33
+ # An object containing a numeric value and its formatted text
34
+ # representation.
35
+ # @return [TextValueObject]
36
+ attr_accessor :duration
37
+
38
+ # - `OK` indicates the response contains a valid result.
39
+ # - `NOT_FOUND` indicates that the origin and/or destination of this pairing
40
+ # could not be geocoded.
41
+ # - `ZERO_RESULTS` indicates no route could be found between the origin and
42
+ # destination.
43
+ # - `MAX_ROUTE_LENGTH_EXCEEDED` indicates the requested route is too long
44
+ # and cannot be processed.
45
+ # @return [DistanceMatrixElementStatus]
46
+ attr_accessor :status
47
+
48
+ # A mapping from model property names to API property names.
49
+ def self.names
50
+ @_hash = {} if @_hash.nil?
51
+ @_hash['fare'] = 'fare'
52
+ @_hash['distance'] = 'distance'
53
+ @_hash['duration_in_traffic'] = 'duration_in_traffic'
54
+ @_hash['duration'] = 'duration'
55
+ @_hash['status'] = 'status'
56
+ @_hash
57
+ end
58
+
59
+ # An array for optional fields
60
+ def self.optionals
61
+ %w[
62
+ fare
63
+ distance
64
+ duration_in_traffic
65
+ duration
66
+ ]
67
+ end
68
+
69
+ # An array for nullable fields
70
+ def self.nullables
71
+ []
72
+ end
73
+
74
+ def initialize(status:, fare: SKIP, distance: SKIP,
75
+ duration_in_traffic: SKIP, duration: SKIP,
76
+ additional_properties: nil)
77
+ # Add additional model properties to the instance
78
+ additional_properties = {} if additional_properties.nil?
79
+
80
+ @fare = fare unless fare == SKIP
81
+ @distance = distance unless distance == SKIP
82
+ @duration_in_traffic = duration_in_traffic unless duration_in_traffic == SKIP
83
+ @duration = duration unless duration == SKIP
84
+ @status = status
85
+ @additional_properties = additional_properties
86
+ end
87
+
88
+ # Creates an instance of the object from a hash.
89
+ def self.from_hash(hash)
90
+ return nil unless hash
91
+
92
+ # Extract variables from the hash.
93
+ status = hash.key?('status') ? hash['status'] : nil
94
+ fare = Fare.from_hash(hash['fare']) if hash['fare']
95
+ distance = TextValueObject.from_hash(hash['distance']) if hash['distance']
96
+ duration_in_traffic = TextValueObject.from_hash(hash['duration_in_traffic']) if
97
+ hash['duration_in_traffic']
98
+ duration = TextValueObject.from_hash(hash['duration']) if hash['duration']
99
+
100
+ # Create a new hash for additional properties, removing known properties.
101
+ new_hash = hash.reject { |k, _| names.value?(k) }
102
+
103
+ additional_properties = APIHelper.get_additional_properties(
104
+ new_hash, proc { |value| value }
105
+ )
106
+
107
+ # Create object from extracted values.
108
+ DistanceMatrixElement.new(status: status,
109
+ fare: fare,
110
+ distance: distance,
111
+ duration_in_traffic: duration_in_traffic,
112
+ duration: duration,
113
+ additional_properties: additional_properties)
114
+ end
115
+
116
+ # Provides a human-readable string representation of the object.
117
+ def to_s
118
+ class_name = self.class.name.split('::').last
119
+ "<#{class_name} fare: #{@fare}, distance: #{@distance}, duration_in_traffic:"\
120
+ " #{@duration_in_traffic}, duration: #{@duration}, status: #{@status},"\
121
+ " additional_properties: #{@additional_properties}>"
122
+ end
123
+
124
+ # Provides a debugging-friendly string with detailed object information.
125
+ def inspect
126
+ class_name = self.class.name.split('::').last
127
+ "<#{class_name} fare: #{@fare.inspect}, distance: #{@distance.inspect},"\
128
+ " duration_in_traffic: #{@duration_in_traffic.inspect}, duration: #{@duration.inspect},"\
129
+ " status: #{@status.inspect}, additional_properties: #{@additional_properties}>"
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,48 @@
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
+ # - `OK` indicates the response contains a valid result. - `NOT_FOUND`
8
+ # indicates that the origin and/or destination of this pairing could not be
9
+ # geocoded. - `ZERO_RESULTS` indicates no route could be found between the
10
+ # origin and destination. - `MAX_ROUTE_LENGTH_EXCEEDED` indicates the
11
+ # requested route is too long and cannot be processed.
12
+ class DistanceMatrixElementStatus
13
+ DISTANCE_MATRIX_ELEMENT_STATUS = [
14
+ # TODO: Write general description for OK
15
+ OK = 'OK'.freeze,
16
+
17
+ # TODO: Write general description for NOT_FOUND
18
+ NOT_FOUND = 'NOT_FOUND'.freeze,
19
+
20
+ # TODO: Write general description for ZERO_RESULTS
21
+ ZERO_RESULTS = 'ZERO_RESULTS'.freeze,
22
+
23
+ # TODO: Write general description for MAX_ROUTE_LENGTH_EXCEEDED
24
+ MAX_ROUTE_LENGTH_EXCEEDED = 'MAX_ROUTE_LENGTH_EXCEEDED'.freeze
25
+ ].freeze
26
+
27
+ def self.validate(value)
28
+ return false if value.nil?
29
+
30
+ DISTANCE_MATRIX_ELEMENT_STATUS.include?(value)
31
+ end
32
+
33
+ def self.from_value(value, default_value = OK)
34
+ return default_value if value.nil?
35
+
36
+ str = value.to_s.strip
37
+
38
+ case str.downcase
39
+ when 'ok' then OK
40
+ when 'not_found' then NOT_FOUND
41
+ when 'zero_results' then ZERO_RESULTS
42
+ when 'max_route_length_exceeded' then MAX_ROUTE_LENGTH_EXCEEDED
43
+ else
44
+ default_value
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,149 @@
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
+ # DistanceMatrixResponse Model.
8
+ class DistanceMatrixResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # An array of addresses as returned by the API from your original request.
13
+ # These are formatted by the geocoder and localized according to the
14
+ # language parameter passed with the request. This content is meant to be
15
+ # read as-is. Do not programatically parse the formatted addresses.
16
+ # @return [Array[String]]
17
+ attr_accessor :origin_addresses
18
+
19
+ # An array of addresses as returned by the API from your original request.
20
+ # As with `origin_addresses`, these are localized if appropriate. This
21
+ # content is meant to be read as-is. Do not programatically parse the
22
+ # formatted addresses.
23
+ # @return [Array[String]]
24
+ attr_accessor :destination_addresses
25
+
26
+ # An array of elements, which in turn each contain a `status`, `duration`,
27
+ # and `distance` element.
28
+ # @return [Array[DistanceMatrixRow]]
29
+ attr_accessor :rows
30
+
31
+ # Status codes returned by service.
32
+ # - `OK` indicates the response contains a valid result.
33
+ # - `INVALID_REQUEST` indicates that the provided request was invalid.
34
+ # - `MAX_ELEMENTS_EXCEEDED` indicates that the product of origins and
35
+ # destinations exceeds the per-query limit.
36
+ # - `MAX_DIMENSIONS_EXCEEDED` indicates that the number of origins or
37
+ # destinations exceeds the per-query limit.
38
+ # - `OVER_DAILY_LIMIT` indicates any of the following:
39
+ # - The API key is missing or invalid.
40
+ # - Billing has not been enabled on your account.
41
+ # - A self-imposed usage cap has been exceeded.
42
+ # - The provided method of payment is no longer valid (for example, a
43
+ # credit card has expired).
44
+ # - `OVER_QUERY_LIMIT` indicates the service has received too many requests
45
+ # from your application within the allowed time period.
46
+ # - `REQUEST_DENIED` indicates that the service denied use of the Distance
47
+ # Matrix service by your application.
48
+ # - `UNKNOWN_ERROR` indicates a Distance Matrix request could not be
49
+ # processed due to a server error. The request may succeed if you try again.
50
+ # @return [DistanceMatrixStatus]
51
+ attr_accessor :status
52
+
53
+ # A string containing the human-readable text of any errors encountered
54
+ # while the request was being processed.
55
+ # @return [String]
56
+ attr_accessor :error_message
57
+
58
+ # A mapping from model property names to API property names.
59
+ def self.names
60
+ @_hash = {} if @_hash.nil?
61
+ @_hash['origin_addresses'] = 'origin_addresses'
62
+ @_hash['destination_addresses'] = 'destination_addresses'
63
+ @_hash['rows'] = 'rows'
64
+ @_hash['status'] = 'status'
65
+ @_hash['error_message'] = 'error_message'
66
+ @_hash
67
+ end
68
+
69
+ # An array for optional fields
70
+ def self.optionals
71
+ %w[
72
+ error_message
73
+ ]
74
+ end
75
+
76
+ # An array for nullable fields
77
+ def self.nullables
78
+ []
79
+ end
80
+
81
+ def initialize(origin_addresses:, destination_addresses:, rows:, status:,
82
+ error_message: SKIP, additional_properties: nil)
83
+ # Add additional model properties to the instance
84
+ additional_properties = {} if additional_properties.nil?
85
+
86
+ @origin_addresses = origin_addresses
87
+ @destination_addresses = destination_addresses
88
+ @rows = rows
89
+ @status = status
90
+ @error_message = error_message unless error_message == SKIP
91
+ @additional_properties = additional_properties
92
+ end
93
+
94
+ # Creates an instance of the object from a hash.
95
+ def self.from_hash(hash)
96
+ return nil unless hash
97
+
98
+ # Extract variables from the hash.
99
+ origin_addresses =
100
+ hash.key?('origin_addresses') ? hash['origin_addresses'] : nil
101
+ destination_addresses =
102
+ hash.key?('destination_addresses') ? hash['destination_addresses'] : nil
103
+ # Parameter is an array, so we need to iterate through it
104
+ rows = nil
105
+ unless hash['rows'].nil?
106
+ rows = []
107
+ hash['rows'].each do |structure|
108
+ rows << (DistanceMatrixRow.from_hash(structure) if structure)
109
+ end
110
+ end
111
+
112
+ rows = nil unless hash.key?('rows')
113
+ status = hash.key?('status') ? hash['status'] : nil
114
+ error_message = hash.key?('error_message') ? hash['error_message'] : SKIP
115
+
116
+ # Create a new hash for additional properties, removing known properties.
117
+ new_hash = hash.reject { |k, _| names.value?(k) }
118
+
119
+ additional_properties = APIHelper.get_additional_properties(
120
+ new_hash, proc { |value| value }
121
+ )
122
+
123
+ # Create object from extracted values.
124
+ DistanceMatrixResponse.new(origin_addresses: origin_addresses,
125
+ destination_addresses: destination_addresses,
126
+ rows: rows,
127
+ status: status,
128
+ error_message: error_message,
129
+ additional_properties: additional_properties)
130
+ end
131
+
132
+ # Provides a human-readable string representation of the object.
133
+ def to_s
134
+ class_name = self.class.name.split('::').last
135
+ "<#{class_name} origin_addresses: #{@origin_addresses}, destination_addresses:"\
136
+ " #{@destination_addresses}, rows: #{@rows}, status: #{@status}, error_message:"\
137
+ " #{@error_message}, additional_properties: #{@additional_properties}>"
138
+ end
139
+
140
+ # Provides a debugging-friendly string with detailed object information.
141
+ def inspect
142
+ class_name = self.class.name.split('::').last
143
+ "<#{class_name} origin_addresses: #{@origin_addresses.inspect}, destination_addresses:"\
144
+ " #{@destination_addresses.inspect}, rows: #{@rows.inspect}, status: #{@status.inspect},"\
145
+ " error_message: #{@error_message.inspect}, additional_properties:"\
146
+ " #{@additional_properties}>"
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,89 @@
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
+ # DistanceMatrixRow Model.
8
+ class DistanceMatrixRow < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # When the Distance Matrix API returns results, it places them within a JSON
13
+ # rows array. Even if no results are returned (such as when the origins
14
+ # and/or destinations don't exist), it still returns an empty array.
15
+ # Rows are ordered according to the values in the origin parameter of the
16
+ # request. Each row corresponds to an origin, and each element within that
17
+ # row corresponds to a pairing of the origin with a destination value.
18
+ # Each row array contains one or more element entries, which in turn contain
19
+ # the information about a single origin-destination pairing.
20
+ # @return [Array[DistanceMatrixElement]]
21
+ attr_accessor :elements
22
+
23
+ # A mapping from model property names to API property names.
24
+ def self.names
25
+ @_hash = {} if @_hash.nil?
26
+ @_hash['elements'] = 'elements'
27
+ @_hash
28
+ end
29
+
30
+ # An array for optional fields
31
+ def self.optionals
32
+ []
33
+ end
34
+
35
+ # An array for nullable fields
36
+ def self.nullables
37
+ []
38
+ end
39
+
40
+ def initialize(elements:, additional_properties: nil)
41
+ # Add additional model properties to the instance
42
+ additional_properties = {} if additional_properties.nil?
43
+
44
+ @elements = elements
45
+ @additional_properties = additional_properties
46
+ end
47
+
48
+ # Creates an instance of the object from a hash.
49
+ def self.from_hash(hash)
50
+ return nil unless hash
51
+
52
+ # Extract variables from the hash.
53
+ # Parameter is an array, so we need to iterate through it
54
+ elements = nil
55
+ unless hash['elements'].nil?
56
+ elements = []
57
+ hash['elements'].each do |structure|
58
+ elements << (DistanceMatrixElement.from_hash(structure) if structure)
59
+ end
60
+ end
61
+
62
+ elements = nil unless hash.key?('elements')
63
+
64
+ # Create a new hash for additional properties, removing known properties.
65
+ new_hash = hash.reject { |k, _| names.value?(k) }
66
+
67
+ additional_properties = APIHelper.get_additional_properties(
68
+ new_hash, proc { |value| value }
69
+ )
70
+
71
+ # Create object from extracted values.
72
+ DistanceMatrixRow.new(elements: elements,
73
+ additional_properties: additional_properties)
74
+ end
75
+
76
+ # Provides a human-readable string representation of the object.
77
+ def to_s
78
+ class_name = self.class.name.split('::').last
79
+ "<#{class_name} elements: #{@elements}, additional_properties: #{@additional_properties}>"
80
+ end
81
+
82
+ # Provides a debugging-friendly string with detailed object information.
83
+ def inspect
84
+ class_name = self.class.name.split('::').last
85
+ "<#{class_name} elements: #{@elements.inspect}, additional_properties:"\
86
+ " #{@additional_properties}>"
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,74 @@
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
+ # Status codes returned by service. - `OK` indicates the response contains a
8
+ # valid result. - `INVALID_REQUEST` indicates that the provided request was
9
+ # invalid. - `MAX_ELEMENTS_EXCEEDED` indicates that the product of origins and
10
+ # destinations exceeds the per-query limit. - `MAX_DIMENSIONS_EXCEEDED`
11
+ # indicates that the number of origins or destinations exceeds the per-query
12
+ # limit. - `OVER_DAILY_LIMIT` indicates any of the following: - The API key
13
+ # is missing or invalid. - Billing has not been enabled on your account. -
14
+ # A self-imposed usage cap has been exceeded. - The provided method of
15
+ # payment is no longer valid (for example, a credit card has expired). -
16
+ # `OVER_QUERY_LIMIT` indicates the service has received too many requests from
17
+ # your application within the allowed time period. - `REQUEST_DENIED`
18
+ # indicates that the service denied use of the Distance Matrix service by your
19
+ # application. - `UNKNOWN_ERROR` indicates a Distance Matrix request could not
20
+ # be processed due to a server error. The request may succeed if you try
21
+ # again.
22
+ class DistanceMatrixStatus
23
+ DISTANCE_MATRIX_STATUS = [
24
+ # TODO: Write general description for OK
25
+ OK = 'OK'.freeze,
26
+
27
+ # TODO: Write general description for INVALID_REQUEST
28
+ INVALID_REQUEST = 'INVALID_REQUEST'.freeze,
29
+
30
+ # TODO: Write general description for MAX_ELEMENTS_EXCEEDED
31
+ MAX_ELEMENTS_EXCEEDED = 'MAX_ELEMENTS_EXCEEDED'.freeze,
32
+
33
+ # TODO: Write general description for MAX_DIMENSIONS_EXCEEDED
34
+ MAX_DIMENSIONS_EXCEEDED = 'MAX_DIMENSIONS_EXCEEDED'.freeze,
35
+
36
+ # TODO: Write general description for OVER_DAILY_LIMIT
37
+ OVER_DAILY_LIMIT = 'OVER_DAILY_LIMIT'.freeze,
38
+
39
+ # TODO: Write general description for OVER_QUERY_LIMIT
40
+ OVER_QUERY_LIMIT = 'OVER_QUERY_LIMIT'.freeze,
41
+
42
+ # TODO: Write general description for REQUEST_DENIED
43
+ REQUEST_DENIED = 'REQUEST_DENIED'.freeze,
44
+
45
+ # TODO: Write general description for UNKNOWN_ERROR
46
+ UNKNOWN_ERROR = 'UNKNOWN_ERROR'.freeze
47
+ ].freeze
48
+
49
+ def self.validate(value)
50
+ return false if value.nil?
51
+
52
+ DISTANCE_MATRIX_STATUS.include?(value)
53
+ end
54
+
55
+ def self.from_value(value, default_value = OK)
56
+ return default_value if value.nil?
57
+
58
+ str = value.to_s.strip
59
+
60
+ case str.downcase
61
+ when 'ok' then OK
62
+ when 'invalid_request' then INVALID_REQUEST
63
+ when 'max_elements_exceeded' then MAX_ELEMENTS_EXCEEDED
64
+ when 'max_dimensions_exceeded' then MAX_DIMENSIONS_EXCEEDED
65
+ when 'over_daily_limit' then OVER_DAILY_LIMIT
66
+ when 'over_query_limit' then OVER_QUERY_LIMIT
67
+ when 'request_denied' then REQUEST_DENIED
68
+ when 'unknown_error' then UNKNOWN_ERROR
69
+ else
70
+ default_value
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,132 @@
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
+ # ElevationResponse Model.
8
+ class ElevationResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # When the service returns a status code other than `OK`, there may be an
13
+ # additional `error_message` field within the response object. This field
14
+ # contains more detailed information about thereasons behind the given
15
+ # status code. This field is not always returned, and its content is subject
16
+ # to change.
17
+ # @return [String]
18
+ attr_accessor :error_message
19
+
20
+ # Status codes returned by service.
21
+ # - `OK` indicating the API request was successful.
22
+ # - `DATA_NOT_AVAILABLE` indicating that there's no available data for the
23
+ # input locations.
24
+ # - `INVALID_REQUEST` indicating the API request was malformed.
25
+ # - `OVER_DAILY_LIMIT` indicating any of the following:
26
+ # - The API key is missing or invalid.
27
+ # - Billing has not been enabled on your account.
28
+ # - A self-imposed usage cap has been exceeded.
29
+ # - The provided method of payment is no longer valid (for example, a
30
+ # credit card has expired).
31
+ # - `OVER_QUERY_LIMIT` indicating the requestor has exceeded quota.
32
+ # - `REQUEST_DENIED` indicating the API did not complete the request.
33
+ # - `UNKNOWN_ERROR` indicating an unknown error.
34
+ # @return [ElevationStatus]
35
+ attr_accessor :status
36
+
37
+ # Status codes returned by service.
38
+ # - `OK` indicating the API request was successful.
39
+ # - `DATA_NOT_AVAILABLE` indicating that there's no available data for the
40
+ # input locations.
41
+ # - `INVALID_REQUEST` indicating the API request was malformed.
42
+ # - `OVER_DAILY_LIMIT` indicating any of the following:
43
+ # - The API key is missing or invalid.
44
+ # - Billing has not been enabled on your account.
45
+ # - A self-imposed usage cap has been exceeded.
46
+ # - The provided method of payment is no longer valid (for example, a
47
+ # credit card has expired).
48
+ # - `OVER_QUERY_LIMIT` indicating the requestor has exceeded quota.
49
+ # - `REQUEST_DENIED` indicating the API did not complete the request.
50
+ # - `UNKNOWN_ERROR` indicating an unknown error.
51
+ # @return [Array[ElevationResult]]
52
+ attr_accessor :results
53
+
54
+ # A mapping from model property names to API property names.
55
+ def self.names
56
+ @_hash = {} if @_hash.nil?
57
+ @_hash['error_message'] = 'error_message'
58
+ @_hash['status'] = 'status'
59
+ @_hash['results'] = 'results'
60
+ @_hash
61
+ end
62
+
63
+ # An array for optional fields
64
+ def self.optionals
65
+ %w[
66
+ error_message
67
+ ]
68
+ end
69
+
70
+ # An array for nullable fields
71
+ def self.nullables
72
+ []
73
+ end
74
+
75
+ def initialize(status:, results:, error_message: SKIP,
76
+ additional_properties: nil)
77
+ # Add additional model properties to the instance
78
+ additional_properties = {} if additional_properties.nil?
79
+
80
+ @error_message = error_message unless error_message == SKIP
81
+ @status = status
82
+ @results = results
83
+ @additional_properties = additional_properties
84
+ end
85
+
86
+ # Creates an instance of the object from a hash.
87
+ def self.from_hash(hash)
88
+ return nil unless hash
89
+
90
+ # Extract variables from the hash.
91
+ status = hash.key?('status') ? hash['status'] : nil
92
+ # Parameter is an array, so we need to iterate through it
93
+ results = nil
94
+ unless hash['results'].nil?
95
+ results = []
96
+ hash['results'].each do |structure|
97
+ results << (ElevationResult.from_hash(structure) if structure)
98
+ end
99
+ end
100
+
101
+ results = nil unless hash.key?('results')
102
+ error_message = hash.key?('error_message') ? hash['error_message'] : SKIP
103
+
104
+ # Create a new hash for additional properties, removing known properties.
105
+ new_hash = hash.reject { |k, _| names.value?(k) }
106
+
107
+ additional_properties = APIHelper.get_additional_properties(
108
+ new_hash, proc { |value| value }
109
+ )
110
+
111
+ # Create object from extracted values.
112
+ ElevationResponse.new(status: status,
113
+ results: results,
114
+ error_message: error_message,
115
+ additional_properties: additional_properties)
116
+ end
117
+
118
+ # Provides a human-readable string representation of the object.
119
+ def to_s
120
+ class_name = self.class.name.split('::').last
121
+ "<#{class_name} error_message: #{@error_message}, status: #{@status}, results: #{@results},"\
122
+ " additional_properties: #{@additional_properties}>"
123
+ end
124
+
125
+ # Provides a debugging-friendly string with detailed object information.
126
+ def inspect
127
+ class_name = self.class.name.split('::').last
128
+ "<#{class_name} error_message: #{@error_message.inspect}, status: #{@status.inspect},"\
129
+ " results: #{@results.inspect}, additional_properties: #{@additional_properties}>"
130
+ end
131
+ end
132
+ end