class PactBroker::Client::Environments::EnvironmentCommand

Constants

NOT_SUPPORTED_MESSAGE
PACTFLOW_NOT_SUPPORTED_MESSAGE

Private Instance Methods

check_if_command_supported() click to toggle source
# File lib/pact_broker/client/environments/environment_command.rb, line 62
def check_if_command_supported
  unless index_resource.can?("pb:environments")
    if is_pactflow?
      raise PactBroker::Client::Error.new(PACTFLOW_NOT_SUPPORTED_MESSAGE)
    else
      raise PactBroker::Client::Error.new(NOT_SUPPORTED_MESSAGE)
    end
  end
end
contacts() click to toggle source
# File lib/pact_broker/client/environments/environment_command.rb, line 49
def contacts
  if params[:contact_name] || params[:contact_email_address]
    contact = {}
    contact["name"] = params[:contact_name] || "unknown"
    if params[:contact_email_address]
      contact["details"] = { "emailAddress" => params[:contact_email_address] }
    end
    [contact]
  else
    nil
  end
end
existing_environment_body() click to toggle source
# File lib/pact_broker/client/environments/environment_command.rb, line 42
def existing_environment_body
  @existing_environment_params ||= existing_environment_resource!
    .response
    .body
    .except("uuid", "_links", "_embedded", "createdAt", "updatedAt")
end
existing_environment_resource() click to toggle source
# File lib/pact_broker/client/environments/environment_command.rb, line 34
def existing_environment_resource
  @existing_environment_resource ||= existing_environment_link.get
end
existing_environment_resource!() click to toggle source
# File lib/pact_broker/client/environments/environment_command.rb, line 38
def existing_environment_resource!
  existing_environment_resource.assert_success!
end
new_environment_body() click to toggle source
# File lib/pact_broker/client/environments/environment_command.rb, line 15
def new_environment_body
  {
    "name" => params[:name],
    "displayName" => params[:display_name],
    "production" => params[:production],
    "contacts" => contacts
  }.compact
end