<commit_before>require_relative 'base_api'

module PactBroker

  module Api

    class PactApi < BaseApi

      namespace '/pacticipants/:consumer/versions/:number/pacts' do
        put '/:provider' do
          pact, created = pact_service.create_or_update_pact(
            provider: params[:provider],
            consumer: params[:consumer],
            number: params[:number],
            json_content: request.body.read)
          created ? status(201) : status(200)
        end

        get '/:provider' do
          pact = nil<commit_msg>Changing to new /pacts/latest URL format<commit_after>require_relative 'base_api'

module PactBroker

  module Api

    class PactApi < BaseApi

      namespace '/pacts' do
        get '/latest' do
          param :consumer, String
          param :provider, String

          pact = nil
          pact = pact_service.find_pact(consumer: params[:consumer], provider: params[:provider], number: 'last')
          if pact
            status 200
            headers 'X-Pact-Consumer-Version' => pact.consumer_version_number
            json pact
          else
            status 404
          end

        end
      end

      namespace '/pacticipants/:consumer/versions/:number/pacts' do
        put '/:provider' do
          pact, created = pact_service.create_or_update_pact(
            provider: params[:provider],
            consumer: params[:consumer],
            number: params[:number],
            json_content: request.body.read)
          created ? status(201) : status(200)
        end

        get '/:provider' do
          pact = nil
{'fraction_non_alphanumeric': 0.090282131661442, 'fraction_numerical': 0.01128526645768025, 'mean_word_length': 1.9610389610389611, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5808156', 'n_tokens_mistral': 463, 'n_tokens_neox': 427, 'n_words': 110}