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.



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

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.



15
16
17
# File 'lib/pact_broker/client/webhooks/create.rb', line 15

def basic_auth_options
  @basic_auth_options
end

#pact_broker_base_urlObject (readonly)

Returns the value of attribute pact_broker_base_url.



15
16
17
# File 'lib/pact_broker/client/webhooks/create.rb', line 15

def pact_broker_base_url
  @pact_broker_base_url
end

#paramsObject (readonly)

Returns the value of attribute params.



15
16
17
# File 'lib/pact_broker/client/webhooks/create.rb', line 15

def params
  @params
end

#verboseObject (readonly)

Returns the value of attribute verbose.



15
16
17
# File 'lib/pact_broker/client/webhooks/create.rb', line 15

def verbose
  @verbose
end

Class Method Details

.call(params, pact_broker_base_url, pact_broker_client_options) ⇒ Object



17
18
19
# File 'lib/pact_broker/client/webhooks/create.rb', line 17

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



27
28
29
30
31
32
33
# File 'lib/pact_broker/client/webhooks/create.rb', line 27

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