Sha256: 3e190703a3d5b5cf9b5d3ca9d6646dd88fe8c1241f8d0d283f27bbbb0aeaa469

Contents?: true

Size: 1.49 KB

Versions: 26

Compression:

Stored size: 1.49 KB

Contents

module ShopifyCLI
  class PartnersAPI
    class Organizations
      class << self
        def fetch_all(ctx)
          resp = PartnersAPI.query(ctx, "all_organizations")
          (resp&.dig("data", "organizations", "nodes") || []).map do |org|
            org["stores"] = (org.dig("stores", "nodes") || [])
            org
          end
        end

        def fetch(ctx, id:)
          resp = PartnersAPI.query(ctx, "find_organization", id: id)
          org = resp&.dig("data", "organizations", "nodes")&.first
          return nil if org.nil?
          org["stores"] = (org.dig("stores", "nodes") || [])
          org
        end

        def fetch_all_with_apps(ctx)
          resp = PartnersAPI.query(ctx, "all_orgs_with_apps")
          (resp&.dig("data", "organizations", "nodes") || []).map do |org|
            org["stores"] = (org.dig("stores", "nodes") || [])
            org["apps"] = (org.dig("apps", "nodes") || [])
            org
          end
        end

        def fetch_with_apps(ctx, id:)
          resp = PartnersAPI.query(ctx, "find_organization_with_apps", id: id)
          organization = resp&.dig("data", "organizations", "nodes")&.first
          return unless organization

          organization.tap { organization["apps"] = (organization.dig("apps", "nodes") || []) }
        end

        def fetch_with_extensions(ctx, type, id:)
          organization = fetch_with_apps(ctx, id: id)
          AppExtensions.fetch_apps_extensions(ctx, organization, type)
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.35.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.34.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.33.1 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.33.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.32.1 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.32.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.31.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.30.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.29.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.28.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.27.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.26.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.25.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.24.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.23.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.22.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.21.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.20.1 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.20.0 lib/shopify_cli/partners_api/organizations.rb