Sha256: 586bd9b465f4ea60374ad6e799e731a2d56acf5a73f1f3e90dd312181a5388c3

Contents?: true

Size: 1.03 KB

Versions: 1

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])
        "/pacticipant/#{pacticipant}/versions"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact_broker-client-0.0.1 lib/pact_broker/client/versions.rb