Sha256: 2a13c03b79fe962c7ef1ab7fc80d79d961f6b813f4dd979e8d7aac860f3ea081

Contents?: true

Size: 1.43 KB

Versions: 30

Compression:

Stored size: 1.43 KB

Contents

require_relative 'environment'
require_relative 'resource_requester'

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

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

      # Gets a collection of environments.
      #
      # @return [Contentful::Management::Array<Contentful::Management::Environment>]
      def all
        @resource_requester.all(
          space_id: @space_id
        )
      end

      # Gets a specific environment.
      #
      # @param [String] environment_id
      #
      # @return [Contentful::Management::Environment]
      def find(environment_id)
        @resource_requester.find(
          space_id: @space_id,
          environment_id: environment_id
        )
      end

      # Create an environment.
      #
      # @param [Hash] attributes
      # @option attributes [String] :name
      #
      # @return [Contentful::Management::Environment]
      def create(attributes)
        associated_class.create(client, @space_id, attributes)
      end

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

      def associated_class
        ::Contentful::Management::Environment
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
contentful-management-3.5.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-3.4.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-3.3.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-3.2.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-3.1.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-3.0.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.13.1 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.13.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.12.1 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.12.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.11.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.10.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.9.1 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.9.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.8.2 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.8.1 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.8.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.7.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.6.0 lib/contentful/management/client_environment_methods_factory.rb
contentful-management-2.5.0 lib/contentful/management/client_environment_methods_factory.rb