Sha256: cf92c678e5c09948b667f5be2b1c7f4ebad8eda41eee5d88d8711d21025419a4

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require 'pact_broker/client/hal'
require 'pact_broker/client/retry'

module PactBroker
  module Client
    module HalClientMethods
      def create_index_entry_point(pact_broker_base_url, pact_broker_client_options)
        PactBroker::Client::Hal::EntryPoint.new(pact_broker_base_url, create_http_client(pact_broker_client_options))
      end

      def create_http_client(pact_broker_client_options)
        PactBroker::Client::Hal::HttpClient.new(pact_broker_client_options.merge(pact_broker_client_options[:basic_auth] || {}))
      end

      def index_entry_point
        @index_entry_point ||= create_index_entry_point(pact_broker_base_url, pact_broker_client_options)
      end

      def index_resource
        @index_resource ||= Retry.while_error do
          index_entry_point.get!
        end
      end

      def is_pactflow?
        index_resource.response.headers.keys.any?{ | header_name | header_name.downcase.include?("pactflow") }
      end

      def pact_broker_name
        is_pactflow? ? "Pactflow" : "the Pact Broker"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pact_broker-client-1.41.0 lib/pact_broker/client/hal_client_methods.rb
pact_broker-client-1.40.0 lib/pact_broker/client/hal_client_methods.rb
pact_broker-client-1.39.0 lib/pact_broker/client/hal_client_methods.rb