Class: PactBroker::Client::Versions

Inherits:
BaseClient show all
Defined in:
lib/pact_broker/client/versions.rb

Instance Attribute Summary

Attributes inherited from BaseClient

#base_url, #client_options

Instance Method Summary collapse

Methods inherited from BaseClient

#default_get_headers, #default_patch_headers, #default_put_headers, #default_request_headers, #get, #handle_response, #initialize, #patch, #put

Methods included from StringToSymbol

#string_keys_to_symbols

Methods included from UrlHelpers

#encode_param

Constructor Details

This class inherits a constructor from PactBroker::Client::BaseClient

Instance Method Details

#latest(options) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/pact_broker/client/versions.rb', line 8

def latest options
  query = options[:tag] ? {tag: options[:tag]} : {}
  response = self.class.get("#{versions_base_url(options)}/latest", query: query, headers: default_get_headers)

  handle_response(response) do
    string_keys_to_symbols(response.to_hash)
  end
end

#pactsObject



34
35
36
# File 'lib/pact_broker/client/versions.rb', line 34

def pacts
  Pacts.new base_url: base_url, client_options: client_options
end

#tag(options) ⇒ Object



17
18
19
20
21
22
# File 'lib/pact_broker/client/versions.rb', line 17

def tag options
  response = put(tag_url(options), headers: default_put_headers.merge("Content-Length" => "0"))
  handle_response(response) do
    true
  end
end

#update(options) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/pact_broker/client/versions.rb', line 24

def update options
  body = options.select{ | key, v | [:repository_ref, :repository_url, :tags].include?(key)}
  body[:tags] ||= []
  (body[:tags] << options[:tag]) if options[:tag]
  response = patch("#{version_base_url(options)}", body: body, headers: default_patch_headers)
  handle_response(response) do
    true
  end
end