summaryrefslogtreecommitdiff
path: root/lib/bitbucket
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-22 16:10:29 -0300
committerStan Hu <stanhu@gmail.com>2016-11-21 16:47:26 -0800
commit3f59d25d263d1ac9db76cd2d3d4d025fb6d6dff4 (patch)
tree27c0f9437d8f4c257ea49e3e208be1c5d4699c52 /lib/bitbucket
parent3dd15d3f753a5a71522275a37393bfa56d6e3517 (diff)
downloadgitlab-ce-3f59d25d263d1ac9db76cd2d3d4d025fb6d6dff4.tar.gz
Add an endpoint to get a list of issue comments
Diffstat (limited to 'lib/bitbucket')
-rw-r--r--lib/bitbucket/client.rb10
-rw-r--r--lib/bitbucket/representation/comment.rb27
-rw-r--r--lib/bitbucket/representation/url.rb9
3 files changed, 46 insertions, 0 deletions
diff --git a/lib/bitbucket/client.rb b/lib/bitbucket/client.rb
index ac6e91bb526..3d22347603d 100644
--- a/lib/bitbucket/client.rb
+++ b/lib/bitbucket/client.rb
@@ -11,6 +11,16 @@ module Bitbucket
Collection.new(paginator)
end
+ def issue_comments(repo, number)
+ relative_path = "/repositories/#{repo}/issues/#{number}/comments"
+ paginator = Paginator.new(connection, relative_path, :url)
+
+ Collection.new(paginator).map do |comment_url|
+ parsed_response = connection.get(comment_url.to_s)
+ Representation::Comment.new(parsed_response)
+ end
+ end
+
def repo(name)
parsed_response = connection.get("/repositories/#{name}")
diff --git a/lib/bitbucket/representation/comment.rb b/lib/bitbucket/representation/comment.rb
new file mode 100644
index 00000000000..94bc18cbfab
--- /dev/null
+++ b/lib/bitbucket/representation/comment.rb
@@ -0,0 +1,27 @@
+module Bitbucket
+ module Representation
+ class Comment < Representation::Base
+ def author
+ user.fetch('username', 'Anonymous')
+ end
+
+ def note
+ raw.dig('content', 'raw')
+ end
+
+ def created_at
+ raw['created_on']
+ end
+
+ def updated_at
+ raw['updated_on'] || raw['created_on']
+ end
+
+ private
+
+ def user
+ raw.fetch('user', {})
+ end
+ end
+ end
+end
diff --git a/lib/bitbucket/representation/url.rb b/lib/bitbucket/representation/url.rb
new file mode 100644
index 00000000000..24ae1048013
--- /dev/null
+++ b/lib/bitbucket/representation/url.rb
@@ -0,0 +1,9 @@
+module Bitbucket
+ module Representation
+ class Url < Representation::Base
+ def to_s
+ raw.dig('links', 'self', 'href')
+ end
+ end
+ end
+end