Class: Repull::Review

Inherits:
ApiModelBase show all
Defined in:
lib/repull/models/review.rb

Overview

A guest or host review unified across channels. Returned by ‘GET /v1/reviews` and `GET /v1/reviews/#id`. Populated from main vanio’s unified ‘reviews` table after the per-channel backfill cron has run.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ Review

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/repull/models/review.rb', line 160

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Repull::Review` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Repull::Review`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.key?(:'external_id')
    self.external_id = attributes[:'external_id']
  end

  if attributes.key?(:'platform')
    self.platform = attributes[:'platform']
  end

  if attributes.key?(:'listing_id')
    self.listing_id = attributes[:'listing_id']
  end

  if attributes.key?(:'reservation_id')
    self.reservation_id = attributes[:'reservation_id']
  end

  if attributes.key?(:'reservation_confirmation_code')
    self.reservation_confirmation_code = attributes[:'reservation_confirmation_code']
  end

  if attributes.key?(:'guest_id')
    self.guest_id = attributes[:'guest_id']
  end

  if attributes.key?(:'guest_name')
    self.guest_name = attributes[:'guest_name']
  end

  if attributes.key?(:'guest_avatar')
    self.guest_avatar = attributes[:'guest_avatar']
  end

  if attributes.key?(:'reviewer_role')
    self.reviewer_role = attributes[:'reviewer_role']
  end

  if attributes.key?(:'rating')
    self.rating = attributes[:'rating']
  end

  if attributes.key?(:'categories')
    if (value = attributes[:'categories']).is_a?(Array)
      self.categories = value
    end
  end

  if attributes.key?(:'public_review')
    self.public_review = attributes[:'public_review']
  end

  if attributes.key?(:'private_feedback')
    self.private_feedback = attributes[:'private_feedback']
  end

  if attributes.key?(:'is_reviewee_recommended')
    self.is_reviewee_recommended = attributes[:'is_reviewee_recommended']
  end

  if attributes.key?(:'response')
    self.response = attributes[:'response']
  end

  if attributes.key?(:'submitted_at')
    self. = attributes[:'submitted_at']
  end

  if attributes.key?(:'updated_at')
    self.updated_at = attributes[:'updated_at']
  end

  if attributes.key?(:'expires_at')
    self.expires_at = attributes[:'expires_at']
  end

  if attributes.key?(:'hidden')
    self.hidden = attributes[:'hidden']
  end

  if attributes.key?(:'language')
    self.language = attributes[:'language']
  end
end

Instance Attribute Details

#categoriesObject

Returns the value of attribute categories.



47
48
49
# File 'lib/repull/models/review.rb', line 47

def categories
  @categories
end

#expires_atObject

When the review window closes (Airbnb has a 14-day window after checkout).



65
66
67
# File 'lib/repull/models/review.rb', line 65

def expires_at
  @expires_at
end

#external_idObject

ID in the source channel (Airbnb review id, Booking review id, etc.).



23
24
25
# File 'lib/repull/models/review.rb', line 23

def external_id
  @external_id
end

#guest_avatarObject

Returns the value of attribute guest_avatar.



39
40
41
# File 'lib/repull/models/review.rb', line 39

def guest_avatar
  @guest_avatar
end

#guest_idObject

Returns the value of attribute guest_id.



35
36
37
# File 'lib/repull/models/review.rb', line 35

def guest_id
  @guest_id
end

#guest_nameObject

Returns the value of attribute guest_name.



37
38
39
# File 'lib/repull/models/review.rb', line 37

def guest_name
  @guest_name
end

#hiddenObject

Returns the value of attribute hidden.



67
68
69
# File 'lib/repull/models/review.rb', line 67

def hidden
  @hidden
end

#idObject

Internal Repull review id — pass back to ‘/v1/reviews/#id`.



20
21
22
# File 'lib/repull/models/review.rb', line 20

def id
  @id
end

Did the reviewer recommend the reviewee? Used for guest-side reviews.



56
57
58
# File 'lib/repull/models/review.rb', line 56

def is_reviewee_recommended
  @is_reviewee_recommended
end

#languageObject

Detected language (ISO 639-1) of the review body.



70
71
72
# File 'lib/repull/models/review.rb', line 70

def language
  @language
end

#listing_idObject

Internal Repull listing id the review is attached to.



28
29
30
# File 'lib/repull/models/review.rb', line 28

def listing_id
  @listing_id
end

#platformObject

Returns the value of attribute platform.



25
26
27
# File 'lib/repull/models/review.rb', line 25

def platform
  @platform
end

#private_feedbackObject

Private feedback the reviewer sent only to the host.



53
54
55
# File 'lib/repull/models/review.rb', line 53

def private_feedback
  @private_feedback
end

#public_reviewObject

Public-facing review text shown on the listing page.



50
51
52
# File 'lib/repull/models/review.rb', line 50

def public_review
  @public_review
end

#ratingObject

