summaryrefslogtreecommitdiff
path: root/lib/bitbucket/client.rb
blob: 39b52ae25a6ecd7652c8729fcad977f026e133e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Bitbucket
  class Client
    def initialize(options = {})
      @connection = options.fetch(:connection, Connection.new(options))
    end


    def repos
      relative_path = "/repositories/#{user.username}"
      paginator = Paginator.new(connection, relative_path, :repo)

      Collection.new(paginator)
    end

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

    private

    attr_reader :connection
  end
end