Sha256: fb8fa89dfb9cb7ec94286470a112154618123e1a023a19553f49aa7f55e9469e

Contents?: true

Size: 1 KB

Versions: 31

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true
require "shopify_cli"

module Extension
  module Tasks
    class GetExtensions < ShopifyCLI::Task
      def call(context:, type:)
        organizations = ShopifyCLI::PartnersAPI::Organizations.fetch_with_extensions(context, type)
        extensions_from_organizations(organizations, context: context)
      end

      private

      def extensions_from_organizations(organizations, context:)
        organizations.flat_map do |organization|
          extensions_owned_by_organization(organization, context: context)
        end
      end

      def extensions_owned_by_organization(organization, context:)
        return [] unless organization.key?("apps") && organization["apps"].any?

        organization["apps"].flat_map do |app|
          app["extensionRegistrations"].map do |registration|
            [Converters::AppConverter.from_hash(app, organization),
             Converters::RegistrationConverter.from_hash(context, registration)]
          end
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
shopify-cli-2.15.6 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.15.5 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.15.4 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.15.3 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.15.2 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.15.1 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.15.0 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.14.0 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.13.0 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.12.0 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.11.2 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.11.1 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.11.0 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.10.2 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.10.1 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.10.0 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.9.0 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.8.0 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.7.4 lib/project_types/extension/tasks/get_extensions.rb
shopify-cli-2.7.3 lib/project_types/extension/tasks/get_extensions.rb