Class: Warranty::ReviewPrompt

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
app/services/warranty/review_prompt.rb

Overview

Decides whether the warranty thank-you page should show a Reviews.io
prompt, and builds the link (Warranty Registration v2, §4).

Deliberately conservative:

  • unmatched registrations → no prompt (no order to anchor a review to);
  • retailer/marketplace orders → no prompt until the business confirms
    Reviews.io policy allows company invitations for third-party buyers
    (open question #4 in the task doc);
  • already-reviewed orders → no prompt (orders.reviewed flag plus the
    daily-imported reviews_io mirror, matched on both id semantics).

We link to the self-hosted dynamic review form rather than firing
InvitationSender — the invitation already goes out at invoice time, and
double-sending is a Reviews.io hygiene problem.

Instance Method Summary collapse

Methods included from Service

#attributes_used, #build_result, call, #logger

Methods included from Service::Initializer

#initialize

Instance Method Details

#callString?

Returns the review URL, or nil when no prompt should show.

Returns:

  • (String, nil)

    the review URL, or nil when no prompt should show



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/services/warranty/review_prompt.rb', line 23

def call
  order = warranty&.order
  return if order.nil?
  return if order.customer.nil? || order.customer.retailer_organization?
  return if already_reviewed?(order)

  order.company_review_url
rescue StandardError => e
  # The prompt is a nice-to-have — never let link building break the
  # thank-you page.
  ErrorReporting.warning('Warranty review prompt failed', error: e.message, warranty_id: warranty&.id)
  nil
end