Skip to content

Commit

Permalink
chore: add missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Mar 22, 2024
1 parent 176ea0f commit 3c1a823
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions lib/pact_broker/api/resources/branch_versions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
require "pact_broker/api/resources/base_resource"
require "pact_broker/configuration"
require "pact_broker/api/decorators/versions_decorator"
require "pact_broker/api/resources/pagination_methods"


module PactBroker
module Api
module Resources
class BranchVersions < BaseResource
include PaginationMethods

def content_types_provided
[["application/hal+json", :to_json]]
end

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

def resource_exists?
!!branch
end

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

def versions
@versions ||= version_service.find_pacticipant_versions_in_reverse_order(pacticipant_name, { branch_name: identifier_from_path[:branch_name] }, pagination_options)
end

def policy_name
:'versions::versions'
end

def branch
@branch ||= branch_service.find_branch(**identifier_from_path.slice(:pacticipant_name, :branch_name))
end

def resource_title
"Versions for branch #{branch.name} of #{branch.pacticipant.name}"
end
end
end
end
end

0 comments on commit 3c1a823

Please sign in to comment.