Sha256: 61ec03b74a0f6cdd7fcbcc1fdfbc273d86d4a23d721536d2b33f7163937552ba

Contents?: true

Size: 1.15 KB

Versions: 36

Compression:

Stored size: 1.15 KB

Contents

require "pact_broker/api/resources/base_resource"
require "pact_broker/webhooks/triggered_webhook"

module PactBroker
  module Api
    module Resources
      class TriggeredWebhookLogs < BaseResource

        def content_types_provided
          [["text/plain", :to_text]]
        end

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

        def resource_exists?
          !!triggered_webhook
        end

        def to_text
          # Too simple to bother putting into a service
          if webhook_executions.any?
            webhook_executions.collect(&:logs).join("\n")
          else
            "Webhook has not executed yet. Please retry in a few seconds."
          end
        end

        def policy_name
          :'webhooks::webhook'
        end

        def policy_record
          triggered_webhook&.webhook
        end

        private

        def webhook_executions
          @webhook_executions ||= triggered_webhook.webhook_executions
        end

        def triggered_webhook
          @triggered_webhook ||= PactBroker::Webhooks::TriggeredWebhook.find(uuid: identifier_from_path[:uuid])
        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/triggered_webhook_logs.rb
pact_broker-2.105.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.104.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.103.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.102.2 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.102.1 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.102.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.101.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.100.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.99.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.98.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.97.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.96.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.95.1 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.95.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.94.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.93.4 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.93.3 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.93.2 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.93.1 lib/pact_broker/api/resources/triggered_webhook_logs.rb