diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-08-22 15:45:29 -0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-11-21 16:47:25 -0800 |
commit | f1f5863bfc5727dba4767a54a299b0cf526b025a (patch) | |
tree | d13a022d4fdd3a102bc447b072f74d1c3409f7fc /lib/bitbucket | |
parent | fc34c9560324b7db5bdaf205cbdf46a339102af2 (diff) | |
download | gitlab-ce-f1f5863bfc5727dba4767a54a299b0cf526b025a.tar.gz |
Add an endpoint to get the Bitbucket user profile
Diffstat (limited to 'lib/bitbucket')
-rw-r--r-- | lib/bitbucket/client.rb | 5 | ||||
-rw-r--r-- | lib/bitbucket/representation/base.rb | 13 | ||||
-rw-r--r-- | lib/bitbucket/representation/user.rb | 9 |
3 files changed, 27 insertions, 0 deletions
diff --git a/lib/bitbucket/client.rb b/lib/bitbucket/client.rb index 5f48e52da98..c05fc35f36e 100644 --- a/lib/bitbucket/client.rb +++ b/lib/bitbucket/client.rb @@ -4,6 +4,11 @@ module Bitbucket @connection = options.fetch(:connection, Connection.new(options)) end + def user + parsed_response = connection.get('/user') + Representation::User.new(parsed_response) + end + private attr_reader :connection diff --git a/lib/bitbucket/representation/base.rb b/lib/bitbucket/representation/base.rb new file mode 100644 index 00000000000..7b639492d38 --- /dev/null +++ b/lib/bitbucket/representation/base.rb @@ -0,0 +1,13 @@ +module Bitbucket + module Representation + class Base + def initialize(raw) + @raw = raw + end + + private + + attr_reader :raw + end + end +end diff --git a/lib/bitbucket/representation/user.rb b/lib/bitbucket/representation/user.rb new file mode 100644 index 00000000000..ba6b7667b49 --- /dev/null +++ b/lib/bitbucket/representation/user.rb @@ -0,0 +1,9 @@ +module Bitbucket + module Representation + class User < Representation::Base + def username + raw['username'] + end + end + end +end |