Class: PactBroker::Client::Pacticipants2::Create
- Inherits:
-
Object
- Object
- PactBroker::Client::Pacticipants2::Create
- Includes:
- HalClientMethods
- Defined in:
- lib/pact_broker/client/pacticipants/create.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(params, pact_broker_base_url, pact_broker_client_options) ⇒ Create
constructor
A new instance of Create.
Methods included from HalClientMethods
#create_http_client, #create_index_entry_point, #index_resource, #is_pactflow?, #pact_broker_name
Constructor Details
#initialize(params, pact_broker_base_url, pact_broker_client_options) ⇒ Create
Returns a new instance of Create.
17 18 19 20 21 |
# File 'lib/pact_broker/client/pacticipants/create.rb', line 17 def initialize(params, pact_broker_base_url, ) @params = params @index_entry_point = create_index_entry_point(pact_broker_base_url, ) @verbose = [:verbose] end |
Class Method Details
.call(params, pact_broker_base_url, pact_broker_client_options) ⇒ Object
13 14 15 |
# File 'lib/pact_broker/client/pacticipants/create.rb', line 13 def self.call(params, pact_broker_base_url, ) new(params, pact_broker_base_url, ).call end |
Instance Method Details
#call ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pact_broker/client/pacticipants/create.rb', line 23 def call pacticipant_entity = index_entity._link('pb:pacticipant').('pacticipant' => params[:name]).get = nil response_entity = if pacticipant_entity.does_not_exist? = "Pacticipant \"#{params[:name]}\" created" index_entity._link!('pb:pacticipants').post(pacticipant_resource_params) else = "Pacticipant \"#{params[:name]}\" updated" pacticipant_entity._link!('self').patch(pacticipant_resource_params) end response_entity.assert_success! PactBroker::Client::CommandResult.new(true, ) rescue StandardError => e $stderr.puts("#{e.class} - #{e}\n#{e.backtrace.join("\n")}") if verbose PactBroker::Client::CommandResult.new(false, "#{e.class} - #{e}") end |