summaryrefslogtreecommitdiff
path: root/qa/qa/vendor/smocker/event_payload.rb
blob: e7287c741cea03ee5ef8b5343a44aef83f2b894a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# frozen_string_literal: true

module QA
  module Vendor
    module Smocker
      class EventPayload
        def initialize(hook_data)
          @hook_data = hook_data
        end

        def raw
          @hook_data
        end

        def event
          raw[:object_kind]&.to_sym
        end

        def event_name
          raw[:event_name]&.to_sym
        end

        def project_name
          raw.dig(:project, :name)
        end

        def mr?
          event == :merge_request
        end

        def issue?
          event == :issue
        end

        def note?
          event == :note
        end

        def push?
          event == :push
        end

        def tag?
          event == :tag
        end

        def wiki?
          event == :wiki_page
        end

        def subgroup_create?
          event_name == :subgroup_create
        end

        def subgroup_destroy?
          event_name == :subgroup_destroy
        end
      end
    end
  end
end