Class: Edi::Wayfair::RecordCatalogParentCoverage

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
app/services/edi/wayfair/record_catalog_parent_coverage.rb

Overview

Replaces each active catalog item's complete set of live Wayfair parent
products after, and only after, a successful paginated Supplier Catalog v1
scan. Keeping the full set separately from the current canonical PDP URL
makes duplicate parent listings observable without reintroducing URL churn.

Defined Under Namespace

Classes: Coverage, Result, Scan, ScanValidator

Instance Method Summary collapse

Methods included from Service

#attributes_used, #build_result, call, #logger

Methods included from Service::Initializer

#initialize

Instance Method Details

#callResult

Returns:



25
26
27
28
29
30
31
32
33
34
35
# File 'app/services/edi/wayfair/record_catalog_parent_coverage.rb', line 25

def call
  return Result.new(errors: ['Catalog is required']) unless catalog.is_a?(Catalog)

  scan = Scan.new(ecls)
  return Result.new(errors: scan.errors) if scan.errors.any?

  coverage = Coverage.new(catalog:, products: scan.products)
  return Result.new(errors: coverage.errors) if coverage.errors.any?

  persist(coverage)
end