Class: Extension::Tasks::GetProduct

Inherits:
ShopifyCLI::Task show all
Defined in:
lib/project_types/extension/tasks/get_product.rb

Constant Summary collapse

API_VERSION =
"2021-07"
GRAPHQL_FILE =
"get_variant_id"

Instance Method Summary collapse

Instance Method Details

#call(context, shop) ⇒ Object



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

def call(context, shop)
  response = ShopifyCLI::AdminAPI.query(
    context,
    GRAPHQL_FILE,
    shop: shop,
    api_version: API_VERSION
  )
  context.abort(context.message("tasks.errors.store_error")) if response.nil?
  Converters::ProductConverter.from_hash(response)
end