Class: Edi::Wayfair::CatalogReadV2Persister

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

Overview

Persists the current v2 status, class, attributes, and insights for one item.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Methods included from Service

#attributes_used, #build_result, call, #logger

Methods included from Service::Initializer

#initialize

Instance Method Details

#callResult

Syncs the fetched product data onto the catalog item, saving on change.

Returns:



23
24
25
26
27
28
29
30
31
32
33
# File 'app/services/edi/wayfair/catalog_read_v2_persister.rb', line 23

def call
  @changed = false
  sync_insights
  sync_attributes if product.key?('attributes')
  sync_status
  sync_classification
  return Result.new(changed: false) unless @changed

  catalog_item.wayfair_synced_at = Time.current
  Result.new(changed: catalog_item.save)
end