Sha256: 7f21b1da4ebf9ad1197d796305b050fff93e7f437b4a91c1af41437bd7d7c274

Contents?: true

Size: 1.27 KB

Versions: 12

Compression:

Stored size: 1.27 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_with_app(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_extensions(ctx, type)
          resp = PartnersAPI.query(ctx, "all_orgs_with_extensions", type: type)
          (resp&.dig("data", "organizations", "nodes") || []).map do |org|
            org["apps"] = (org.dig("apps", "nodes") || [])
            org
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
shopify-cli-2.7.3 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.7.2 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.7.1 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.7.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.6.6 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.6.5 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.6.4 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.6.3 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.6.2 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.6.1 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.6.0 lib/shopify_cli/partners_api/organizations.rb
shopify-cli-2.5.0 lib/shopify_cli/partners_api/organizations.rb