gitlab-org--gitlab-foss/lib/bitbucket_server/client.rb

38 lines
1006 B
Ruby
Raw Normal View History

module BitbucketServer
class Client
attr_reader :connection
def initialize(options = {})
@connection = Connection.new(options)
end
2018-06-26 06:13:32 +00:00
def pull_requests(project_key, repo)
path = "/projects/#{project_key}/repos/#{repo}/pull-requests?state=ALL"
get_collection(path, :pull_request)
end
def activities(project_key, repo, pull_request)
path = "/projects/#{project_key}/repos/#{repo}/pull-requests/#{pull_request}/activities"
2018-06-29 05:26:33 +00:00
get_collection(path, :activity)
end
def repo(project, repo_name)
parsed_response = connection.get("/projects/#{project}/repos/#{repo_name}")
# XXXX TODO Handle failure
BitbucketServer::Representation::Repo.new(parsed_response)
end
def repos
path = "/repos"
get_collection(path, :repo)
end
private
def get_collection(path, type)
paginator = BitbucketServer::Paginator.new(connection, path, type)
BitbucketServer::Collection.new(paginator)
end
end
end