rujira 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -23
- data/lib/rujira/api/application_properties.rb +65 -0
- data/lib/rujira/api/applicationrole.rb +85 -0
- data/lib/rujira/api/attachments.rb +41 -13
- data/lib/rujira/api/avatar.rb +68 -0
- data/lib/rujira/api/configuration.rb +27 -0
- data/lib/rujira/api/custom_fields.rb +47 -0
- data/lib/rujira/api/field.rb +49 -0
- data/lib/rujira/api/filter.rb +223 -0
- data/lib/rujira/api/issue/comments.rb +203 -0
- data/lib/rujira/api/issue/watchers.rb +116 -0
- data/lib/rujira/api/issue.rb +312 -26
- data/lib/rujira/api/myself.rb +36 -0
- data/lib/rujira/api/permissions.rb +45 -0
- data/lib/rujira/client.rb +8 -2
- data/lib/rujira/version.rb +1 -1
- data/lib/rujira.rb +8 -0
- metadata +11 -1
@@ -0,0 +1,203 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rujira
|
4
|
+
module Api
|
5
|
+
class Issue < Common
|
6
|
+
# Module providing methods to manage comments on Jira issues.
|
7
|
+
#
|
8
|
+
# This module is included in the `Issue` class and allows you to:
|
9
|
+
# - Add a new comment to an issue
|
10
|
+
# - Retrieve a specific comment
|
11
|
+
# - Update a comment
|
12
|
+
# - Delete a comment
|
13
|
+
# - Pin a comment
|
14
|
+
# - Retrieve pinned comments
|
15
|
+
#
|
16
|
+
# All methods support an optional block to customize the request using the
|
17
|
+
# builder DSL, e.g., adding headers, query parameters, or payloads.
|
18
|
+
#
|
19
|
+
# @example Add a comment to an issue
|
20
|
+
# client.Issue.add_comment("TEST-123") do
|
21
|
+
# payload({ body: "This is a comment" })
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# @example Update a comment
|
25
|
+
# client.Issue.update_comment("TEST-123", "10001") do
|
26
|
+
# payload({ body: "Updated comment text" })
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# @example Delete a comment
|
30
|
+
# client.Issue.delete_comment("TEST-123", "10001")
|
31
|
+
#
|
32
|
+
# @example Get a pinned comment
|
33
|
+
# client.Issue.get_pinned_comment("TEST-123")
|
34
|
+
#
|
35
|
+
# @example Pin a comment
|
36
|
+
# client.Issue.pin_comment("TEST-123", "10001")
|
37
|
+
module Comments
|
38
|
+
# Retrieves comments for a given issue.
|
39
|
+
#
|
40
|
+
# @param [String] id_or_key The issue ID or key.
|
41
|
+
# @yield [builder] Optional block to configure additional request parameters.
|
42
|
+
# @return [Object] The API response containing the issue's comments.
|
43
|
+
#
|
44
|
+
# @example Get comments for an issue
|
45
|
+
# client.Issue.comment("TEST-123") do
|
46
|
+
# # Optional: add query parameters or headers
|
47
|
+
# params startAt: 0, maxResults: 50
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
def list_comment(id_or_key, &block)
|
51
|
+
abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
|
52
|
+
builder do
|
53
|
+
path "issue/#{id_or_key}/comment"
|
54
|
+
method :get
|
55
|
+
instance_eval(&block) if block_given?
|
56
|
+
end
|
57
|
+
run
|
58
|
+
end
|
59
|
+
|
60
|
+
# Adds a comment to a given issue.
|
61
|
+
#
|
62
|
+
# @param [String] id_or_key The issue ID or key.
|
63
|
+
# @yield [builder] Block to configure the payload for the new comment.
|
64
|
+
# @return [Object] The API response after adding the comment.
|
65
|
+
#
|
66
|
+
# @example Add a comment to an issue
|
67
|
+
# client.Issue.add_comment("TEST-123") do
|
68
|
+
# payload body: "This is a new comment added via the API."
|
69
|
+
# end
|
70
|
+
def add_comment(id_or_key, &block)
|
71
|
+
abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
|
72
|
+
builder do
|
73
|
+
path "issue/#{id_or_key}/comment"
|
74
|
+
method :post
|
75
|
+
instance_eval(&block) if block_given?
|
76
|
+
end
|
77
|
+
run
|
78
|
+
end
|
79
|
+
|
80
|
+
# Updates an existing comment on a given issue.
|
81
|
+
#
|
82
|
+
# @param [String] id_or_key The issue ID or key.
|
83
|
+
# @param [String] id The comment ID.
|
84
|
+
# @yield [builder] Block to configure the payload for updating the comment.
|
85
|
+
# @return [Object] The API response after updating the comment.
|
86
|
+
#
|
87
|
+
# @example Update a comment on an issue
|
88
|
+
# client.Issue.update_comment("TEST-123", "10001") do
|
89
|
+
# payload body: "Updated comment content."
|
90
|
+
# end
|
91
|
+
def update_comment(id_or_key, id, &block)
|
92
|
+
abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
|
93
|
+
builder do
|
94
|
+
path "issue/#{id_or_key}/comment/#{id}"
|
95
|
+
method :put
|
96
|
+
instance_eval(&block) if block_given?
|
97
|
+
end
|
98
|
+
run
|
99
|
+
end
|
100
|
+
|
101
|
+
# Deletes a comment from a given issue.
|
102
|
+
#
|
103
|
+
# @param [String] id_or_key The issue ID or key.
|
104
|
+
# @param [String] id The comment ID.
|
105
|
+
# @yield [builder] Optional block to configure additional request parameters.
|
106
|
+
# @return [Object] The API response after deleting the comment.
|
107
|
+
#
|
108
|
+
# @example Delete a comment from an issue
|
109
|
+
# client.Issue.delete_comment("TEST-123", "10001") do
|
110
|
+
# # Optional: add headers or query parameters if needed
|
111
|
+
# end
|
112
|
+
def delete_comment(id_or_key, id, &block)
|
113
|
+
abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
|
114
|
+
builder do
|
115
|
+
path "issue/#{id_or_key}/comment/#{id}"
|
116
|
+
method :delete
|
117
|
+
instance_eval(&block) if block_given?
|
118
|
+
end
|
119
|
+
run
|
120
|
+
end
|
121
|
+
|
122
|
+
# Retrieves a specific comment from a given issue.
|
123
|
+
#
|
124
|
+
# @param [String] id_or_key The issue ID or key.
|
125
|
+
# @param [String] id The comment ID.
|
126
|
+
# @yield [builder] Optional block to configure additional request parameters.
|
127
|
+
# @return [Object] The API response containing the comment details.
|
128
|
+
#
|
129
|
+
# @example Get a specific comment
|
130
|
+
# client.Issue.get_comment("TEST-123", "10001") do
|
131
|
+
# # Optional: add headers or query parameters if needed
|
132
|
+
# end
|
133
|
+
#
|
134
|
+
def get_comment(id_or_key, id, &block)
|
135
|
+
abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
|
136
|
+
builder do
|
137
|
+
path "issue/#{id_or_key}/comment/#{id}"
|
138
|
+
instance_eval(&block) if block_given?
|
139
|
+
end
|
140
|
+
run
|
141
|
+
end
|
142
|
+
|
143
|
+
# Pins a comment on a given issue.
|
144
|
+
#
|
145
|
+
# @param [String] id_or_key The issue ID or key.
|
146
|
+
# @param [String] id The comment ID.
|
147
|
+
# @yield [builder] Optional block to configure additional request parameters.
|
148
|
+
# @return [Object] The API response after pinning the comment.
|
149
|
+
#
|
150
|
+
# @example Pin a comment
|
151
|
+
# client.Issue.pin_comment("TEST-123", "10001") do
|
152
|
+
# # Optional: add headers or query parameters if needed
|
153
|
+
# end
|
154
|
+
#
|
155
|
+
def pin_comment(id_or_key, id, &block)
|
156
|
+
abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
|
157
|
+
builder do
|
158
|
+
method :put
|
159
|
+
path "issue/#{id_or_key}/comment/#{id}/pin"
|
160
|
+
instance_eval(&block) if block_given?
|
161
|
+
end
|
162
|
+
run
|
163
|
+
end
|
164
|
+
|
165
|
+
# Adds a comment to an issue.
|
166
|
+
#
|
167
|
+
# @param [String] id_or_key The issue ID or key.
|
168
|
+
# @yield [builder] Optional block to configure the comment payload.
|
169
|
+
# @return [Object] The API response containing the created comment.
|
170
|
+
#
|
171
|
+
# @example Add a comment
|
172
|
+
# client.Issue.comment("TEST-123") do
|
173
|
+
# payload body: "This is a comment"
|
174
|
+
# end
|
175
|
+
#
|
176
|
+
def comment(id_or_key, &block)
|
177
|
+
abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
|
178
|
+
@client.Comment.create id_or_key, &block
|
179
|
+
end
|
180
|
+
|
181
|
+
# Retrieves the pinned comment(s) for a given issue.
|
182
|
+
#
|
183
|
+
# @param [String] id_or_key The issue ID or key.
|
184
|
+
# @yield [builder] Optional block to configure additional request parameters.
|
185
|
+
# @return [Object] The API response containing the pinned comment(s).
|
186
|
+
#
|
187
|
+
# @example Get pinned comments for an issue
|
188
|
+
# client.Issue.get_pinned_comment("TEST-123") do
|
189
|
+
# # Optional: add query parameters or headers
|
190
|
+
# params expand: "renderedBody"
|
191
|
+
# end
|
192
|
+
def get_pinned_comments(id_or_key, &block)
|
193
|
+
abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
|
194
|
+
builder do
|
195
|
+
path "issue/#{id_or_key}/pinned-comments"
|
196
|
+
instance_eval(&block) if block_given?
|
197
|
+
end
|
198
|
+
run
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rujira
|
4
|
+
module Api
|
5
|
+
# Provides access to Jira issues via the REST API.
|
6
|
+
# API reference:
|
7
|
+
# https://docs.atlassian.com/software/jira/docs/api/REST/9.17.0/#api/2/issue
|
8
|
+
#
|
9
|
+
class Issue < Common
|
10
|
+
# Module providing methods to manage watchers on Jira issues.
|
11
|
+
#
|
12
|
+
# This module is included in the `Issue` class and allows you to:
|
13
|
+
# - Retrieve the list of watchers for an issue
|
14
|
+
# - Add watchers to an issue
|
15
|
+
# - Remove watchers from an issue
|
16
|
+
#
|
17
|
+
# All methods support an optional block to customize the request using the
|
18
|
+
# builder DSL, e.g., adding headers, query parameters, or payloads.
|
19
|
+
#
|
20
|
+
# @example Get all watchers for an issue
|
21
|
+
# client.Issue.get_watchers("TEST-123")
|
22
|
+
#
|
23
|
+
# @example Add watchers to an issue
|
24
|
+
# client.Issue.add_watchers("TEST-123") do
|
25
|
+
# payload ["john.doe", "jane.smith"]
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# @example Remove a watcher from an issue
|
29
|
+
# client.Issue.remove_watchers("TEST-123", "john.doe")
|
30
|
+
module Watchers
|
31
|
+
# Removes a watcher from a given issue.
|
32
|
+
#
|
33
|
+
# @param [String] id_or_key The issue ID or key.
|
34
|
+
# @param [String] username The username of the watcher to remove.
|
35
|
+
# @yield [builder] Optional block to configure additional request parameters.
|
36
|
+
# @return [Object] The API response after removing the watcher.
|
37
|
+
#
|
38
|
+
# @example Remove a watcher from an issue
|
39
|
+
# client.Issue.remove_watchers("TEST-123", "john.doe") do
|
40
|
+
# # Optional: add headers or query parameters
|
41
|
+
# end
|
42
|
+
def remove_watchers(id_or_key, username, &block)
|
43
|
+
abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
|
44
|
+
abort 'USERNAME is required' if username.to_s.strip.empty?
|
45
|
+
builder do
|
46
|
+
method :delete
|
47
|
+
path "issue/#{id_or_key}/watchers"
|
48
|
+
params username: username
|
49
|
+
instance_eval(&block) if block_given?
|
50
|
+
end
|
51
|
+
run
|
52
|
+
end
|
53
|
+
|
54
|
+
# Retrieves the list of watchers for a given issue.
|
55
|
+
#
|
56
|
+
# @param [String] id_or_key The issue ID or key.
|
57
|
+
# @yield [builder] Optional block to configure additional request parameters.
|
58
|
+
# @return [Object] The API response containing the list of watchers.
|
59
|
+
#
|
60
|
+
# @example Get watchers of an issue
|
61
|
+
# client.Issue.get_watchers("TEST-123") do
|
62
|
+
# # Optional: add query parameters or headers
|
63
|
+
# end
|
64
|
+
def get_watchers(id_or_key, &block)
|
65
|
+
abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
|
66
|
+
builder do
|
67
|
+
path "issue/#{id_or_key}/watchers"
|
68
|
+
instance_eval(&block) if block_given?
|
69
|
+
end
|
70
|
+
run
|
71
|
+
end
|
72
|
+
|
73
|
+
# Adds watchers to a given issue.
|
74
|
+
#
|
75
|
+
# @param [String] id_or_key The issue ID or key.
|
76
|
+
# @yield [builder] Block to configure the payload for adding watchers.
|
77
|
+
# @return [Object] The API response after adding watchers.
|
78
|
+
#
|
79
|
+
# @example Add watchers to an issue
|
80
|
+
# client.Issue.add_watchers("TEST-123") do
|
81
|
+
# payload ["john.doe", "jane.smith"]
|
82
|
+
# end
|
83
|
+
def add_watchers(id_or_key, &block)
|
84
|
+
abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
|
85
|
+
builder do
|
86
|
+
method :post
|
87
|
+
path "issue/#{id_or_key}/watchers"
|
88
|
+
instance_eval(&block) if block_given?
|
89
|
+
end
|
90
|
+
run
|
91
|
+
end
|
92
|
+
|
93
|
+
# Adds a watcher to an issue.
|
94
|
+
#
|
95
|
+
# @param [String] id_or_key The issue ID or key.
|
96
|
+
# @param [String] name The username to add as a watcher.
|
97
|
+
# @yield [builder] Optional block to configure the request.
|
98
|
+
# @return [Object] The API response after adding the watcher.
|
99
|
+
#
|
100
|
+
# @example Add a watcher
|
101
|
+
# client.Issue.watchers("TEST-123", "johndoe")
|
102
|
+
#
|
103
|
+
def watcher(id_or_key, name, &block)
|
104
|
+
abort 'Issue ID or KEY is required' if id_or_key.to_s.strip.empty?
|
105
|
+
builder do
|
106
|
+
path "issue/#{id_or_key}/watchers"
|
107
|
+
method :post
|
108
|
+
payload name.to_json
|
109
|
+
instance_eval(&block) if block_given?
|
110
|
+
end
|
111
|
+
run
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|