Class: GoogleMapsPlatform::PlacesTextSearchResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/google_maps_platform/models/places_text_search_response.rb

Overview

PlacesTextSearchResponse Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(html_attributions:, results:, status:, error_message: SKIP, info_messages: SKIP, next_page_token: SKIP, additional_properties: nil) ⇒ PlacesTextSearchResponse

Returns a new instance of PlacesTextSearchResponse.



99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/google_maps_platform/models/places_text_search_response.rb', line 99

def initialize(html_attributions:, results:, status:, error_message: SKIP,
               info_messages: SKIP, next_page_token: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance

  additional_properties = {} if additional_properties.nil?

  @html_attributions = html_attributions
  @results = results
  @status = status
  @error_message = error_message unless error_message == SKIP
  @info_messages = info_messages unless info_messages == SKIP
  @next_page_token = next_page_token unless next_page_token == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#error_messageString

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.

Returns:

  • (String)


56
57
58
# File 'lib/google_maps_platform/models/places_text_search_response.rb', line 56

def error_message
  @error_message
end

#html_attributionsArray[String]

May contain a set of attributions about this listing which must be displayed to the user (some listings may not have attribution).

Returns:

  • (Array[String])


15
16
17
# File 'lib/google_maps_platform/models/places_text_search_response.rb', line 15

def html_attributions
  @html_attributions
end

#info_messagesArray[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.

Returns:

  • (Array[String])


63
64
65
# File 'lib/google_maps_platform/models/places_text_search_response.rb', line 63

def info_messages
  @info_messages
end

#next_page_tokenString

Contains a token that can be used to return up to 20 additional results. A next_page_token will not be returned if there are no additional results to display. The maximum number of results that can be returned is 60. There is a short delay between when a next_page_token is issued, and when it will become valid.

Returns:

  • (String)


71
72
73
# File 'lib/google_maps_platform/models/places_text_search_response.rb', line 71

def next_page_token
  @next_page_token
end

#resultsArray[Place]

Contains an array of places. <div class=“caution”>Place Search requests return a subset of the fields that are returned by Place Details requests. If the field you want is not returned by Place Search, you can use Place Search to get a place_id, then use that Place ID to make a Place Details request.</div>

Returns:



23
24
25
# File 'lib/google_maps_platform/models/places_text_search_response.rb', line 23

def results
  @results
end

#statusPlacesSearchStatus

Status codes returned by service.

  • OK indicating the API request was successful.

  • ZERO_RESULTS indicating that the search was successful but returned no

results. This may occur if the search was passed a latlng in a remote location.

  • INVALID_REQUEST indicating the API request was malformed, generally

due to missing required query parameter (location or radius).

  • OVER_QUERY_LIMIT indicating 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_DENIED indicating that your request was denied, generally

because:

- The request is missing an API key.
- The `key` parameter is invalid.
  • UNKNOWN_ERROR indicating an unknown error.

Returns:



48
49
50
# File 'lib/google_maps_platform/models/places_text_search_response.rb', line 48

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/google_maps_platform/models/places_text_search_response.rb', line 115

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  html_attributions =
    hash.key?('html_attributions') ? hash['html_attributions'] : nil
  # Parameter is an array, so we need to iterate through it

  results = nil
  unless hash['results'].nil?
    results = []
    hash['results'].each do |structure|
      results << (Place.from_hash(structure) if structure)
    end
  end

  results = nil unless hash.key?('results')
  status = hash.key?('status') ? hash['status'] : nil
  error_message = hash.key?('error_message') ? hash['error_message'] : SKIP
  info_messages = hash.key?('info_messages') ? hash['info_messages'] : SKIP
  next_page_token =
    hash.key?('next_page_token') ? hash['next_page_token'] : 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.

  PlacesTextSearchResponse.new(html_attributions: html_attributions,
                               results: results,
                               status: status,
                               error_message: error_message,
                               info_messages: info_messages,
                               next_page_token: next_page_token,
                               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



74
75
76
77
78
79
80
81
82
83
# File 'lib/google_maps_platform/models/places_text_search_response.rb', line 74

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['html_attributions'] = 'html_attributions'
  @_hash['results'] = 'results'
  @_hash['status'] = 'status'
  @_hash['error_message'] = 'error_message'
  @_hash['info_messages'] = 'info_messages'
  @_hash['next_page_token'] = 'next_page_token'
  @_hash
end

.nullablesObject

An array for nullable fields



95
96
97
# File 'lib/google_maps_platform/models/places_text_search_response.rb', line 95

def self.nullables
  []
end

.optionalsObject

An array for optional fields



86
87
88
89
90
91
92
# File 'lib/google_maps_platform/models/places_text_search_response.rb', line 86

def self.optionals
  %w[
    error_message
    info_messages
    next_page_token
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



163
164
165
166
167
168
169
# File 'lib/google_maps_platform/models/places_text_search_response.rb', line 163

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} html_attributions: #{@html_attributions.inspect}, results:"\
  " #{@results.inspect}, status: #{@status.inspect}, error_message: #{@error_message.inspect},"\
  " info_messages: #{@info_messages.inspect}, next_page_token: #{@next_page_token.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



155
156
157
158
159
160
# File 'lib/google_maps_platform/models/places_text_search_response.rb', line 155

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} html_attributions: #{@html_attributions}, results: #{@results}, status:"\
  " #{@status}, error_message: #{@error_message}, info_messages: #{@info_messages},"\
  " next_page_token: #{@next_page_token}, additional_properties: #{@additional_properties}>"
end