2018-06-25 20:06:10 +00:00
|
|
|
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"
|
2018-06-25 20:06:10 +00:00
|
|
|
get_collection(path, :pull_request)
|
|
|
|
end
|
|
|
|
|
2018-06-26 22:59:34 +00:00
|
|
|
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)
|
2018-06-25 20:06:10 +00:00
|
|
|
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
|