Class: Warranty::RegistrantResolver
- Inherits:
-
Object
- Object
- Warranty::RegistrantResolver
- Includes:
- Service
- Defined in:
- app/services/warranty/registrant_resolver.rb
Overview
Resolves the END CONSUMER Customer a warranty registration belongs to
(Warranty Registration v2, ยง5 of the task doc).
- Direct order โ the order's customer already IS the end consumer; reuse
it (the form just refreshes contact info downstream). - Retailer/marketplace order or no order โ the buyer has no Party of
their own yet. Dedupe by email/phone via the same duplicate detection
the CRM new-customer wizard uses; only when nothing matches, create a
Homeowner customer (creation_method: :web). The retailer order is
NEVER reparented โ the warranty row points at both.
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
Methods included from Service
#attributes_used, #build_result, call, #logger
Methods included from Service::Initializer
Instance Method Details
#call ⇒ Result
42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/services/warranty/registrant_resolver.rb', line 42 def call return Result.new(success: true, customer: order.customer) if order&.customer && !order.customer.retailer_organization? return Result.new(success: false, error: 'An email address is required to register a warranty.') if email.blank? if (existing = matching_customer) return Result.new(success: true, customer: existing) end create_customer end |