Class: Bitbucket::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bitbucket/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



7
8
9
# File 'lib/bitbucket/client.rb', line 7

def initialize(options = {})
  @connection = Connection.new(options)
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



5
6
7
# File 'lib/bitbucket/client.rb', line 5

def connection
  @connection
end

Instance Method Details

#issue_comments(repo, issue_id) ⇒ Object



21
22
23
24
# File 'lib/bitbucket/client.rb', line 21

def issue_comments(repo, issue_id)
  path = "/repositories/#{repo}/issues/#{issue_id}/comments"
  get_collection(path, :comment)
end

#issues(repo) ⇒ Object



16
17
18
19
# File 'lib/bitbucket/client.rb', line 16

def issues(repo)
  path = "/repositories/#{repo}/issues"
  get_collection(path, :issue)
end

#last_issue(repo) ⇒ Object



11
12
13
14
# File 'lib/bitbucket/client.rb', line 11

def last_issue(repo)
  parsed_response = connection.get("/repositories/#{repo}/issues?pagelen=1&sort=-created_on&state=ALL")
  Bitbucket::Representation::Issue.new(parsed_response['values'].first)
end

#pull_request_comments(repo, pull_request) ⇒ Object



31
32
33
34
# File 'lib/bitbucket/client.rb', line 31

def pull_request_comments(repo, pull_request)
  path = "/repositories/#{repo}/pullrequests/#{pull_request}/comments"
  get_collection(path, :pull_request_comment)
end

#pull_request_diff(repo, pull_request) ⇒ Object



36
37
38
39
# File 'lib/bitbucket/client.rb', line 36

def pull_request_diff(repo, pull_request)
  path = "/repositories/#{repo}/pullrequests/#{pull_request}/diff"
  connection.get(path)
end

#pull_requests(repo) ⇒ Object



26
27
28
29
# File 'lib/bitbucket/client.rb', line 26

def pull_requests(repo)
  path = "/repositories/#{repo}/pullrequests?state=ALL"
  get_collection(path, :pull_request)
end

#repo(name) ⇒ Object



41
42
43
44
# File 'lib/bitbucket/client.rb', line 41

def repo(name)
  parsed_response = connection.get("/repositories/#{name}")
  Representation::Repo.new(parsed_response)
end

#repos(filter: nil) ⇒ Object



46
47
48
49
50
51
# File 'lib/bitbucket/client.rb', line 46

def repos(filter: nil)
  path = "/repositories?role=member"
  path += "&q=name~\"#{filter}\"" if filter

  get_collection(path, :repo)
end

#userObject



53
54
55
56
57
58
# File 'lib/bitbucket/client.rb', line 53

def user
  @user ||= begin
    parsed_response = connection.get('/user')
    Representation::User.new(parsed_response)
  end
end