Sha256: 7a4a3c6ff8792d671245fb3699e55242c297cab3748c8c161fb6e9231684510d

Contents?: true

Size: 993 Bytes

Versions: 13

Compression:

Stored size: 993 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

13 entries across 13 versions & 1 rubygems

Version Path
shopify-cli-1.6.0 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.5.0 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.4.1 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.4.0 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.3.1 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.3.0 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.2.0 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.1.2 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.1.1 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.1.0 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.0.5 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.0.4 lib/shopify-cli/partners_api/organizations.rb
shopify-cli-1.0.3 lib/shopify-cli/partners_api/organizations.rb