issue.rb 893 Bytes
Newer Older
1
2
# frozen_string_literal: true

3
4
5
6
7
8
9
10
11
module Bitbucket
  module Representation
    class Issue < Representation::Base
      CLOSED_STATUS = %w(resolved invalid duplicate wontfix closed).freeze

      def iid
        raw['id']
      end

12
13
14
15
      def kind
        raw['kind']
      end

16
      def author
17
        raw.dig('reporter', 'nickname')
18
19
20
      end

      def description
21
        raw.fetch('content', {}).fetch('raw', nil)
22
23
24
25
26
27
28
29
30
31
      end

      def state
        closed? ? 'closed' : 'opened'
      end

      def title
        raw['title']
      end

Valery Sizov's avatar
Valery Sizov committed
32
      def milestone
33
        raw['milestone']['name'] if raw['milestone'].present?
Valery Sizov's avatar
Valery Sizov committed
34
35
      end

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
      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
    end
  end
end