Sha256: 78aea7e7cc0c1d949c8e41b9300e69085651dde9883e3a852e0d979e87ae5efb

Contents?: true

Size: 1.81 KB

Versions: 3

Compression:

Stored size: 1.81 KB

Contents

require_relative 'resource'
require_relative 'webhook_webhook_call_methods_factory'
require_relative 'webhook_webhook_health_methods_factory'

module Contentful
  module Management
    # Resource class for Webhook.
    # @see _ https://www.contentful.com/developers/documentation/content-management-api/http/#resources-webhooks
    class Webhook
      include Contentful::Management::Resource
      include Contentful::Management::Resource::SystemProperties
      include Contentful::Management::Resource::Refresher

      property :url, :string
      property :httpBasicUsername, :string
      property :name, :string
      property :headers, :array
      property :topics, :array

      # @private
      def self.endpoint
        'webhook_definitions'
      end

      # @private
      def self.create_attributes(_client, attributes)
        attributes.select { |key, _value| [:httpBasicUsername, :httpBasicPassword, :url, :name, :headers, :topics].include? key }
      end

      # Allows manipulation of webhook call details in context of the current webhook
      # Allows listing all webhook call details for the webhook and finding one by ID.
      # @see _ README for details.
      #
      # @return [Contentful::Management::WebhookWebhookCallMethodsFactory]
      def webhook_calls
        WebhookWebhookCallMethodsFactory.new(self)
      end

      # Allows manipulation of webhook health details in context of the current webhook
      # Allows listing webhook health details for the webhook.
      # @see _ README for details.
      #
      # @return [Contentful::Management::WebhookWebhookHealthMethodsFactory]
      def webhook_health
        WebhookWebhookHealthMethodsFactory.new(self)
      end

      protected

      def query_attributes(attributes)
        self.class.create_attributes(nil, attributes)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
contentful-management-1.10.1 lib/contentful/management/webhook.rb
contentful-management-1.10.0 lib/contentful/management/webhook.rb
contentful-management-1.9.0 lib/contentful/management/webhook.rb