Sha256: b529daabc8f56aec0fe1a348f031b879199d276c670cb63f48c2fd829af88842

Contents?: true

Size: 1.22 KB

Versions: 17

Compression:

Stored size: 1.22 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(user_options: decorator_context(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
          PactBroker::Api::Decorators::PactWebhooksStatusDecorator.new(latest_triggered_webhooks)
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pact_broker-2.74.1 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.74.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.73.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.72.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.71.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.70.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.69.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.68.1 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.68.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.67.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.66.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.65.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.64.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.63.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.62.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.61.0 lib/pact_broker/api/resources/pact_webhooks_status.rb
pact_broker-2.60.1 lib/pact_broker/api/resources/pact_webhooks_status.rb