Class: Api::ReviewsIo::ReviewProxy

Inherits:
Object
  • Object
show all
Defined in:
app/services/api/reviews_io/reviews_fetcher.rb

Overview

Lightweight proxy object that mimics Review model for display purposes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headline:, full_review:, reviewer_name:, reviewer_city:, reviewer_state:, star_rating_level:, created_at:, updated_at:) ⇒ ReviewProxy

Returns a new instance of ReviewProxy.



304
305
306
307
308
309
310
311
312
313
314
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 304

def initialize(headline:, full_review:, reviewer_name:, reviewer_city:, reviewer_state:,
               star_rating_level:, created_at:, updated_at:)
  @headline_review = headline
  @full_review = full_review
  @reviewer_name = reviewer_name
  @reviewer_city = reviewer_city
  @reviewer_state = reviewer_state
  @star_rating_level = star_rating_level
  @created_at = created_at
  @updated_at = updated_at
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



301
302
303
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 301

def created_at
  @created_at
end

#full_reviewObject (readonly)

Returns the value of attribute full_review.



301
302
303
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 301

def full_review
  @full_review
end

#headline_reviewObject (readonly)

Returns the value of attribute headline_review.



301
302
303
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 301

def headline_review
  @headline_review
end

#reviewer_cityObject (readonly)

Returns the value of attribute reviewer_city.



301
302
303
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 301

def reviewer_city
  @reviewer_city
end

#reviewer_nameObject (readonly)

Returns the value of attribute reviewer_name.



301
302
303
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 301

def reviewer_name
  @reviewer_name
end

#reviewer_stateObject (readonly)

Returns the value of attribute reviewer_state.



301
302
303
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 301

def reviewer_state
  @reviewer_state
end

#star_rating_levelObject (readonly)

Returns the value of attribute star_rating_level.



301
302
303
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 301

def star_rating_level
  @star_rating_level
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



301
302
303
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 301

def updated_at
  @updated_at
end

Instance Method Details

#digital_assetsObject

Reviews.io reviews don't have associated digital assets in our DB



327
328
329
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 327

def digital_assets
  []
end

#idObject

Reviews from Reviews.io don't have database IDs



317
318
319
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 317

def id
  nil
end

#is_publicObject

Reviews.io reviews are public by default



322
323
324
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 322

def is_public
  true
end

#itemsObject

Reviews.io reviews don't have associated items



352
353
354
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 352

def items
  []
end

#obfuscated_reviewer_nameObject

Return obfuscated name for privacy



357
358
359
360
361
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 357

def obfuscated_reviewer_name
  return nil unless reviewer_name.present?

  PersonNameParser.new(reviewer_name).obfuscated_name
end

#orderObject

Reviews.io reviews don't have associated orders



337
338
339
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 337

def order
  nil
end

#product_lineObject

Reviews.io reviews don't have associated product lines



347
348
349
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 347

def product_line
  nil
end

#schema_dot_org_structureObject

Schema.org structure for reviews



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 364

def schema_dot_org_structure
  SchemaDotOrg::Review.new(
    name: headline_review&.squish,
    author: SchemaDotOrg::Person.new(
      name: obfuscated_reviewer_name,
      address: (
        if reviewer_city.present? || reviewer_state.present?
          SchemaDotOrg::PostalAddress.new(
            addressLocality: reviewer_city.presence,
            addressRegion: reviewer_state.presence
          )
        end
      )
    ),
    reviewBody: full_review&.squish,
    reviewRating: SchemaDotOrg::Rating.new(
      bestRating: 5,
      worstRating: 1,
      ratingValue: star_rating_level.to_i
    ),
    datePublished: created_at.to_date
  )
end

#support_caseObject

Reviews.io reviews don't have associated support cases



342
343
344
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 342

def support_case
  nil
end

#wy_commentObject

Reviews.io reviews don't have WarmlyYours comments



332
333
334
# File 'app/services/api/reviews_io/reviews_fetcher.rb', line 332

def wy_comment
  nil
end