Overall rating on the platform’s scale (typically 1..5). May be ‘null` for review types that lack a numeric overall score.



45
46
47
# File 'lib/repull/models/review.rb', line 45

def rating
  @rating
end

#reservation_confirmation_codeObject

Channel-side confirmation code for the reservation being reviewed.



33
34
35
# File 'lib/repull/models/review.rb', line 33

def reservation_confirmation_code
  @reservation_confirmation_code
end

#reservation_idObject

Returns the value of attribute reservation_id.



30
31
32
# File 'lib/repull/models/review.rb', line 30

def reservation_id
  @reservation_id
end

#responseObject

Returns the value of attribute response.



58
59
60
# File 'lib/repull/models/review.rb', line 58

def response
  @response
end

#reviewer_roleObject

Who wrote the review — ‘guest` (about the host/property) or `host` (about the guest).



42
43
44
# File 'lib/repull/models/review.rb', line 42

def reviewer_role
  @reviewer_role
end

#submitted_atObject

Returns the value of attribute submitted_at.



60
61
62
# File 'lib/repull/models/review.rb', line 60

def 
  @submitted_at
end

#updated_atObject

Returns the value of attribute updated_at.



62
63
64
# File 'lib/repull/models/review.rb', line 62

def updated_at
  @updated_at
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



100
101
102
# File 'lib/repull/models/review.rb', line 100

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



105
106
107
# File 'lib/repull/models/review.rb', line 105

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/repull/models/review.rb', line 73

def self.attribute_map
  {
    :'id' => :'id',
    :'external_id' => :'externalId',
    :'platform' => :'platform',
    :'listing_id' => :'listingId',
    :'reservation_id' => :'reservationId',
    :'reservation_confirmation_code' => :'reservationConfirmationCode',
    :'guest_id' => :'guestId',
    :'guest_name' => :'guestName',
    :'guest_avatar' => :'guestAvatar',
    :'reviewer_role' => :'reviewerRole',
    :'rating' => :'rating',
    :'categories' => :'categories',
    :'public_review' => :'publicReview',
    :'private_feedback' => :'privateFeedback',
    :'is_reviewee_recommended' => :'isRevieweeRecommended',
    :'response' => :'response',
    :'submitted_at' => :'submittedAt',
    :'updated_at' => :'updatedAt',
    :'expires_at' => :'expiresAt',
    :'hidden' => :'hidden',
    :'language' => :'language'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/repull/models/review.rb', line 319

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/repull/models/review.rb', line 137

def self.openapi_nullable
  Set.new([
    :'platform',
    :'listing_id',
    :'reservation_id',
    :'reservation_confirmation_code',
    :'guest_id',
    :'guest_name',
    :'guest_avatar',
    :'rating',
    :'public_review',
    :'private_feedback',
    :'is_reviewee_recommended',
    :'response',
    :'submitted_at',
    :'updated_at',
    :'expires_at',
    :'language'
  ])
end

.openapi_typesObject

Attribute type mapping.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/repull/models/review.rb', line 110

def self.openapi_types
  {
    :'id' => :'String',
    :'external_id' => :'String',
    :'platform' => :'String',
    :'listing_id' => :'String',
    :'reservation_id' => :'String',
    :'reservation_confirmation_code' => :'String',
    :'guest_id' => :'String',
    :'guest_name' => :'String',
    :'guest_avatar' => :'String',
    :'reviewer_role' => :'String',
    :'rating' => :'Float',
    :'categories' => :'Array<ReviewCategory>',
    :'public_review' => :'String',
    :'private_feedback' => :'String',
    :'is_reviewee_recommended' => :'Boolean',
    :'response' => :'ReviewResponse',
    :'submitted_at' => :'Time',
    :'updated_at' => :'Time',
    :'expires_at' => :'Time',
    :'hidden' => :'Boolean',
    :'language' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/repull/models/review.rb', line 278

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      external_id == o.external_id &&
      platform == o.platform &&
      listing_id == o.listing_id &&
      reservation_id == o.reservation_id &&
      reservation_confirmation_code == o.reservation_confirmation_code &&
      guest_id == o.guest_id &&
      guest_name == o.guest_name &&
      guest_avatar == o.guest_avatar &&
      reviewer_role == o.reviewer_role &&
      rating == o.rating &&
      categories == o.categories &&
      public_review == o.public_review &&
      private_feedback == o.private_feedback &&
      is_reviewee_recommended == o.is_reviewee_recommended &&
      response == o.response &&
       == o. &&
      updated_at == o.updated_at &&
      expires_at == o.expires_at &&
      hidden == o.hidden &&
      language == o.language
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


306
307
308
# File 'lib/repull/models/review.rb', line 306

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



312
313
314
# File 'lib/repull/models/review.rb', line 312

def hash
  [id, external_id, platform, listing_id, reservation_id, reservation_confirmation_code, guest_id, guest_name, guest_avatar, reviewer_role, rating, categories, public_review, private_feedback, is_reviewee_recommended, response, , updated_at, expires_at, hidden, language].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



263
264
265
266
267
# File 'lib/repull/models/review.rb', line 263

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/repull/models/review.rb', line 341

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



271
272
273
274
# File 'lib/repull/models/review.rb', line 271

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  true
end