Sha256: 9116e07fbcedabdebbefe1a8458fed0bed8ef430c17b9c3a42ae151415a34cf7

Contents?: true

Size: 1.86 KB

Versions: 45

Compression:

Stored size: 1.86 KB

Contents

# Need Versions class to extend BaseClient until we can remove the old Versions code
require 'pact_broker/client/base_client'
require 'pact_broker/client/pact_broker_client'
require 'pact_broker/client/versions/formatter'

module PactBroker
  module Client
    class Versions < BaseClient
      class Describe

        class Result
          attr_reader :success, :message

          def initialize success, message = nil
            @success = success
            @message = message
          end
        end

        def self.call params, options, pact_broker_base_url, pact_broker_client_options
          new(params, options, pact_broker_base_url, pact_broker_client_options).call
        end

        def initialize params, options, pact_broker_base_url, pact_broker_client_options
          @params = params
          @options = options
          @pact_broker_base_url = pact_broker_base_url
          @pact_broker_client_options = pact_broker_client_options
        end

        def call
          version_hash = if params[:version]
            versions_client.find(params)
          else
            pact_broker_client.pacticipants.versions.latest(params)
          end
          if version_hash
            Result.new(true, format_version(version_hash))
          else
            Result.new(false, "Pacticipant version not found")
          end
        end

        private

        def format_version(version_hash)
          Formatter.call(version_hash, options[:output])
        end

        attr_reader :params, :options, :pact_broker_base_url, :pact_broker_client_options

        def versions_client
          pact_broker_client.pacticipants.versions
        end

        def pact_broker_client
          @pact_broker_client ||= PactBroker::Client::PactBrokerClient.new(base_url: pact_broker_base_url, client_options: pact_broker_client_options)
        end
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
pact_broker-client-1.77.0 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.76.2 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.76.1 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.76.0 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.75.4 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.75.3 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.75.1 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.75.0 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.74.0 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.73.0 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.72.0 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.71.0 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.70.0 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.69.0 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.68.0 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.67.0 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.66.1 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.66.0 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.65.0 lib/pact_broker/client/versions/describe.rb
pact_broker-client-1.64.0 lib/pact_broker/client/versions/describe.rb