Class: Extension::Tasks::CreateExtension
- Inherits:
-
ShopifyCLI::Task
- Object
- ShopifyCLI::Task
- Extension::Tasks::CreateExtension
- Includes:
- UserErrors
- Defined in:
- lib/project_types/extension/tasks/create_extension.rb
Constant Summary collapse
- GRAPHQL_FILE =
"extension_create"
- RESPONSE_FIELD =
%w(data extensionCreate)
- REGISTRATION_FIELD =
"extensionRegistration"
Constants included from UserErrors
UserErrors::MESSAGE_FIELD, UserErrors::USER_ERRORS_FIELD, UserErrors::USER_ERRORS_PARSE_ERROR
Instance Method Summary collapse
Methods included from UserErrors
Instance Method Details
#call(context:, api_key:, type:, title:, config:, extension_context: nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/project_types/extension/tasks/create_extension.rb', line 14 def call(context:, api_key:, type:, title:, config:, extension_context: nil) input = { api_key: api_key, type: type, title: title, config: JSON.generate(config), extension_context: extension_context, } response = ShopifyCLI::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD) context.abort(context.("tasks.errors.parse_error")) if response.nil? abort_if_user_errors(context, response) Converters::RegistrationConverter.from_hash(context, response.dig(REGISTRATION_FIELD)) end |