Sha256: 5f25b47ea7e96ccdc65a7b11a8f1f19a5d244c4e707d938aec5819e3ee5a3fd2

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

module PactBroker
  module Api
    module PactBrokerUrls

      def pacticipants_url base_url
        "#{base_url}/pacticipants"
      end

      def pacticipant_url base_url, pacticipant
        "#{pacticipants_url(base_url)}/#{url_encode(pacticipant.name)}"
      end

      def latest_version_url base_url, pacticipant
        "#{pacticipant_url(base_url, pacticipant)}/versions/latest"
      end

      def versions_url base_url, pacticipant
        "#{pacticipant_url(base_url, pacticipant)}/versions"
      end

      def version_url base_url, version
        "#{pacticipant_url(base_url, version.pacticipant)}/versions/#{version.number}"
      end

      def pact_url base_url, pact
        representable_pact = representable_pact(pact)
        "#{pactigration_base_url(base_url, representable_pact)}/version/#{representable_pact.consumer.version.number}"
      end

      def latest_pact_url base_url, pact
        "#{pactigration_base_url(base_url, pact)}/latest"
      end

      def latest_pacts_url base_url
        "#{base_url}/pacts/latest"
      end

      def tags_url base_url, version
        "#{version_url(base_url, version)}/tags"
      end

      def tag_url base_url, tag
        "#{tags_url(base_url, tag.version)}/#{tag.name}"
      end

      private

      def representable_pact pact
        Decorators::RepresentablePact === pact ? pact : Decorators::RepresentablePact.new(pact)
      end

      def pactigration_base_url base_url, pact
        "#{base_url}/pact/provider/#{url_encode(pact.provider.name)}/consumer/#{url_encode(pact.consumer.name)}"
      end

      def url_encode param
        ERB::Util.url_encode param
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact_broker-1.0.0.alpha1 lib/pact_broker/api/pact_broker_urls.rb
pact_broker-0.0.10 lib/pact_broker/api/pact_broker_urls.rb