Sha256: 83b66b8214af98c7a6abf56267b289208004a3557e1a70ae6ed58acc17a8a097

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

require_relative 'base_decorator'
require 'pact_broker/api/decorators/webhook_request_decorator'
require 'pact_broker/models/webhook_request'
require 'pact_broker/api/decorators/basic_pacticipant_decorator'

module PactBroker
  module Api
    module Decorators
      class WebhookDecorator < BaseDecorator

        property :request, :class => PactBroker::Models::WebhookRequest, :extend => WebhookRequestDecorator

        property :createdAt, getter: lambda { |_| created_at.xmlschema }, writeable: false
        property :updatedAt, getter: lambda { |_| updated_at.xmlschema }, writeable: false

        property :consumer, :extend => PactBroker::Api::Decorators::BasicPacticipantRepresenter, :embedded => true, writeable: false
        property :provider, :extend => PactBroker::Api::Decorators::BasicPacticipantRepresenter, :embedded => true, writeable: false

        link :self do | options |
          {
            title: represented.description,
            href: webhook_url(represented.uuid, options[:base_url])
          }

        end

        link :'pact-webhooks' do | options |
          {
            title: "All webhooks for the pact between #{represented.consumer.name} and #{represented.provider.name}",
            href: webhooks_for_pact_url(represented.consumer, represented.provider, options[:base_url])
          }
        end

        link :'webhooks' do | options |
          {
            title: "All webhooks",
            href: webhooks_url(options[:base_url])
          }
        end

        link :execute do | options |
          {
            title: "Test the execution of the webhook by sending a POST request to this URL",
            href: webhook_execution_url(represented, options[:base_url])
          }

        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact_broker-1.2.0 lib/pact_broker/api/decorators/webhook_decorator.rb