class PactBroker::Client::Versions::Describe

def self.call params, options, pact_broker_base_url, pact_broker_client_options

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 call

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

def format_version(version_hash)

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

def initialize params, options, pact_broker_base_url, pact_broker_client_options

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 pact_broker_client

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

def versions_client

def versions_client
  pact_broker_client.pacticipants.versions
end