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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.5 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
module Bitbucket
class Client
attr_reader :connection
def initialize(options = {})
@connection = Connection.new(options)
end
def issues(repo)
2016-12-07 04:33:32 -05:00
path = "/repositories/#{repo}/issues"
2016-12-07 08:54:32 -05:00
get_collection(path, :issue)
end
2016-12-07 04:33:32 -05:00
def issue_comments(repo, issue_id)
path = "/repositories/#{repo}/issues/#{issue_id}/comments"
2016-12-07 08:54:32 -05:00
get_collection(path, :comment)
end
def pull_requests(repo)
2016-12-07 04:33:32 -05:00
path = "/repositories/#{repo}/pullrequests?state=ALL"
2016-12-07 08:54:32 -05:00
get_collection(path, :pull_request)
end
2016-11-16 03:13:17 -05:00
def pull_request_comments(repo, pull_request)
2016-12-07 04:33:32 -05:00
path = "/repositories/#{repo}/pullrequests/#{pull_request}/comments"
2016-12-07 08:54:32 -05:00
get_collection(path, :pull_request_comment)
2016-11-16 03:13:17 -05:00
end
def pull_request_diff(repo, pull_request)
2016-12-07 04:33:32 -05:00
path = "/repositories/#{repo}/pullrequests/#{pull_request}/diff"
connection.get(path)
end
def repo(name)
parsed_response = connection.get("/repositories/#{name}")
Representation::Repo.new(parsed_response)
end
def repos(filter: nil)
path = "/repositories?role=member"
path += "&q=name~\"#{filter}\"" if filter
2016-12-07 08:54:32 -05:00
get_collection(path, :repo)
end
def user
@user ||= begin
parsed_response = connection.get('/user')
Representation::User.new(parsed_response)
end
end
private
2016-12-07 08:54:32 -05:00
def get_collection(path, type)
paginator = Paginator.new(connection, path, type)
Collection.new(paginator)
end
end
end