Class: Edi::Wayfair::RecordCatalogParentCoverage::Scan
- Inherits:
-
Object
- Object
- Edi::Wayfair::RecordCatalogParentCoverage::Scan
- 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
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(ecls) ⇒ Scan
constructor
A new instance of Scan.
- #products ⇒ Array<Hash>
Constructor Details
#initialize(ecls) ⇒ Scan
Returns a new instance of Scan.
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.}"] end |
Instance Attribute Details
#errors ⇒ Object (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
#products ⇒ 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 |