Module: Extension::Tasks::Converters::ProductConverter

Defined in:
lib/project_types/extension/tasks/converters/product_converter.rb

Constant Summary collapse

VARIANT_PATH =
["data", "products", "edges", 0, "node", "variants", "edges", 0, "node", "id"]

Class Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/project_types/extension/tasks/converters/product_converter.rb', line 10

def self.from_hash(hash)
  return nil if hash.nil?
  variant = hash.dig(*VARIANT_PATH)
  return unless variant
  Models::Product.new(
    variant_id: ShopifyCLI::API.gid_to_id(variant)
  )
end