diff --git a/lib/bitbucket/client.rb b/lib/bitbucket/client.rb index 5f48e52da9858aa3595cf80363ac8f1265a10fb4..c05fc35f36e4e98bbfe533c62e3e1946cd44a0d1 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 0000000000000000000000000000000000000000..7b639492d388b11477bcb4e40219f864bc88a1dc --- /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 0000000000000000000000000000000000000000..ba6b7667b49f8610f3932c3111b35d798219e805 --- /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