Sha256: 2bdaf7aa347dc2e6d7fcf3cf45c7be591de83b216dd5cd7ad245ee8f8825d897

Contents?: true

Size: 1.21 KB

Versions: 19

Compression:

Stored size: 1.21 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

      def initialize 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

      #TODO retries
      def execute
        logger.info "Executing #{self}"
        request.execute
      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

19 entries across 19 versions & 1 rubygems

Version Path
pact_broker-1.14.0 lib/pact_broker/domain/webhook.rb
pact_broker-1.13.0 lib/pact_broker/domain/webhook.rb
pact_broker-1.12.0 lib/pact_broker/domain/webhook.rb
pact_broker-1.11.2 lib/pact_broker/domain/webhook.rb
pact_broker-1.11.1 lib/pact_broker/domain/webhook.rb
pact_broker-1.11.0 lib/pact_broker/domain/webhook.rb
pact_broker-1.10.0 lib/pact_broker/domain/webhook.rb
pact_broker-1.9.3 lib/pact_broker/domain/webhook.rb
pact_broker-1.9.2 lib/pact_broker/domain/webhook.rb
pact_broker-1.9.1 lib/pact_broker/domain/webhook.rb
pact_broker-1.9.0 lib/pact_broker/domain/webhook.rb
pact_broker-1.9.0.rc1 lib/pact_broker/domain/webhook.rb
pact_broker-1.8.1 lib/pact_broker/domain/webhook.rb
pact_broker-1.8.0 lib/pact_broker/domain/webhook.rb
pact_broker-1.7.0 lib/pact_broker/domain/webhook.rb
pact_broker-1.6.0 lib/pact_broker/domain/webhook.rb
pact_broker-1.5.0 lib/pact_broker/domain/webhook.rb
pact_broker-1.4.0 lib/pact_broker/domain/webhook.rb
pact_broker-1.3.2.rc1 lib/pact_broker/domain/webhook.rb