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.93.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.92.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.91.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.90.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.89.1 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.89.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.88.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.87.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.86.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.85.1 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.85.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.84.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.83.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.82.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.81.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.80.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb