77module Pact
88 module PactBroker
99 class FetchPactURIsForVerification
10- attr_reader :provider , :consumer_version_selectors , :provider_version_tags , :broker_base_url , :http_client_options , :http_client
10+ attr_reader :provider , :consumer_version_selectors , :provider_version_tags , :broker_base_url , :http_client_options , :http_client , :options
1111
1212 PACTS_FOR_VERIFICATION_RELATION = 'beta:provider-pacts-for-verification' . freeze
1313 PACTS = 'pacts' . freeze
@@ -16,17 +16,18 @@ class FetchPactURIsForVerification
1616 SELF = 'self' . freeze
1717 EMBEDDED = '_embedded' . freeze
1818
19- def initialize ( provider , consumer_version_selectors , provider_version_tags , broker_base_url , http_client_options )
19+ def initialize ( provider , consumer_version_selectors , provider_version_tags , broker_base_url , http_client_options , options = { } )
2020 @provider = provider
2121 @consumer_version_selectors = consumer_version_selectors || [ ]
2222 @provider_version_tags = provider_version_tags || [ ]
2323 @http_client_options = http_client_options
2424 @broker_base_url = broker_base_url
2525 @http_client = Pact ::Hal ::HttpClient . new ( http_client_options )
26+ @options = options
2627 end
2728
28- def self . call ( provider , consumer_version_selectors , provider_version_tags , broker_base_url , http_client_options )
29- new ( provider , consumer_version_selectors , provider_version_tags , broker_base_url , http_client_options ) . call
29+ def self . call ( provider , consumer_version_selectors , provider_version_tags , broker_base_url , http_client_options , options = { } )
30+ new ( provider , consumer_version_selectors , provider_version_tags , broker_base_url , http_client_options , options ) . call
3031 end
3132
3233 def call
@@ -50,8 +51,7 @@ def pacts_for_verification
5051 pacts_for_verification_entity . response . body [ EMBEDDED ] [ PACTS ] . collect do | pact |
5152 metadata = {
5253 pending : pact [ "verificationProperties" ] [ "pending" ] ,
53- pending_reason : pact [ "verificationProperties" ] [ "pendingReason" ] ,
54- inclusion_reason : pact [ "verificationProperties" ] [ "inclusionReason" ] ,
54+ notices : extract_notices ( pact )
5555 }
5656 Pact ::Provider ::PactURI . new ( pact [ LINKS ] [ SELF ] [ HREF ] , http_client_options , metadata )
5757 end
@@ -61,22 +61,21 @@ def pacts_for_verification_entity
6161 index
6262 . _link ( PACTS_FOR_VERIFICATION_RELATION )
6363 . expand ( provider : provider )
64- . with_query ( query )
65- . get!
64+ . post! ( query )
6665 end
6766
6867 def query
6968 q = { }
70- if consumer_version_selectors . any?
71- q [ "consumer_version_selectors" ] = consumer_version_selectors
72- end
73-
74- if provider_version_tags . any?
75- q [ "provider_version_tags" ] = provider_version_tags
76- end
69+ q [ "includePendingStatus" ] = true if options [ :include_pending_status ]
70+ q [ "consumerVersionSelectors" ] = consumer_version_selectors if consumer_version_selectors . any?
71+ q [ "providerVersionTags" ] = provider_version_tags if provider_version_tags . any?
7772 q
7873 end
7974
75+ def extract_notices ( pact )
76+ ( pact [ "verificationProperties" ] [ "notices" ] || [ ] ) . collect { |notice | notice [ "text" ] } . compact
77+ end
78+
8079 def log_message
8180 latest = consumer_version_selectors . any? ? "" : "latest "
8281 message = "INFO: Fetching #{ latest } pacts for #{ provider } from #{ broker_base_url } "
0 commit comments