Sha256: ce21957f18afa5fd9600169ba696bd035959dd502d822773b3dc9c62ad75ca8c

Contents?: true

Size: 1.03 KB

Versions: 26

Compression:

Stored size: 1.03 KB

Contents

require 'pact_broker/api/resources/base_resource'
require 'pact_broker/configuration'

module PactBroker
  module Api
    module Resources

      class LatestPact < BaseResource

        def content_types_provided
          [ ["application/hal+json", :to_json],
            ["application/json", :to_json],
            ["text/html", :to_html]]
        end

        def allowed_methods
          ["GET", "OPTIONS"]
        end

        def resource_exists?
          pact
        end

        def to_json
          response.headers['X-Pact-Consumer-Version'] = pact.consumer_version_number
          PactBroker::Api::Decorators::PactDecorator.new(pact).to_json(user_options: { base_url: base_url })
        end

        def to_html
          PactBroker.configuration.html_pact_renderer.call(
            pact, {
              base_url: base_url,
              badge_url: "#{resource_url}/badge.svg"
          })
        end

        def pact
          @pact ||= pact_service.find_latest_pact(identifier_from_path)
        end

      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
pact_broker-2.38.1 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.38.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.37.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.36.1 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.36.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.35.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.34.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.33.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.32.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.31.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.30.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.29.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.27.6 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.27.5 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.27.4 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.27.3 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.27.2 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.27.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.26.1 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.26.0 lib/pact_broker/api/resources/latest_pact.rb