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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# frozen_string_literal: true
module QA
module Resource
class Issuable < Base
using Rainbow
# Comments (notes) path
#
# @return [String]
def api_comments_path
"#{api_get_path}/notes"
end
# Get issue comments
#
# @return [Array]
def comments(auto_paginate: false, attempts: 0)
Runtime::Logger.debug("Fetching comments for #{self.class.name.black.bg(:white)} with path '#{api_get_path}'")
return parse_body(api_get_from(api_comments_path)) unless auto_paginate
auto_paginated_response(
Runtime::API::Request.new(api_client, api_comments_path, per_page: '100').url,
attempts: attempts
)
end
# Create a new comment
#
# @param [String] body
# @param [Boolean] confidential
# @return [Hash]
def add_comment(body:, confidential: false)
api_post_to(api_comments_path, body: body, confidential: confidential)
end
# Issue label events
#
# @param [Boolean] auto_paginate
# @param [Integer] attempts
# @return [Array<Hash>]
def label_events(auto_paginate: false, attempts: 0)
events("label", auto_paginate: auto_paginate, attempts: attempts)
end
# Issue state events
#
# @param [Boolean] auto_paginate
# @param [Integer] attempts
# @return [Array<Hash>]
def state_events(auto_paginate: false, attempts: 0)
events("state", auto_paginate: auto_paginate, attempts: attempts)
end
# Issue milestone events
#
# @param [Boolean] auto_paginate
# @param [Integer] attempts
# @return [Array<Hash>]
def milestone_events(auto_paginate: false, attempts: 0)
events("milestone", auto_paginate: auto_paginate, attempts: attempts)
end
private
# Issue events
#
# @param [String] name event name
# @param [Boolean] auto_paginate
# @param [Integer] attempts
# @return [Array<Hash>]
def events(name, auto_paginate:, attempts:)
return parse_body(api_get_from("#{api_get_path}/resource_#{name}_events")) unless auto_paginate
auto_paginated_response(
Runtime::API::Request.new(api_client, "#{api_get_path}/resource_#{name}_events", per_page: '100').url,
attempts: attempts
)
end
end
end
end
|