Sha256: 26e52ba13a1326c3992bdde2af6c7619b1980be37674488e71cb14989d55aa9a

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require_relative 'base_client'

module PactBroker
  module Client
    class Versions < BaseClient


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

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

      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)}/#{options[:version]}", body: body, headers: default_patch_headers)
        handle_response(response) do
          true
        end
      end

      def pacts
        Pacts.new base_url: base_url
      end

      private
      def version_base_url options
        pacticipant = encode_param(options[:pacticipant])
        "/pacticipants/#{pacticipant}/versions"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact_broker-client-0.0.3 lib/pact_broker/client/versions.rb
pact_broker-client-0.0.2 lib/pact_broker/client/versions.rb