Sha256: b059036ac3635d03e7093575cee975df71c7bda8490266947ffecdf7da574d64

Contents?: true

Size: 1.32 KB

Versions: 13

Compression:

Stored size: 1.32 KB

Contents

require 'pact_broker/domain/webhook_request'
require 'pact_broker/messages'
require 'pact_broker/logging'
require 'pact_broker/api/contracts/webhook_contract'

module PactBroker
  module Domain
    class Webhook

      include Messages
      include Logging

      attr_accessor :uuid, :consumer, :provider, :request, :created_at, :updated_at, :events
      attr_reader :attributes

      def initialize attributes = {}
        @attributes = attributes
        @uuid = attributes[:uuid]
        @request = attributes[:request]
        @consumer = attributes[:consumer]
        @provider = attributes[:provider]
        @events = attributes[:events]
        @created_at = attributes[:created_at]
        @updated_at = attributes[:updated_at]
      end

      def description
        "A webhook for the pact between #{consumer.name} and #{provider.name}"
      end

      def request_description
        request && request.description
      end

      def execute pact, options
        logger.info "Executing #{self}"
        request.execute pact, options
      end

      def to_s
        "webhook for consumer=#{consumer_name} provider=#{provider_name} uuid=#{uuid} request=#{request}"
      end

      def consumer_name
        consumer && consumer.name
      end

      def provider_name
        provider && provider.name
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pact_broker-2.20.0 lib/pact_broker/domain/webhook.rb
pact_broker-2.19.2 lib/pact_broker/domain/webhook.rb
pact_broker-2.19.1 lib/pact_broker/domain/webhook.rb
pact_broker-2.19.0 lib/pact_broker/domain/webhook.rb
pact_broker-2.18.0 lib/pact_broker/domain/webhook.rb
pact_broker-2.17.1 lib/pact_broker/domain/webhook.rb
pact_broker-2.17.0 lib/pact_broker/domain/webhook.rb
pact_broker-2.16.1 lib/pact_broker/domain/webhook.rb
pact_broker-2.16.0 lib/pact_broker/domain/webhook.rb
pact_broker-2.15.0 lib/pact_broker/domain/webhook.rb
pact_broker-2.14.0 lib/pact_broker/domain/webhook.rb
pact_broker-2.13.1 lib/pact_broker/domain/webhook.rb
pact_broker-2.13.0 lib/pact_broker/domain/webhook.rb