Class: PactBroker::Client::Webhooks::Create

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/client/webhooks/create.rb

Constant Summary collapse

WEBHOOKS_WITH_OPTIONAL_PACTICICPANTS_NOT_SUPPORTED =
"This version of the Pact Broker requires that both consumer and provider are specified for a webhook. Please upgrade your broker to >= 2.22.0 to create a webhook with optional consumer and provider."
CREATING_WEBHOOK_WITH_UUID_NOT_SUPPORTED =
"This version of the Pact Broker does not support creating webhooks with a specified UUID. Please upgrade your broker to >= 2.49.0 or use the create-webhook command."

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, pact_broker_base_url, pact_broker_client_options) ⇒ Create

Returns a new instance of Create.



25
26
27
28
29
# File 'lib/pact_broker/client/webhooks/create.rb', line 25

def initialize(params, pact_broker_base_url, pact_broker_client_options)
  @params = OpenStruct.new(params)
  @pact_broker_base_url = pact_broker_base_url
  @http_client = PactBroker::Client::Hal::HttpClient.new(pact_broker_client_options.merge(pact_broker_client_options[:basic_auth] || {}))
end

Instance Attribute Details

#basic_auth_optionsObject (readonly)

Returns the value of attribute basic_auth_options.



19
20
21
# File 'lib/pact_broker/client/webhooks/create.rb', line 19

def basic_auth_options
  @basic_auth_options
end

#pact_broker_base_urlObject (readonly)

Returns the value of attribute pact_broker_base_url.



19
20
21
# File 'lib/pact_broker/client/webhooks/create.rb', line 19

def pact_broker_base_url
  @pact_broker_base_url
end

#paramsObject (readonly)

Returns the value of attribute params.



19
20
21
# File 'lib/pact_broker/client/webhooks/create.rb', line 19

def params
  @params
end

#verboseObject (readonly)

Returns the value of attribute verbose.



19
20
21
# File 'lib/pact_broker/client/webhooks/create.rb', line 19

def verbose
  @verbose
end

Class Method Details

.call(params, pact_broker_base_url, pact_broker_client_options) ⇒ Object



21
22
23
# File 'lib/pact_broker/client/webhooks/create.rb', line 21

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

Instance Method Details

#callObject



31
32
33
34
35
36
37
# File 'lib/pact_broker/client/webhooks/create.rb', line 31

def call
  if params.consumer && params.provider && !params.uuid
    create_webhook_with_consumer_and_provider
  else
    create_webhook_with_optional_consumer_and_provider
  end
end