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,99 @@
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
+ # ElevationResult Model.
8
+ class ElevationResult < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # The elevation of the location in meters.
13
+ # @return [Float]
14
+ attr_accessor :elevation
15
+
16
+ # The value indicating the maximum distance between data points from which
17
+ # the elevation was interpolated, in meters. This property will be missing
18
+ # if the resolution is not known. Note that elevation data becomes more
19
+ # coarse (larger resolution values) when multiple points are passed. To
20
+ # obtain the most accurate elevation value for a point, it should be queried
21
+ # independently.
22
+ # @return [Float]
23
+ attr_accessor :resolution
24
+
25
+ # An object describing a specific location with Latitude and Longitude in
26
+ # decimal degrees.
27
+ # @return [LatLngLiteral]
28
+ attr_accessor :location
29
+
30
+ # A mapping from model property names to API property names.
31
+ def self.names
32
+ @_hash = {} if @_hash.nil?
33
+ @_hash['elevation'] = 'elevation'
34
+ @_hash['resolution'] = 'resolution'
35
+ @_hash['location'] = 'location'
36
+ @_hash
37
+ end
38
+
39
+ # An array for optional fields
40
+ def self.optionals
41
+ %w[
42
+ resolution
43
+ ]
44
+ end
45
+
46
+ # An array for nullable fields
47
+ def self.nullables
48
+ []
49
+ end
50
+
51
+ def initialize(elevation:, location:, resolution: SKIP,
52
+ additional_properties: nil)
53
+ # Add additional model properties to the instance
54
+ additional_properties = {} if additional_properties.nil?
55
+
56
+ @elevation = elevation
57
+ @resolution = resolution unless resolution == SKIP
58
+ @location = location
59
+ @additional_properties = additional_properties
60
+ end
61
+
62
+ # Creates an instance of the object from a hash.
63
+ def self.from_hash(hash)
64
+ return nil unless hash
65
+
66
+ # Extract variables from the hash.
67
+ elevation = hash.key?('elevation') ? hash['elevation'] : nil
68
+ location = LatLngLiteral.from_hash(hash['location']) if hash['location']
69
+ resolution = hash.key?('resolution') ? hash['resolution'] : SKIP
70
+
71
+ # Create a new hash for additional properties, removing known properties.
72
+ new_hash = hash.reject { |k, _| names.value?(k) }
73
+
74
+ additional_properties = APIHelper.get_additional_properties(
75
+ new_hash, proc { |value| value }
76
+ )
77
+
78
+ # Create object from extracted values.
79
+ ElevationResult.new(elevation: elevation,
80
+ location: location,
81
+ resolution: resolution,
82
+ additional_properties: additional_properties)
83
+ end
84
+
85
+ # Provides a human-readable string representation of the object.
86
+ def to_s
87
+ class_name = self.class.name.split('::').last
88
+ "<#{class_name} elevation: #{@elevation}, resolution: #{@resolution}, location:"\
89
+ " #{@location}, additional_properties: #{@additional_properties}>"
90
+ end
91
+
92
+ # Provides a debugging-friendly string with detailed object information.
93
+ def inspect
94
+ class_name = self.class.name.split('::').last
95
+ "<#{class_name} elevation: #{@elevation.inspect}, resolution: #{@resolution.inspect},"\
96
+ " location: #{@location.inspect}, additional_properties: #{@additional_properties}>"
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,65 @@
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` indicating the API request was
8
+ # successful. - `DATA_NOT_AVAILABLE` indicating that there's no available data
9
+ # for the input locations. - `INVALID_REQUEST` indicating the API request was
10
+ # malformed. - `OVER_DAILY_LIMIT` indicating any of the following: - The API
11
+ # key is missing or invalid. - Billing has not been enabled on your account.
12
+ # - A self-imposed usage cap has been exceeded. - The provided method of
13
+ # payment is no longer valid (for example, a credit card has expired). -
14
+ # `OVER_QUERY_LIMIT` indicating the requestor has exceeded quota. -
15
+ # `REQUEST_DENIED` indicating the API did not complete the request. -
16
+ # `UNKNOWN_ERROR` indicating an unknown error.
17
+ class ElevationStatus
18
+ ELEVATION_STATUS = [
19
+ # TODO: Write general description for OK
20
+ OK = 'OK'.freeze,
21
+
22
+ # TODO: Write general description for DATA_NOT_AVAILABLE
23
+ DATA_NOT_AVAILABLE = 'DATA_NOT_AVAILABLE'.freeze,
24
+
25
+ # TODO: Write general description for INVALID_REQUEST
26
+ INVALID_REQUEST = 'INVALID_REQUEST'.freeze,
27
+
28
+ # TODO: Write general description for OVER_DAILY_LIMIT
29
+ OVER_DAILY_LIMIT = 'OVER_DAILY_LIMIT'.freeze,
30
+
31
+ # TODO: Write general description for OVER_QUERY_LIMIT
32
+ OVER_QUERY_LIMIT = 'OVER_QUERY_LIMIT'.freeze,
33
+
34
+ # TODO: Write general description for REQUEST_DENIED
35
+ REQUEST_DENIED = 'REQUEST_DENIED'.freeze,
36
+
37
+ # TODO: Write general description for UNKNOWN_ERROR
38
+ UNKNOWN_ERROR = 'UNKNOWN_ERROR'.freeze
39
+ ].freeze
40
+
41
+ def self.validate(value)
42
+ return false if value.nil?
43
+
44
+ ELEVATION_STATUS.include?(value)
45
+ end
46
+
47
+ def self.from_value(value, default_value = OK)
48
+ return default_value if value.nil?
49
+
50
+ str = value.to_s.strip
51
+
52
+ case str.downcase
53
+ when 'ok' then OK
54
+ when 'data_not_available' then DATA_NOT_AVAILABLE
55
+ when 'invalid_request' then INVALID_REQUEST
56
+ when 'over_daily_limit' then OVER_DAILY_LIMIT
57
+ when 'over_query_limit' then OVER_QUERY_LIMIT
58
+ when 'request_denied' then REQUEST_DENIED
59
+ when 'unknown_error' then UNKNOWN_ERROR
60
+ else
61
+ default_value
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,135 @@
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
+ # ErrorDetail Model.
8
+ class ErrorDetail < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # The type of error.
13
+ # @return [String]
14
+ attr_accessor :m_type
15
+
16
+ # A short description of the error.
17
+ # @return [String]
18
+ attr_accessor :message
19
+
20
+ # A reason for the error.
21
+ # @return [String]
22
+ attr_accessor :reason
23
+
24
+ # The domain in which the error occurred.
25
+ # @return [String]
26
+ attr_accessor :domain
27
+
28
+ # Additional metadata about the error.
29
+ # @return [Object]
30
+ attr_accessor :metadata
31
+
32
+ # A list of field violations.
33
+ # @return [Array[FieldViolation]]
34
+ attr_accessor :field_violations
35
+
36
+ # A mapping from model property names to API property names.
37
+ def self.names
38
+ @_hash = {} if @_hash.nil?
39
+ @_hash['m_type'] = '@type'
40
+ @_hash['message'] = 'message'
41
+ @_hash['reason'] = 'reason'
42
+ @_hash['domain'] = 'domain'
43
+ @_hash['metadata'] = 'metadata'
44
+ @_hash['field_violations'] = 'fieldViolations'
45
+ @_hash
46
+ end
47
+
48
+ # An array for optional fields
49
+ def self.optionals
50
+ %w[
51
+ m_type
52
+ message
53
+ reason
54
+ domain
55
+ metadata
56
+ field_violations
57
+ ]
58
+ end
59
+
60
+ # An array for nullable fields
61
+ def self.nullables
62
+ []
63
+ end
64
+
65
+ def initialize(m_type: SKIP, message: SKIP, reason: SKIP, domain: SKIP,
66
+ metadata: SKIP, field_violations: SKIP,
67
+ additional_properties: nil)
68
+ # Add additional model properties to the instance
69
+ additional_properties = {} if additional_properties.nil?
70
+
71
+ @m_type = m_type unless m_type == SKIP
72
+ @message = message unless message == SKIP
73
+ @reason = reason unless reason == SKIP
74
+ @domain = domain unless domain == SKIP
75
+ @metadata = metadata unless metadata == SKIP
76
+ @field_violations = field_violations unless field_violations == SKIP
77
+ @additional_properties = additional_properties
78
+ end
79
+
80
+ # Creates an instance of the object from a hash.
81
+ def self.from_hash(hash)
82
+ return nil unless hash
83
+
84
+ # Extract variables from the hash.
85
+ m_type = hash.key?('@type') ? hash['@type'] : SKIP
86
+ message = hash.key?('message') ? hash['message'] : SKIP
87
+ reason = hash.key?('reason') ? hash['reason'] : SKIP
88
+ domain = hash.key?('domain') ? hash['domain'] : SKIP
89
+ metadata = hash.key?('metadata') ? hash['metadata'] : SKIP
90
+ # Parameter is an array, so we need to iterate through it
91
+ field_violations = nil
92
+ unless hash['fieldViolations'].nil?
93
+ field_violations = []
94
+ hash['fieldViolations'].each do |structure|
95
+ field_violations << (FieldViolation.from_hash(structure) if structure)
96
+ end
97
+ end
98
+
99
+ field_violations = SKIP unless hash.key?('fieldViolations')
100
+
101
+ # Create a new hash for additional properties, removing known properties.
102
+ new_hash = hash.reject { |k, _| names.value?(k) }
103
+
104
+ additional_properties = APIHelper.get_additional_properties(
105
+ new_hash, proc { |value| value }
106
+ )
107
+
108
+ # Create object from extracted values.
109
+ ErrorDetail.new(m_type: m_type,
110
+ message: message,
111
+ reason: reason,
112
+ domain: domain,
113
+ metadata: metadata,
114
+ field_violations: field_violations,
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} m_type: #{@m_type}, message: #{@message}, reason: #{@reason}, domain:"\
122
+ " #{@domain}, metadata: #{@metadata}, field_violations: #{@field_violations},"\
123
+ " additional_properties: #{@additional_properties}>"
124
+ end
125
+
126
+ # Provides a debugging-friendly string with detailed object information.
127
+ def inspect
128
+ class_name = self.class.name.split('::').last
129
+ "<#{class_name} m_type: #{@m_type.inspect}, message: #{@message.inspect}, reason:"\
130
+ " #{@reason.inspect}, domain: #{@domain.inspect}, metadata: #{@metadata.inspect},"\
131
+ " field_violations: #{@field_violations.inspect}, additional_properties:"\
132
+ " #{@additional_properties}>"
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,130 @@
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
+ # ErrorObject Model.
8
+ class ErrorObject < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # This is the same as the HTTP status of the response.
13
+ # @return [Float]
14
+ attr_accessor :code
15
+
16
+ # A short description of the error.
17
+ # @return [String]
18
+ attr_accessor :message
19
+
20
+ # A list of errors which occurred. Each error contains an identifier for the
21
+ # type of error and a short description.
22
+ # @return [Array[ErrorDetail]]
23
+ attr_accessor :errors
24
+
25
+ # A status code that indicates the error type.
26
+ # @return [String]
27
+ attr_accessor :status
28
+
29
+ # Additional details about the error.
30
+ # @return [Array[ErrorDetail]]
31
+ attr_accessor :details
32
+
33
+ # A mapping from model property names to API property names.
34
+ def self.names
35
+ @_hash = {} if @_hash.nil?
36
+ @_hash['code'] = 'code'
37
+ @_hash['message'] = 'message'
38
+ @_hash['errors'] = 'errors'
39
+ @_hash['status'] = 'status'
40
+ @_hash['details'] = 'details'
41
+ @_hash
42
+ end
43
+
44
+ # An array for optional fields
45
+ def self.optionals
46
+ %w[
47
+ status
48
+ details
49
+ ]
50
+ end
51
+
52
+ # An array for nullable fields
53
+ def self.nullables
54
+ []
55
+ end
56
+
57
+ def initialize(code:, message:, errors:, status: SKIP, details: SKIP,
58
+ additional_properties: nil)
59
+ # Add additional model properties to the instance
60
+ additional_properties = {} if additional_properties.nil?
61
+
62
+ @code = code
63
+ @message = message
64
+ @errors = errors
65
+ @status = status unless status == SKIP
66
+ @details = details unless details == SKIP
67
+ @additional_properties = additional_properties
68
+ end
69
+
70
+ # Creates an instance of the object from a hash.
71
+ def self.from_hash(hash)
72
+ return nil unless hash
73
+
74
+ # Extract variables from the hash.
75
+ code = hash.key?('code') ? hash['code'] : nil
76
+ message = hash.key?('message') ? hash['message'] : nil
77
+ # Parameter is an array, so we need to iterate through it
78
+ errors = nil
79
+ unless hash['errors'].nil?
80
+ errors = []
81
+ hash['errors'].each do |structure|
82
+ errors << (ErrorDetail.from_hash(structure) if structure)
83
+ end
84
+ end
85
+
86
+ errors = nil unless hash.key?('errors')
87
+ status = hash.key?('status') ? hash['status'] : SKIP
88
+ # Parameter is an array, so we need to iterate through it
89
+ details = nil
90
+ unless hash['details'].nil?
91
+ details = []
92
+ hash['details'].each do |structure|
93
+ details << (ErrorDetail.from_hash(structure) if structure)
94
+ end
95
+ end
96
+
97
+ details = SKIP unless hash.key?('details')
98
+
99
+ # Create a new hash for additional properties, removing known properties.
100
+ new_hash = hash.reject { |k, _| names.value?(k) }
101
+
102
+ additional_properties = APIHelper.get_additional_properties(
103
+ new_hash, proc { |value| value }
104
+ )
105
+
106
+ # Create object from extracted values.
107
+ ErrorObject.new(code: code,
108
+ message: message,
109
+ errors: errors,
110
+ status: status,
111
+ details: details,
112
+ additional_properties: additional_properties)
113
+ end
114
+
115
+ # Provides a human-readable string representation of the object.
116
+ def to_s
117
+ class_name = self.class.name.split('::').last
118
+ "<#{class_name} code: #{@code}, message: #{@message}, errors: #{@errors}, status:"\
119
+ " #{@status}, details: #{@details}, additional_properties: #{@additional_properties}>"
120
+ end
121
+
122
+ # Provides a debugging-friendly string with detailed object information.
123
+ def inspect
124
+ class_name = self.class.name.split('::').last
125
+ "<#{class_name} code: #{@code.inspect}, message: #{@message.inspect}, errors:"\
126
+ " #{@errors.inspect}, status: #{@status.inspect}, details: #{@details.inspect},"\
127
+ " additional_properties: #{@additional_properties}>"
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,92 @@
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
+ # The total fare for the route. ``` { "currency" : "USD", "value" : 6,
8
+ # "text" : "$6.00" } ```
9
+ class Fare < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # An [ISO 4217 currency code](https://en.wikipedia.org/wiki/ISO_4217)
14
+ # indicating the currency that the amount is expressed in.
15
+ # @return [String]
16
+ attr_accessor :currency
17
+
18
+ # The total fare amount, in the currency specified.
19
+ # @return [Float]
20
+ attr_accessor :value
21
+
22
+ # The total fare amount, formatted in the requested language.
23
+ # @return [String]
24
+ attr_accessor :text
25
+
26
+ # A mapping from model property names to API property names.
27
+ def self.names
28
+ @_hash = {} if @_hash.nil?
29
+ @_hash['currency'] = 'currency'
30
+ @_hash['value'] = 'value'
31
+ @_hash['text'] = 'text'
32
+ @_hash
33
+ end
34
+
35
+ # An array for optional fields
36
+ def self.optionals
37
+ []
38
+ end
39
+
40
+ # An array for nullable fields
41
+ def self.nullables
42
+ []
43
+ end
44
+
45
+ def initialize(currency:, value:, text:, additional_properties: nil)
46
+ # Add additional model properties to the instance
47
+ additional_properties = {} if additional_properties.nil?
48
+
49
+ @currency = currency
50
+ @value = value
51
+ @text = text
52
+ @additional_properties = additional_properties
53
+ end
54
+
55
+ # Creates an instance of the object from a hash.
56
+ def self.from_hash(hash)
57
+ return nil unless hash
58
+
59
+ # Extract variables from the hash.
60
+ currency = hash.key?('currency') ? hash['currency'] : nil
61
+ value = hash.key?('value') ? hash['value'] : nil
62
+ text = hash.key?('text') ? hash['text'] : nil
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
+ Fare.new(currency: currency,
73
+ value: value,
74
+ text: text,
75
+ additional_properties: additional_properties)
76
+ end
77
+
78
+ # Provides a human-readable string representation of the object.
79
+ def to_s
80
+ class_name = self.class.name.split('::').last
81
+ "<#{class_name} currency: #{@currency}, value: #{@value}, text: #{@text},"\
82
+ " additional_properties: #{@additional_properties}>"
83
+ end
84
+
85
+ # Provides a debugging-friendly string with detailed object information.
86
+ def inspect
87
+ class_name = self.class.name.split('::').last
88
+ "<#{class_name} currency: #{@currency.inspect}, value: #{@value.inspect}, text:"\
89
+ " #{@text.inspect}, additional_properties: #{@additional_properties}>"
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,82 @@
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
+ # FieldViolation Model.
8
+ class FieldViolation < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # The name of the invalid field.
13
+ # @return [String]
14
+ attr_accessor :field
15
+
16
+ # A short description of the error.
17
+ # @return [String]
18
+ attr_accessor :description
19
+
20
+ # A mapping from model property names to API property names.
21
+ def self.names
22
+ @_hash = {} if @_hash.nil?
23
+ @_hash['field'] = 'field'
24
+ @_hash['description'] = 'description'
25
+ @_hash
26
+ end
27
+
28
+ # An array for optional fields
29
+ def self.optionals
30
+ []
31
+ end
32
+
33
+ # An array for nullable fields
34
+ def self.nullables
35
+ []
36
+ end
37
+
38
+ def initialize(field:, description:, additional_properties: nil)
39
+ # Add additional model properties to the instance
40
+ additional_properties = {} if additional_properties.nil?
41
+
42
+ @field = field
43
+ @description = description
44
+ @additional_properties = additional_properties
45
+ end
46
+
47
+ # Creates an instance of the object from a hash.
48
+ def self.from_hash(hash)
49
+ return nil unless hash
50
+
51
+ # Extract variables from the hash.
52
+ field = hash.key?('field') ? hash['field'] : nil
53
+ description = hash.key?('description') ? hash['description'] : nil
54
+
55
+ # Create a new hash for additional properties, removing known properties.
56
+ new_hash = hash.reject { |k, _| names.value?(k) }
57
+
58
+ additional_properties = APIHelper.get_additional_properties(
59
+ new_hash, proc { |value| value }
60
+ )
61
+
62
+ # Create object from extracted values.
63
+ FieldViolation.new(field: field,
64
+ description: description,
65
+ additional_properties: additional_properties)
66
+ end
67
+
68
+ # Provides a human-readable string representation of the object.
69
+ def to_s
70
+ class_name = self.class.name.split('::').last
71
+ "<#{class_name} field: #{@field}, description: #{@description}, additional_properties:"\
72
+ " #{@additional_properties}>"
73
+ end
74
+
75
+ # Provides a debugging-friendly string with detailed object information.
76
+ def inspect
77
+ class_name = self.class.name.split('::').last
78
+ "<#{class_name} field: #{@field.inspect}, description: #{@description.inspect},"\
79
+ " additional_properties: #{@additional_properties}>"
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,37 @@
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
+ # Indicates the status code resulting from the geocoding operation. This field
8
+ # may contain the following values.
9
+ class GeocoderStatus
10
+ GEOCODER_STATUS = [
11
+ # TODO: Write general description for OK
12
+ OK = 'OK'.freeze,
13
+
14
+ # TODO: Write general description for ZERO_RESULTS
15
+ ZERO_RESULTS = 'ZERO_RESULTS'.freeze
16
+ ].freeze
17
+
18
+ def self.validate(value)
19
+ return false if value.nil?
20
+
21
+ GEOCODER_STATUS.include?(value)
22
+ end
23
+
24
+ def self.from_value(value, default_value = OK)
25
+ return default_value if value.nil?
26
+
27
+ str = value.to_s.strip
28
+
29
+ case str.downcase
30
+ when 'ok' then OK
31
+ when 'zero_results' then ZERO_RESULTS
32
+ else
33
+ default_value
34
+ end
35
+ end
36
+ end
37
+ end