Sha256: 59213b0d4e6f4123e1d270dc42d265a2dd6309a5fb5da8e071616afbe06dfc27

Contents?: true

Size: 1.18 KB

Versions: 11

Compression:

Stored size: 1.18 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
          PactBroker::Api::Decorators::VersionsDecorator.new(versions).to_json(user_options: decorator_context(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

11 entries across 11 versions & 1 rubygems

Version Path
pact_broker-2.74.1 lib/pact_broker/api/resources/versions.rb
pact_broker-2.74.0 lib/pact_broker/api/resources/versions.rb
pact_broker-2.73.0 lib/pact_broker/api/resources/versions.rb
pact_broker-2.72.0 lib/pact_broker/api/resources/versions.rb
pact_broker-2.71.0 lib/pact_broker/api/resources/versions.rb
pact_broker-2.70.0 lib/pact_broker/api/resources/versions.rb
pact_broker-2.69.0 lib/pact_broker/api/resources/versions.rb
pact_broker-2.68.1 lib/pact_broker/api/resources/versions.rb
pact_broker-2.68.0 lib/pact_broker/api/resources/versions.rb
pact_broker-2.67.0 lib/pact_broker/api/resources/versions.rb
pact_broker-2.66.0 lib/pact_broker/api/resources/versions.rb