Sha256: 36d150b54165236e7193f14a715baf2fae3aaa8450a90ee62e04fd0a1a755e3f

Contents?: true

Size: 997 Bytes

Versions: 5

Compression:

Stored size: 997 Bytes

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
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shopify-cli-1.14.0 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.13.1 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.13.0 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.12.0 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.11.0 lib/shopify-cli/partners_api/organizations.rb