Sha256: 8029872e0bae35dd2b80e7eea167ef87d22490d604056716082c3aa8b1aee931

Contents?: true

Size: 930 Bytes

Versions: 20

Compression:

Stored size: 930 Bytes

Contents

# frozen_string_literal: true
require "shopify_cli"

module Extension
  module Tasks
    class CreateExtension < ShopifyCli::Task
      include UserErrors

      GRAPHQL_FILE = "extension_create"

      RESPONSE_FIELD = %w(data extensionCreate)
      REGISTRATION_FIELD = "extensionRegistration"

      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.message("tasks.errors.parse_error")) if response.nil?

        abort_if_user_errors(context, response)
        Converters::RegistrationConverter.from_hash(context, response.dig(REGISTRATION_FIELD))
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
shopify-cli-2.4.0 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-2.3.0 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-2.2.2 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-2.2.1 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-2.2.0 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-2.1.0 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-2.0.2 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-2.0.1 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-2.0.0 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-1.14.0 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-1.13.1 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-1.13.0 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-1.12.0 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-1.11.0 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-1.10.0 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-1.9.1 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-1.9.0 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-1.8.0 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-1.7.1 lib/project_types/extension/tasks/create_extension.rb
shopify-cli-1.7.0 lib/project_types/extension/tasks/create_extension.rb