Class: GoogleMapsPlatform::PlacesAutocompleteResponse
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- GoogleMapsPlatform::PlacesAutocompleteResponse
- Defined in:
- lib/google_maps_platform/models/places_autocomplete_response.rb
Overview
PlacesAutocompleteResponse Model.
Instance Attribute Summary collapse
-
#error_message ⇒ String
When the service returns a status code other than
OK<, there may be an additionalerror_messagefield within the response object. -
#info_messages ⇒ Array[String]
When the service returns additional information about the request specification, there may be an additional
info_messagesfield within the response object. -
#predictions ⇒ Array[PlaceAutocompletePrediction]
Contains an array of predictions.
-
#status ⇒ PlacesAutocompleteStatus
Status codes returned by service.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(predictions:, status:, error_message: SKIP, info_messages: SKIP, additional_properties: nil) ⇒ PlacesAutocompleteResponse
constructor
A new instance of PlacesAutocompleteResponse.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(predictions:, status:, error_message: SKIP, info_messages: SKIP, additional_properties: nil) ⇒ PlacesAutocompleteResponse
Returns a new instance of PlacesAutocompleteResponse.
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/google_maps_platform/models/places_autocomplete_response.rb', line 79 def initialize(predictions:, status:, error_message: SKIP, info_messages: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @predictions = predictions @status = status @error_message = unless == SKIP @info_messages = unless == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#error_message ⇒ String
When the service returns a status code other than OK<, there may be an additional error_message field within the response object. This field contains more detailed information about thereasons behind the given status code. This field is not always returned, and its content is subject to change.
47 48 49 |
# File 'lib/google_maps_platform/models/places_autocomplete_response.rb', line 47 def @error_message end |
#info_messages ⇒ Array[String]
When the service returns additional information about the request specification, there may be an additional info_messages field within the response object. This field is only returned for successful requests. It may not always be returned, and its content is subject to change.
54 55 56 |
# File 'lib/google_maps_platform/models/places_autocomplete_response.rb', line 54 def @info_messages end |
#predictions ⇒ Array[PlaceAutocompletePrediction]
Contains an array of predictions.
14 15 16 |
# File 'lib/google_maps_platform/models/places_autocomplete_response.rb', line 14 def predictions @predictions end |
#status ⇒ PlacesAutocompleteStatus
Status codes returned by service.
-
OKindicating the API request was successful. -
ZERO_RESULTSindicating that the search was successful but returned no
results. This may occur if the search was passed a bounds in a remote location.
-
INVALID_REQUESTindicating the API request was malformed, generally
due to the missing input parameter.
-
OVER_QUERY_LIMITindicating any of the following:-
You have exceeded the QPS limits.
-
Billing has not been enabled on your account.
-
The monthly $200 credit, or a self-imposed usage cap, has been
-
exceeded.
- The provided method of payment is no longer valid (for example, a
credit card has expired).
See the [Maps
FAQ](developers.google.com/maps/faq#over-limit-key-error) for more information about how to resolve this error.
-
REQUEST_DENIEDindicating that your request was denied, generally
because:
- The request is missing an API key.
- The `key` parameter is invalid.
-
UNKNOWN_ERRORindicating an unknown error.
39 40 41 |
# File 'lib/google_maps_platform/models/places_autocomplete_response.rb', line 39 def status @status end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/google_maps_platform/models/places_autocomplete_response.rb', line 92 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it predictions = nil unless hash['predictions'].nil? predictions = [] hash['predictions'].each do |structure| predictions << (PlaceAutocompletePrediction.from_hash(structure) if structure) end end predictions = nil unless hash.key?('predictions') status = hash.key?('status') ? hash['status'] : nil = hash.key?('error_message') ? hash['error_message'] : SKIP = hash.key?('info_messages') ? hash['info_messages'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. PlacesAutocompleteResponse.new(predictions: predictions, status: status, error_message: , info_messages: , additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
57 58 59 60 61 62 63 64 |
# File 'lib/google_maps_platform/models/places_autocomplete_response.rb', line 57 def self.names @_hash = {} if @_hash.nil? @_hash['predictions'] = 'predictions' @_hash['status'] = 'status' @_hash['error_message'] = 'error_message' @_hash['info_messages'] = 'info_messages' @_hash end |
.nullables ⇒ Object
An array for nullable fields
75 76 77 |
# File 'lib/google_maps_platform/models/places_autocomplete_response.rb', line 75 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
67 68 69 70 71 72 |
# File 'lib/google_maps_platform/models/places_autocomplete_response.rb', line 67 def self.optionals %w[ error_message info_messages ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
134 135 136 137 138 139 |
# File 'lib/google_maps_platform/models/places_autocomplete_response.rb', line 134 def inspect class_name = self.class.name.split('::').last "<#{class_name} predictions: #{@predictions.inspect}, status: #{@status.inspect},"\ " error_message: #{@error_message.inspect}, info_messages: #{@info_messages.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
126 127 128 129 130 131 |
# File 'lib/google_maps_platform/models/places_autocomplete_response.rb', line 126 def to_s class_name = self.class.name.split('::').last "<#{class_name} predictions: #{@predictions}, status: #{@status}, error_message:"\ " #{@error_message}, info_messages: #{@info_messages}, additional_properties:"\ " #{@additional_properties}>" end |