Sha256: 3a1444aa13f934fbca5ab917f326627e3083f7921732d63415993fbd459dcbb6

Contents?: true

Size: 1.33 KB

Versions: 18

Compression:

Stored size: 1.33 KB

Contents

require_relative 'resource_requester'

module Contentful
  module Management
    # Wrapper for Space API for usage from within Client
    # @private
    class ClientSpaceMethodsFactory
      attr_reader :client

      def initialize(client)
        @client = client
        @resource_requester = ResourceRequester.new(client, associated_class)
      end

      # Gets a collection of spaces.
      #
      # @return [Contentful::Management::Array<Contentful::Management::Space>]
      def all
        @resource_requester.all
      end

      # Gets a specific space.
      #
      # @param [String] space_id
      #
      # @return [Contentful::Management::Space]
      def find(space_id)
        @resource_requester.find(space_id: space_id)
      end

      # Create a space.
      #
      # @param [Hash] attributes
      # @option attributes [String] :name
      # @option attributes [String] :default_locale
      # @option attributes [String] :organization_id Required if user has more than one organization
      #
      # @return [Contentful::Management::Space]
      def create(attributes)
        associated_class.create(client, attributes)
      end

      def new
        object = associated_class.new
        object.client = client
        object
      end

      def associated_class
        ::Contentful::Management::Space
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
contentful-management-2.9.1 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.9.0 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.8.2 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.8.1 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.8.0 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.7.0 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.6.0 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.5.0 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.4.0 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.3.0 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.2.2 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.2.1 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.2.0 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.1.1 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.1.0 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.0.2 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.0.1 lib/contentful/management/client_space_methods_factory.rb
contentful-management-2.0.0 lib/contentful/management/client_space_methods_factory.rb