Class: PactBroker::Webhooks::PactAndVerificationParameters

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

Constant Summary collapse

PACT_URL =
'pactbroker.pactUrl'
VERIFICATION_RESULT_URL =
'pactbroker.verificationResultUrl'
CONSUMER_VERSION_NUMBER =
'pactbroker.consumerVersionNumber'
PROVIDER_VERSION_NUMBER =
'pactbroker.providerVersionNumber'
PROVIDER_VERSION_TAGS =
'pactbroker.providerVersionTags'
CONSUMER_VERSION_TAGS =
'pactbroker.consumerVersionTags'
CONSUMER_NAME =
'pactbroker.consumerName'
PROVIDER_NAME =
'pactbroker.providerName'
GITHUB_VERIFICATION_STATUS =
'pactbroker.githubVerificationStatus'
BITBUCKET_VERIFICATION_STATUS =
'pactbroker.bitbucketVerificationStatus'
CONSUMER_LABELS =
'pactbroker.consumerLabels'
PROVIDER_LABELS =
'pactbroker.providerLabels'
ALL =
[
  CONSUMER_NAME,
  PROVIDER_NAME,
  CONSUMER_VERSION_NUMBER,
  PROVIDER_VERSION_NUMBER,
  PROVIDER_VERSION_TAGS,
  CONSUMER_VERSION_TAGS,
  PACT_URL,
  VERIFICATION_RESULT_URL,
  GITHUB_VERIFICATION_STATUS,
  BITBUCKET_VERIFICATION_STATUS,
  CONSUMER_LABELS,
  PROVIDER_LABELS
]

Instance Method Summary collapse

Constructor Details

#initialize(pact, trigger_verification, webhook_context) ⇒ PactAndVerificationParameters

Returns a new instance of PactAndVerificationParameters.



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

def initialize(pact, trigger_verification, webhook_context)
  @pact = pact
  @verification = trigger_verification || (pact && pact.latest_verification)
  @webhook_context = webhook_context
  @base_url = webhook_context.fetch(:base_url)
end

Instance Method Details

#to_hashObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/pact_broker/webhooks/pact_and_verification_parameters.rb', line 39

def to_hash
  @hash ||= {
    PACT_URL => pact ? PactBroker::Api::PactBrokerUrls.(pact, base_url) : "",
    VERIFICATION_RESULT_URL => verification_url,
    CONSUMER_VERSION_NUMBER => consumer_version_number,
    PROVIDER_VERSION_NUMBER => verification ? verification.provider_version_number : "",
    PROVIDER_VERSION_TAGS => provider_version_tags,
    CONSUMER_VERSION_TAGS => consumer_version_tags,
    CONSUMER_NAME => pact ? pact.consumer_name : "",
    PROVIDER_NAME => pact ? pact.provider_name : "",
    GITHUB_VERIFICATION_STATUS => github_verification_status,
    BITBUCKET_VERIFICATION_STATUS => bitbucket_verification_status,
    CONSUMER_LABELS => pacticipant_labels(pact && pact.consumer),
    PROVIDER_LABELS => pacticipant_labels(pact && pact.provider)
  }
end