Class: PactBroker::Client::Versions
- Inherits:
-
BaseClient
- Object
- BaseClient
- PactBroker::Client::Versions
- Defined in:
- lib/pact_broker/client/versions.rb,
lib/pact_broker/client/versions/describe.rb,
lib/pact_broker/client/versions/formatter.rb,
lib/pact_broker/client/versions/json_formatter.rb,
lib/pact_broker/client/versions/text_formatter.rb,
lib/pact_broker/client/versions/record_deployment.rb,
lib/pact_broker/client/versions/record_undeployment.rb
Defined Under Namespace
Classes: Describe, Formatter, JsonFormatter, RecordDeployment, RecordUndeployment, TextFormatter
Constant Summary
Constants inherited from BaseClient
BaseClient::ERROR_CODE_MAPPING
Instance Attribute Summary
Attributes inherited from BaseClient
Instance Method Summary collapse
- #find(options) ⇒ Object
- #latest(options) ⇒ Object
- #pacts ⇒ Object
- #tag(options) ⇒ Object
- #update(options) ⇒ Object
Methods inherited from BaseClient
#default_get_headers, #default_patch_headers, #default_put_headers, #default_request_headers, #get, #handle_response, #initialize, #patch, #put, #url_for_relation, #verbose?
Methods included from StringToSymbol
Methods included from UrlHelpers
#encode_param, #encode_query_param
Constructor Details
This class inherits a constructor from PactBroker::Client::BaseClient
Instance Method Details
#find(options) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/pact_broker/client/versions.rb', line 8 def find response = get("#{version_base_url()}", headers: default_get_headers) handle_response(response) do JSON.parse(response.body, symbolize_names: true) end end |
#latest(options) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pact_broker/client/versions.rb', line 16 def latest url = if [:tag] url_for_relation('pb:latest-tagged-version', pacticipant: .fetch(:pacticipant), tag: .fetch(:tag)) else url_for_relation('pb:latest-version', pacticipant: .fetch(:pacticipant)) end handle_response(get(url, headers: default_get_headers)) do | response | JSON.parse(response.body, symbolize_names: true) end end |
#pacts ⇒ Object
44 45 46 |
# File 'lib/pact_broker/client/versions.rb', line 44 def pacts Pacts.new base_url: base_url, client_options: end |
#tag(options) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/pact_broker/client/versions.rb', line 27 def tag response = put(tag_url(), headers: default_put_headers.merge("Content-Length" => "0")) handle_response(response) do true end end |
#update(options) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/pact_broker/client/versions.rb', line 34 def update body = .select{ | key, v | [:repository_ref, :repository_url, :tags].include?(key)} body[:tags] ||= [] (body[:tags] << [:tag]) if [:tag] response = patch("#{version_base_url()}", body: body, headers: default_patch_headers) handle_response(response) do true end end |