Sha256: 68f647ebd81efa10497ba7af1cb474ac41910684661d704b73b0b3b16e02cb4d

Contents?: true

Size: 913 Bytes

Versions: 11

Compression:

Stored size: 913 Bytes

Contents

# frozen_string_literal: true
require 'shopify_cli'

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

      GRAPHQL_FILE = 'extension_update_draft'

      RESPONSE_FIELD = %w(data extensionUpdateDraft)
      VERSION_FIELD = 'extensionVersion'

      def call(context:, api_key:, registration_id:, config:, extension_context:)
        input = {
          api_key: api_key,
          registration_id: registration_id,
          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::VersionConverter.from_hash(context, response.dig(VERSION_FIELD))
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
shopify-cli-1.6.0 lib/project_types/extension/tasks/update_draft.rb
shopify-cli-1.5.0 lib/project_types/extension/tasks/update_draft.rb
shopify-cli-1.4.1 lib/project_types/extension/tasks/update_draft.rb
shopify-cli-1.4.0 lib/project_types/extension/tasks/update_draft.rb
shopify-cli-1.3.1 lib/project_types/extension/tasks/update_draft.rb
shopify-cli-1.3.0 lib/project_types/extension/tasks/update_draft.rb
shopify-cli-1.2.0 lib/project_types/extension/tasks/update_draft.rb
shopify-cli-1.1.2 lib/project_types/extension/tasks/update_draft.rb
shopify-cli-1.1.1 lib/project_types/extension/tasks/update_draft.rb
shopify-cli-1.1.0 lib/project_types/extension/tasks/update_draft.rb
shopify-cli-1.0.5 lib/project_types/extension/tasks/update_draft.rb