Class: GoogleMapsPlatform::PlaceReview

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

Overview

A review of the place submitted by a user.

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(author_name:, rating:, relative_time_description:, time:, author_url: SKIP, profile_photo_url: SKIP, language: SKIP, original_language: SKIP, text: SKIP, translated: SKIP, additional_properties: nil) ⇒ PlaceReview

Returns a new instance of PlaceReview.



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/place_review.rb', line 105

def initialize(author_name:, rating:, relative_time_description:, time:,
               author_url: SKIP, profile_photo_url: SKIP, language: SKIP,
               original_language: SKIP, text: SKIP, translated: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance

  additional_properties = {} if additional_properties.nil?

  @author_name = author_name
  @author_url = author_url unless author_url == SKIP
  @profile_photo_url = profile_photo_url unless profile_photo_url == SKIP
  @language = language unless language == SKIP
  @original_language = original_language unless original_language == SKIP
  @rating = rating
  @relative_time_description = relative_time_description
  @text = text unless text == SKIP
  @time = time
  @translated = translated unless translated == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#author_nameString

The name of the user who submitted the review. Anonymous reviews are attributed to “A Google user”.

Returns:

  • (String)


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

def author_name
  @author_name
end

#author_urlString

The URL to the user’s Google Maps Local Guides profile, if available.

Returns:

  • (String)


19
20
21
# File 'lib/google_maps_platform/models/place_review.rb', line 19

def author_url
  @author_url
end

#languageString

An IETF language code indicating the language of the returned review. This field contains the main language tag only, and not the secondary tag indicating country or region. For example, all the English reviews are tagged as ‘en’, and not ‘en-AU’ or ‘en-UK’ and so on. This field is empty if there is only a rating with no review text.

Returns:

  • (String)


31
32
33
# File 'lib/google_maps_platform/models/place_review.rb', line 31

def language
  @language
end

#original_languageString

An IETF language code indicating the original language of the review. If the review has been translated, then original_language != language. This field contains the main language tag only, and not the secondary tag indicating country or region. For example, all the English reviews are tagged as ‘en’, and not ‘en-AU’ or ‘en-UK’ and so on. This field is empty if there is only a rating with no review text.

Returns:

  • (String)


40
41
42
# File 'lib/google_maps_platform/models/place_review.rb', line 40

def original_language
  @original_language
end

#profile_photo_urlString

The URL to the user’s profile photo, if available.

Returns:

  • (String)


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

def profile_photo_url
  @profile_photo_url
end

#ratingFloat

The user’s overall rating for this place. This is a whole number, ranging from 1 to 5.

Returns:

  • (Float)


45
46
47
# File 'lib/google_maps_platform/models/place_review.rb', line 45

def rating
  @rating
end

#relative_time_descriptionString

The time that the review was submitted in text, relative to the current time.

Returns:

  • (String)


50
51
52
# File 'lib/google_maps_platform/models/place_review.rb', line 50

def relative_time_description
  @relative_time_description
end

#textString

The user’s review. When reviewing a location with Google Places, text reviews are considered optional. Therefore, this field may be empty. Note that this field may include simple HTML markup. For example, the entity reference ‘&` may represent an ampersand character.

Returns:

  • (String)


57
58
59
# File 'lib/google_maps_platform/models/place_review.rb', line 57

def text
  @text
end

#timeFloat

The time that the review was submitted, measured in the number of seconds since since midnight, January 1, 1970 UTC.

Returns:

  • (Float)


62
63
64
# File 'lib/google_maps_platform/models/place_review.rb', line 62

def time
  @time
end

#translatedTrueClass | FalseClass

A boolean value indicating if the review was translated from the original language it was written in. If a review has been translated, corresponding to a value of true, Google recommends that you indicate this to your users. For example, you can add the following string, “Translated by Google”, to the review.

Returns:

  • (TrueClass | FalseClass)


70
71
72
# File 'lib/google_maps_platform/models/place_review.rb', line 70

def translated
  @translated
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/google_maps_platform/models/place_review.rb', line 126

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  author_name = hash.key?('author_name') ? hash['author_name'] : nil
  rating = hash.key?('rating') ? hash['rating'] : nil
  relative_time_description =
    hash.key?('relative_time_description') ? hash['relative_time_description'] : nil
  time = hash.key?('time') ? hash['time'] : nil
  author_url = hash.key?('author_url') ? hash['author_url'] : SKIP
  profile_photo_url =
    hash.key?('profile_photo_url') ? hash['profile_photo_url'] : SKIP
  language = hash.key?('language') ? hash['language'] : SKIP
  original_language =
    hash.key?('original_language') ? hash['original_language'] : SKIP
  text = hash.key?('text') ? hash['text'] : SKIP
  translated = hash.key?('translated') ? hash['translated'] : 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.

  PlaceReview.new(author_name: author_name,
                  rating: rating,
                  relative_time_description: relative_time_description,
                  time: time,
                  author_url: author_url,
                  profile_photo_url: profile_photo_url,
                  language: language,
                  original_language: original_language,
                  text: text,
                  translated: translated,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/google_maps_platform/models/place_review.rb', line 73

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['author_name'] = 'author_name'
  @_hash['author_url'] = 'author_url'
  @_hash['profile_photo_url'] = 'profile_photo_url'
  @_hash['language'] = 'language'
  @_hash['original_language'] = 'original_language'
  @_hash['rating'] = 'rating'
  @_hash['relative_time_description'] = 'relative_time_description'
  @_hash['text'] = 'text'
  @_hash['time'] = 'time'
  @_hash['translated'] = 'translated'
  @_hash
end

.nullablesObject

An array for nullable fields



101
102
103
# File 'lib/google_maps_platform/models/place_review.rb', line 101

def self.nullables
  []
end

.optionalsObject

An array for optional fields



89
90
91
92
93
94
95
96
97
98
# File 'lib/google_maps_platform/models/place_review.rb', line 89

def self.optionals
  %w[
    author_url
    profile_photo_url
    language
    original_language
    text
    translated
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



176
177
178
179
180
181
182
183
184
# File 'lib/google_maps_platform/models/place_review.rb', line 176

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} author_name: #{@author_name.inspect}, author_url: #{@author_url.inspect},"\
  " profile_photo_url: #{@profile_photo_url.inspect}, language: #{@language.inspect},"\
  " original_language: #{@original_language.inspect}, rating: #{@rating.inspect},"\
  " relative_time_description: #{@relative_time_description.inspect}, text: #{@text.inspect},"\
  " time: #{@time.inspect}, translated: #{@translated.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



166
167
168
169
170
171
172
173
# File 'lib/google_maps_platform/models/place_review.rb', line 166

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} author_name: #{@author_name}, author_url: #{@author_url},"\
  " profile_photo_url: #{@profile_photo_url}, language: #{@language}, original_language:"\
  " #{@original_language}, rating: #{@rating}, relative_time_description:"\
  " #{@relative_time_description}, text: #{@text}, time: #{@time}, translated: #{@translated},"\
  " additional_properties: #{@additional_properties}>"
end