Class: PactBroker::Domain::Webhook

Inherits:
Object
  • Object
show all
Includes:
Logging, Messages
Defined in:
lib/pact_broker/domain/webhook.rb

Constant Summary

Constants included from Logging

Logging::LOG_DIR, Logging::LOG_FILE_NAME

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, #log_error, #logger, #logger=

Methods included from Messages

#message, #potential_duplicate_pacticipant_message, #validation_message

Constructor Details

#initialize(attributes = {}) ⇒ Webhook

Returns a new instance of Webhook.



18
19
20
21
22
23
24
25
26
# File 'lib/pact_broker/domain/webhook.rb', line 18

def initialize attributes = {}
  @attributes = attributes
  @uuid = attributes[:uuid]
  @request = attributes[:request]
  @consumer = attributes[:consumer]
  @provider = attributes[:provider]
  @created_at = attributes[:created_at]
  @updated_at = attributes[:updated_at]
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



16
17
18
# File 'lib/pact_broker/domain/webhook.rb', line 16

def attributes
  @attributes
end

#consumerObject

Returns the value of attribute consumer.



15
16
17
# File 'lib/pact_broker/domain/webhook.rb', line 15

def consumer
  @consumer
end

#created_atObject

Returns the value of attribute created_at.



15
16
17
# File 'lib/pact_broker/domain/webhook.rb', line 15

def created_at
  @created_at
end

#providerObject

Returns the value of attribute provider.



15
16
17
# File 'lib/pact_broker/domain/webhook.rb', line 15

def provider
  @provider
end

#requestObject

Returns the value of attribute request.



15
16
17
# File 'lib/pact_broker/domain/webhook.rb', line 15

def request
  @request
end

#updated_atObject

Returns the value of attribute updated_at.



15
16
17
# File 'lib/pact_broker/domain/webhook.rb', line 15

def updated_at
  @updated_at
end

#uuidObject

Returns the value of attribute uuid.



15
16
17
# File 'lib/pact_broker/domain/webhook.rb', line 15

def uuid
  @uuid
end

Instance Method Details

#consumer_nameObject



45
46
47
# File 'lib/pact_broker/domain/webhook.rb', line 45

def consumer_name
  consumer && consumer.name
end

#descriptionObject



28
29
30
# File 'lib/pact_broker/domain/webhook.rb', line 28

def description
  "A webhook for the pact between #{consumer.name} and #{provider.name}"
end

#executeObject



36
37
38
39
# File 'lib/pact_broker/domain/webhook.rb', line 36

def execute
  logger.info "Executing #{self}"
  request.execute
end

#provider_nameObject



49
50
51
# File 'lib/pact_broker/domain/webhook.rb', line 49

def provider_name
  provider && provider.name
end

#request_descriptionObject



32
33
34
# File 'lib/pact_broker/domain/webhook.rb', line 32

def request_description
  request && request.description
end

#to_sObject



41
42
43
# File 'lib/pact_broker/domain/webhook.rb', line 41

def to_s
  "webhook for consumer=#{consumer_name} provider=#{provider_name} uuid=#{uuid} request=#{request}"
end