Sha256: 7c53764422a3a4d17d0326e3820adfc86ed2456423ee5947b8c68bf78d6dca78

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 KB

Contents

require 'pact_broker/api/resources/base_resource'
require 'pact_broker/configuration'
require 'pact_broker/api/decorators/versions_decorator'

module PactBroker
  module Api
    module Resources
      class Versions < BaseResource
        def content_types_provided
          [["application/hal+json", :to_json]]
        end

        def allowed_methods
          ["GET", "OPTIONS"]
        end

        def resource_exists?
          !!pacticipant
        end

        def to_json
          decorator_class(:versions_decorator).new(versions).to_json(decorator_options(identifier_from_path))
        end

        def versions
          @versions ||= pacticipant_service.find_all_pacticipant_versions_in_reverse_order(pacticipant_name, pagination_options)
        end

        def policy_name
          :'versions::versions'
        end

        def pagination_options
          if request.query['pageNumber'] || request.query['pageSize']
            {
              page_number: request.query['pageNumber']&.to_i || 1,
              page_size: request.query['pageSize']&.to_i || 100
            }
          else
            nil
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pact_broker-2.79.1 lib/pact_broker/api/resources/versions.rb
pact_broker-2.79.0 lib/pact_broker/api/resources/versions.rb
pact_broker-2.78.1 lib/pact_broker/api/resources/versions.rb
pact_broker-2.78.0 lib/pact_broker/api/resources/versions.rb
pact_broker-2.77.0 lib/pact_broker/api/resources/versions.rb
pact_broker-2.76.2 lib/pact_broker/api/resources/versions.rb
pact_broker-2.76.1 lib/pact_broker/api/resources/versions.rb
pact_broker-2.76.0 lib/pact_broker/api/resources/versions.rb
pact_broker-2.75.0 lib/pact_broker/api/resources/versions.rb