Sha256: 2ca7e777a041b410072e37175fdf4a25ae504f38f267f817411a846723405ee3
Contents?: true
Size: 1.6 KB
Versions: 3
Compression:
Stored size: 1.6 KB
Contents
require_relative 'base_api' require_relative 'representors' module PactBroker module Api class PacticipantApi < BaseApi get "/pacticipants" do pacticipants = pacticipant_service.find_all_pacticipants pacticipants.extend(Representors::PacticipantCollectionRepresenter) content_type 'application/json+hal;charset=utf-8' pacticipants.to_json end namespace '/pacticipants' do get '/:name' do pacticipant = pacticipant_service.find_pacticipant_by_name(params[:name]) if pacticipant pacticipant.extend(Representors::PacticipantRepresenter) content_type 'application/json+hal;charset=utf-8' pacticipant.to_json else status 404 end end get '/:name/repository_url' do repository_url = pacticipant_service.find_pacticipant_repository_url_by_pacticipant_name(params[:name]) if repository_url content_type 'text/plain' repository_url else status 404 end end patch '/:name' do logger.info "Recieved request to patch #{params[:name]} with #{params}" pacticipant, created = pacticipant_service.create_or_update_pacticipant( name: params[:name], repository_url: params[:repository_url] ) created ? status(201) : status(200) pacticipant.extend(Representors::PacticipantRepresenter) content_type 'application/json+hal;charset=utf-8' pacticipant.to_json end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pact_broker-0.0.4 | lib/pact_broker/api/pacticipant_api.rb |
pact_broker-0.0.3 | lib/pact_broker/api/pacticipant_api.rb |
pact_broker-0.0.2 | lib/pact_broker/api/pacticipant_api.rb |