diff options
Diffstat (limited to 'lib/bitbucket')
-rw-r--r-- | lib/bitbucket/client.rb | 7 | ||||
-rw-r--r-- | lib/bitbucket/representation/issue.rb | 49 |
2 files changed, 56 insertions, 0 deletions
diff --git a/lib/bitbucket/client.rb b/lib/bitbucket/client.rb index 24984ca0793..ac6e91bb526 100644 --- a/lib/bitbucket/client.rb +++ b/lib/bitbucket/client.rb @@ -4,6 +4,13 @@ module Bitbucket @connection = options.fetch(:connection, Connection.new(options)) end + def issues(repo) + relative_path = "/repositories/#{repo}/issues" + paginator = Paginator.new(connection, relative_path, :issue) + + Collection.new(paginator) + end + def repo(name) parsed_response = connection.get("/repositories/#{name}") diff --git a/lib/bitbucket/representation/issue.rb b/lib/bitbucket/representation/issue.rb new file mode 100644 index 00000000000..48647ad51f6 --- /dev/null +++ b/lib/bitbucket/representation/issue.rb @@ -0,0 +1,49 @@ +module Bitbucket + module Representation + class Issue < Representation::Base + CLOSED_STATUS = %w(resolved invalid duplicate wontfix closed).freeze + + def iid + raw['id'] + end + + def author + reporter.fetch('username', 'Anonymous') + end + + def description + raw.dig('content', 'raw') + end + + def state + closed? ? 'closed' : 'opened' + end + + def title + raw['title'] + end + + def created_at + raw['created_on'] + end + + def updated_at + raw['edited_on'] + end + + def to_s + iid + end + + private + + def closed? + CLOSED_STATUS.include?(raw['state']) + end + + def reporter + raw.fetch('reporter', {}) + end + end + end +end |