Sha256: 393509abe35d3ea08f27a002ce18039c69b3c23a787da826ef2d928225fc1f53
Contents?: true
Size: 1.04 KB
Versions: 26
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true require "shopify_cli" module Extension module Tasks class GetExtensions < ShopifyCLI::Task def call(context:, type:) org_id = ShopifyCLI::DB.get(:organization_id) return [] unless org_id organization = ShopifyCLI::PartnersAPI::Organizations.fetch_with_extensions(context, type, id: org_id) return [] unless organization_with_apps?(organization) extensions_owned_by_organization(organization, context: context) end private def extensions_owned_by_organization(organization, context:) organization["apps"].flat_map do |app| registrations = app["extensionRegistrations"] || [] registrations.map do |registration| [Converters::AppConverter.from_hash(app, organization), Converters::RegistrationConverter.from_hash(context, registration)] end end end def organization_with_apps?(organization) organization&.key?("apps") && organization["apps"].any? end end end end
Version data entries
26 entries across 26 versions & 1 rubygems