Sha256: 19c4fa829a6962e795af7aac485dcf697e2e57dfc55fa191f8b6fe6c13f93e72

Contents?: true

Size: 1.53 KB

Versions: 8

Compression:

Stored size: 1.53 KB

Contents

require_relative "base_decorator"
require "pact_broker/api/pact_broker_urls"
require "pact_broker/pacts/build_verifiable_pact_notices"
require "pact_broker/pacts/metadata"

module PactBroker
  module Api
    module Decorators
      class VerifiablePactDecorator < BaseDecorator
        include PactBroker::Pacts::Metadata

        property :shortDescription, getter: lambda { | represented:, ** | PactBroker::Pacts::VerifiablePactMessages.new(represented, nil).pact_version_short_description }

        nested :verificationProperties do
          include PactBroker::Api::PactBrokerUrls

          property :pending,
            if: ->(options:, **_other) { options.dig(:user_options, :include_pending_status) }
          property :wip,
            if: -> (represented:, **_other) { represented.wip }
          property :notices,
            getter: -> (decorator:, options:, **) { decorator.notices(options[:user_options]) }

          def notices(user_options)
            metadata = represented.wip ? { wip: true } : nil
            pact_url = pact_version_url_with_metadata(represented, metadata, user_options[:base_url])
            PactBroker::Pacts::BuildVerifiablePactNotices.call(represented, pact_url, user_options)
          end
        end

        link :self do | user_options |
          metadata = build_metadata_for_pact_for_verification(represented)
          {
            href: pact_version_url_with_metadata(represented, metadata, user_options[:base_url]),
            name: represented.name
          }
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pact_broker-2.112.0 lib/pact_broker/api/decorators/verifiable_pact_decorator.rb
pact_broker-2.111.0 lib/pact_broker/api/decorators/verifiable_pact_decorator.rb
pact_broker-2.109.1 lib/pact_broker/api/decorators/verifiable_pact_decorator.rb
pact_broker-2.109.0 lib/pact_broker/api/decorators/verifiable_pact_decorator.rb
pact_broker-2.108.0 lib/pact_broker/api/decorators/verifiable_pact_decorator.rb
pact_broker-2.107.1 lib/pact_broker/api/decorators/verifiable_pact_decorator.rb
pact_broker-2.107.0 lib/pact_broker/api/decorators/verifiable_pact_decorator.rb
pact_broker-2.107.0.beta.1 lib/pact_broker/api/decorators/verifiable_pact_decorator.rb