Sha256: 9b64131744fcd3d6c4a2231d81634f069383a15f7798d37d3268ab182b6b1ba2

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 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
      attr_reader :attributes

      def initialize attributes = {}
        @attributes = attributes
        @uuid = attributes[:uuid]
        @request = attributes[:request]
        @consumer = attributes[:consumer]
        @provider = attributes[:provider]
        @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 options
        logger.info "Executing #{self}"
        request.execute 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

8 entries across 8 versions & 1 rubygems

Version Path
pact_broker-2.8.0.beta.5 lib/pact_broker/domain/webhook.rb
pact_broker-2.8.0.beta.4 lib/pact_broker/domain/webhook.rb
pact_broker-2.7.0.beta.3 lib/pact_broker/domain/webhook.rb
pact_broker-2.7.0.beta.2 lib/pact_broker/domain/webhook.rb
pact_broker-2.7.0.beta.1 lib/pact_broker/domain/webhook.rb
pact_broker-2.6.0 lib/pact_broker/domain/webhook.rb
pact_broker-2.5.1 lib/pact_broker/domain/webhook.rb
pact_broker-2.5.0 lib/pact_broker/domain/webhook.rb