Class: Edi::Wayfair::RecordCatalogParentCoverage::Scan

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

Overview

Parses and verifies that ECLs represent one contiguous, successfully
terminated catalog scan. Any uncertainty leaves prior coverage untouched.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ecls) ⇒ Scan

Returns a new instance of Scan.

Parameters:



10
11
12
13
14
15
16
# File 'app/services/edi/wayfair/record_catalog_parent_coverage/scan.rb', line 10

def initialize(ecls)
  @pages = Array(ecls).map { |ecl| parse(ecl) }
  @errors = Edi::Wayfair::RecordCatalogParentCoverage::ScanValidator.new(@pages).errors
rescue JSON::ParserError => e
  @pages = []
  @errors = ["Invalid catalog scan JSON: #{e.message}"]
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'app/services/edi/wayfair/record_catalog_parent_coverage/scan.rb', line 6

def errors
  @errors
end

Instance Method Details

#productsArray<Hash>

Returns:

  • (Array<Hash>)


19
20
21
# File 'app/services/edi/wayfair/record_catalog_parent_coverage/scan.rb', line 19

def products
  @pages.flat_map { |page| page.dig('data', 'supplierCatalog', 'products') }
end