Sha256: cfa33b0da9bb41ee3afe60a84f5bf27b052c8bfcc8545a8bbb2008ce7d89a031

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

require_relative 'client_association_methods_factory'

module Contentful
  module Management
    # Wrapper for API Usage for usage from within Client
    # @private
    class ClientApiUsageMethodsFactory
      include Contentful::Management::ClientAssociationMethodsFactory

      def initialize(client, organization_id)
        super(client)
        @organization_id = organization_id
      end

      def all(usage_type, usage_period_id, api, params = {})
        mandatory_params = {
          'filters[usagePeriod]' => usage_period_id,
          'filters[metric]' => api
        }

        @resource_requester.all(
          {
            usage_type: usage_type,
            organization_id: @organization_id
          },
          mandatory_params.merge(params),
          'x-contentful-enable-alpha-feature' => 'usage-insights'
        )
      end

      def new(*)
        fail 'Not supported'
      end

      def find(*)
        fail 'Not supported'
      end

      def create(*)
        fail 'Not supported'
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
contentful-management-2.11.0 lib/contentful/management/client_api_usage_methods_factory.rb
contentful-management-2.10.0 lib/contentful/management/client_api_usage_methods_factory.rb
contentful-management-2.9.1 lib/contentful/management/client_api_usage_methods_factory.rb
contentful-management-2.9.0 lib/contentful/management/client_api_usage_methods_factory.rb
contentful-management-2.8.2 lib/contentful/management/client_api_usage_methods_factory.rb
contentful-management-2.8.1 lib/contentful/management/client_api_usage_methods_factory.rb
contentful-management-2.8.0 lib/contentful/management/client_api_usage_methods_factory.rb
contentful-management-2.7.0 lib/contentful/management/client_api_usage_methods_factory.rb
contentful-management-2.6.0 lib/contentful/management/client_api_usage_methods_factory.rb