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


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

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

#issues(repo) ⇒ Object


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

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

#pull_request_comments(repo, pull_request) ⇒ Object


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

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


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

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

#pull_requests(repo) ⇒ Object


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

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

#repo(name) ⇒ Object


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

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

#repos(filter: nil) ⇒ Object


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

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

  get_collection(path, :repo)
end

#userObject


48
49
50
51
52
53
# File 'lib/bitbucket/client.rb', line 48

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