Sha256: 399be4c77d27271469c3605891265be88d2a93da5fdaa9c77c5f9c4057040b50

Contents?: true

Size: 1.2 KB

Versions: 36

Compression:

Stored size: 1.2 KB

Contents

require "pact_broker/api/resources/base_resource"
require "pact_broker/api/decorators/pact_webhooks_status_decorator"

module PactBroker
  module Api
    module Resources
      class PactWebhooksStatus < BaseResource

        def allowed_methods
          ["GET", "OPTIONS"]
        end

        def content_types_provided
          [["application/hal+json", :to_json]]
        end

        def resource_exists?
          consumer && provider
        end

        def to_json
          decorator_for(latest_triggered_webhooks).to_json(decorator_options(identifier_from_path))
        end

        def policy_name
          :'webhooks::webhooks'
        end

        private

        def latest_triggered_webhooks
          @latest_triggered_webhooks ||= webhook_service.find_latest_triggered_webhooks_for_pact(pact)
        end

        def pact
          @pact ||= pact_service.find_latest_pact(pact_params)
        end

        def webhooks
          @webhooks ||= webhook_service.find_by_consumer_and_provider(consumer, provider)
        end

        def decorator_for latest_triggered_webhooks
          decorator_class(:pact_webhooks_status_decorator).new(latest_triggered_webhooks)
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
pact_broker-2.106.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.105.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.104.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.103.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.102.2 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.102.1 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.102.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.101.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.100.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.99.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.98.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.97.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.96.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.95.1 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.95.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.94.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.93.4 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.93.3 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.93.2 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.93.1 lib/pact_broker/api/resources/pact_webhooks_status.rb