Sha256: bb1aafef38aa1b5a8bea212b930a7d48613f70c6c94640565e27576d1f0f222f

Contents?: true

Size: 1.15 KB

Versions: 7

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::triggered_webhook'
        end

        def policy_record
          triggered_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

7 entries across 7 versions & 1 rubygems

Version Path
pact_broker-2.111.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.109.1 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.109.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.108.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.107.1 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.107.0 lib/pact_broker/api/resources/triggered_webhook_logs.rb
pact_broker-2.107.0.beta.1 lib/pact_broker/api/resources/triggered_webhook_logs.rb