Class: Extension::Tasks::GetApp

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

Constant Summary collapse

GRAPHQL_FILE =
"get_app_by_api_key"
RESPONSE_FIELD =
%w(data)
APP_FIELD =
"app"

Instance Method Summary collapse

Instance Method Details

#call(context:, api_key:) ⇒ Object



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

def call(context:, api_key:)
  input = { api_key: api_key }

  response = ShopifyCLI::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
  context.abort(context.message("tasks.errors.parse_error")) if response.nil?

  Converters::AppConverter.from_hash(response.dig(APP_FIELD))
end