fizzy-cli 0.5.0 → 0.6.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.
- package/CHANGELOG.md +27 -0
- package/cmd/card_update.go +24 -14
- package/cmd/comment_delete.go +46 -0
- package/cmd/comment_delete_test.go +92 -0
- package/cmd/comment_update.go +51 -0
- package/cmd/comment_update_test.go +130 -0
- package/cmd/reaction.go +13 -0
- package/cmd/reaction_create.go +46 -0
- package/cmd/reaction_create_test.go +113 -0
- package/cmd/reaction_delete.go +46 -0
- package/cmd/reaction_delete_test.go +92 -0
- package/cmd/reaction_list.go +51 -0
- package/cmd/reaction_list_test.go +125 -0
- package/cmd/step.go +14 -0
- package/cmd/step_create.go +53 -0
- package/cmd/step_create_test.go +171 -0
- package/cmd/step_delete.go +46 -0
- package/cmd/step_delete_test.go +92 -0
- package/cmd/step_update.go +66 -0
- package/cmd/step_update_test.go +190 -0
- package/internal/api/boards.go +59 -0
- package/internal/api/cards.go +288 -0
- package/internal/api/client.go +1 -712
- package/internal/api/columns.go +50 -0
- package/internal/api/comments.go +99 -0
- package/internal/api/identity.go +24 -0
- package/internal/api/notifications.go +89 -0
- package/internal/api/reactions.go +61 -0
- package/internal/api/steps.go +93 -0
- package/internal/api/tags.go +24 -0
- package/internal/api/types.go +178 -0
- package/internal/ui/reaction_list.go +14 -0
- package/package.json +1 -1
package/internal/api/client.go
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Package api
|
|
1
|
+
// Package api provides the Fizzy API client
|
|
2
2
|
package api
|
|
3
3
|
|
|
4
4
|
import (
|
|
@@ -10,8 +10,6 @@ import (
|
|
|
10
10
|
"net/http"
|
|
11
11
|
"os"
|
|
12
12
|
"time"
|
|
13
|
-
|
|
14
|
-
"github.com/rogeriopvl/fizzy/internal/colors"
|
|
15
13
|
)
|
|
16
14
|
|
|
17
15
|
type Client struct {
|
|
@@ -99,712 +97,3 @@ func (c *Client) decodeResponse(req *http.Request, v any, expectedStatus ...int)
|
|
|
99
97
|
|
|
100
98
|
return res.StatusCode, nil
|
|
101
99
|
}
|
|
102
|
-
|
|
103
|
-
func (c *Client) GetBoards(ctx context.Context) ([]Board, error) {
|
|
104
|
-
endpointURL := c.AccountBaseURL + "/boards"
|
|
105
|
-
|
|
106
|
-
req, err := c.newRequest(ctx, http.MethodGet, endpointURL, nil)
|
|
107
|
-
if err != nil {
|
|
108
|
-
return nil, fmt.Errorf("failed to create request: %w", err)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
var response []Board
|
|
112
|
-
_, err = c.decodeResponse(req, &response)
|
|
113
|
-
if err != nil {
|
|
114
|
-
return nil, err
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return response, nil
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
func (c *Client) GetBoard(ctx context.Context, boardID string) (*Board, error) {
|
|
121
|
-
endpointURL := c.AccountBaseURL + "/boards/" + boardID
|
|
122
|
-
|
|
123
|
-
req, err := c.newRequest(ctx, http.MethodGet, endpointURL, nil)
|
|
124
|
-
if err != nil {
|
|
125
|
-
return nil, fmt.Errorf("failed to create request: %w", err)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
var response Board
|
|
129
|
-
_, err = c.decodeResponse(req, &response)
|
|
130
|
-
if err != nil {
|
|
131
|
-
return nil, err
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return &response, nil
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
func (c *Client) PostBoards(ctx context.Context, payload CreateBoardPayload) (bool, error) {
|
|
138
|
-
endpointURL := c.AccountBaseURL + "/boards"
|
|
139
|
-
|
|
140
|
-
body := map[string]CreateBoardPayload{"board": payload}
|
|
141
|
-
|
|
142
|
-
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, body)
|
|
143
|
-
if err != nil {
|
|
144
|
-
return false, fmt.Errorf("failed to create board request: %w", err)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
_, err = c.decodeResponse(req, nil, http.StatusCreated)
|
|
148
|
-
if err != nil {
|
|
149
|
-
return false, err
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return true, nil
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
func (c *Client) GetColumns(ctx context.Context) ([]Column, error) {
|
|
156
|
-
if c.BoardBaseURL == "" {
|
|
157
|
-
return nil, fmt.Errorf("please select a board first with 'fizzy use --board <board_name>'")
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
endpointURL := c.BoardBaseURL + "/columns"
|
|
161
|
-
|
|
162
|
-
req, err := c.newRequest(ctx, http.MethodGet, endpointURL, nil)
|
|
163
|
-
if err != nil {
|
|
164
|
-
return nil, fmt.Errorf("failed to create get columns request: %w", err)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
var response []Column
|
|
168
|
-
_, err = c.decodeResponse(req, &response)
|
|
169
|
-
if err != nil {
|
|
170
|
-
return nil, err
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return response, nil
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
func (c *Client) PostColumns(ctx context.Context, payload CreateColumnPayload) (bool, error) {
|
|
177
|
-
if c.BoardBaseURL == "" {
|
|
178
|
-
return false, fmt.Errorf("please select a board first with 'fizzy use --board <board_name>'")
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
endpointURL := c.BoardBaseURL + "/columns"
|
|
182
|
-
|
|
183
|
-
body := map[string]CreateColumnPayload{"column": payload}
|
|
184
|
-
|
|
185
|
-
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, body)
|
|
186
|
-
if err != nil {
|
|
187
|
-
return false, fmt.Errorf("failed to create column request: %w", err)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
_, err = c.decodeResponse(req, nil, http.StatusCreated)
|
|
191
|
-
if err != nil {
|
|
192
|
-
return false, err
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return true, nil
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
func (c *Client) GetCards(ctx context.Context, filters CardFilters) ([]Card, error) {
|
|
199
|
-
endpointURL := c.AccountBaseURL + "/cards"
|
|
200
|
-
|
|
201
|
-
req, err := c.newRequest(ctx, http.MethodGet, endpointURL, nil)
|
|
202
|
-
if err != nil {
|
|
203
|
-
return nil, fmt.Errorf("failed to create get cards request: %w", err)
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if len(filters.BoardIDs) > 0 {
|
|
207
|
-
q := req.URL.Query()
|
|
208
|
-
for _, boardID := range filters.BoardIDs {
|
|
209
|
-
q.Add("board_ids[]", boardID)
|
|
210
|
-
}
|
|
211
|
-
req.URL.RawQuery = q.Encode()
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
var response []Card
|
|
215
|
-
_, err = c.decodeResponse(req, &response)
|
|
216
|
-
if err != nil {
|
|
217
|
-
return nil, err
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return response, nil
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
func (c *Client) GetCard(ctx context.Context, cardNumber int) (*Card, error) {
|
|
224
|
-
endpointURL := fmt.Sprintf("%s/cards/%d", c.AccountBaseURL, cardNumber)
|
|
225
|
-
|
|
226
|
-
req, err := c.newRequest(ctx, http.MethodGet, endpointURL, nil)
|
|
227
|
-
if err != nil {
|
|
228
|
-
return nil, fmt.Errorf("failed to create get card by id request: %w", err)
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
var response Card
|
|
232
|
-
_, err = c.decodeResponse(req, &response)
|
|
233
|
-
if err != nil {
|
|
234
|
-
return nil, err
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return &response, nil
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
func (c *Client) PostCards(ctx context.Context, payload CreateCardPayload) (bool, error) {
|
|
241
|
-
if c.BoardBaseURL == "" {
|
|
242
|
-
return false, fmt.Errorf("please select a board first with 'fizzy use --board <board_name>'")
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
endpointURL := c.BoardBaseURL + "/cards"
|
|
246
|
-
|
|
247
|
-
body := map[string]CreateCardPayload{"card": payload}
|
|
248
|
-
|
|
249
|
-
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, body)
|
|
250
|
-
if err != nil {
|
|
251
|
-
return false, fmt.Errorf("failed to create card request: %w", err)
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
_, err = c.decodeResponse(req, nil, http.StatusCreated)
|
|
255
|
-
if err != nil {
|
|
256
|
-
return false, err
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
return true, nil
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
func (c *Client) PutCard(ctx context.Context, cardNumber int, payload UpdateCardPayload) (*Card, error) {
|
|
263
|
-
endpointURL := fmt.Sprintf("%s/cards/%d", c.AccountBaseURL, cardNumber)
|
|
264
|
-
|
|
265
|
-
body := map[string]UpdateCardPayload{"card": payload}
|
|
266
|
-
|
|
267
|
-
req, err := c.newRequest(ctx, http.MethodPut, endpointURL, body)
|
|
268
|
-
if err != nil {
|
|
269
|
-
return nil, fmt.Errorf("failed to create update card request: %w", err)
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
var response Card
|
|
273
|
-
_, err = c.decodeResponse(req, &response, http.StatusOK)
|
|
274
|
-
if err != nil {
|
|
275
|
-
return nil, err
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return &response, nil
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
func (c *Client) DeleteCard(ctx context.Context, cardNumber int) (bool, error) {
|
|
282
|
-
endpointURL := fmt.Sprintf("%s/cards/%d", c.AccountBaseURL, cardNumber)
|
|
283
|
-
|
|
284
|
-
req, err := c.newRequest(ctx, http.MethodDelete, endpointURL, nil)
|
|
285
|
-
if err != nil {
|
|
286
|
-
return false, fmt.Errorf("failed to create delete card request: %w", err)
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
290
|
-
if err != nil {
|
|
291
|
-
return false, err
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
return true, nil
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
func (c *Client) PostCardsClosure(ctx context.Context, cardNumber int) (bool, error) {
|
|
298
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/closure", c.AccountBaseURL, cardNumber)
|
|
299
|
-
|
|
300
|
-
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, nil)
|
|
301
|
-
if err != nil {
|
|
302
|
-
return false, fmt.Errorf("failed to create closure card request: %w", err)
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
306
|
-
if err != nil {
|
|
307
|
-
return false, err
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return true, nil
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
func (c *Client) PostCardNotNow(ctx context.Context, cardNumber int) (bool, error) {
|
|
314
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/not_now", c.AccountBaseURL, cardNumber)
|
|
315
|
-
|
|
316
|
-
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, nil)
|
|
317
|
-
if err != nil {
|
|
318
|
-
return false, fmt.Errorf("failed to create post not now request: %w", err)
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
322
|
-
if err != nil {
|
|
323
|
-
return false, err
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
return true, nil
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
func (c *Client) PostCardTriage(ctx context.Context, cardNumber int, columnID string) (bool, error) {
|
|
330
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/triage", c.AccountBaseURL, cardNumber)
|
|
331
|
-
|
|
332
|
-
body := map[string]any{"column_id": columnID}
|
|
333
|
-
|
|
334
|
-
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, body)
|
|
335
|
-
if err != nil {
|
|
336
|
-
return false, fmt.Errorf("failed to create post triage request: %w", err)
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
340
|
-
if err != nil {
|
|
341
|
-
return false, err
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
return true, nil
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
func (c *Client) DeleteCardTriage(ctx context.Context, cardNumber int) (bool, error) {
|
|
348
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/triage", c.AccountBaseURL, cardNumber)
|
|
349
|
-
|
|
350
|
-
req, err := c.newRequest(ctx, http.MethodDelete, endpointURL, nil)
|
|
351
|
-
if err != nil {
|
|
352
|
-
return false, fmt.Errorf("failed to create delete triage request: %w", err)
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
356
|
-
if err != nil {
|
|
357
|
-
return false, err
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
return true, nil
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
func (c *Client) PostCardWatch(ctx context.Context, cardNumber int) (bool, error) {
|
|
364
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/watch", c.AccountBaseURL, cardNumber)
|
|
365
|
-
|
|
366
|
-
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, nil)
|
|
367
|
-
if err != nil {
|
|
368
|
-
return false, fmt.Errorf("failed to create post watch request: %w", err)
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
372
|
-
if err != nil {
|
|
373
|
-
return false, err
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
return true, nil
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
func (c *Client) DeleteCardWatch(ctx context.Context, cardNumber int) (bool, error) {
|
|
380
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/watch", c.AccountBaseURL, cardNumber)
|
|
381
|
-
|
|
382
|
-
req, err := c.newRequest(ctx, http.MethodDelete, endpointURL, nil)
|
|
383
|
-
if err != nil {
|
|
384
|
-
return false, fmt.Errorf("failed to create delete watch request: %w", err)
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
388
|
-
if err != nil {
|
|
389
|
-
return false, err
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
return true, nil
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
func (c *Client) PostCardGoldenness(ctx context.Context, cardNumber int) (bool, error) {
|
|
396
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/goldness", c.AccountBaseURL, cardNumber)
|
|
397
|
-
|
|
398
|
-
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, nil)
|
|
399
|
-
if err != nil {
|
|
400
|
-
return false, fmt.Errorf("failed to create post goldness request: %w", err)
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
404
|
-
if err != nil {
|
|
405
|
-
return false, err
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
return true, nil
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
func (c *Client) DeleteCardGoldenness(ctx context.Context, cardNumber int) (bool, error) {
|
|
412
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/goldness", c.AccountBaseURL, cardNumber)
|
|
413
|
-
|
|
414
|
-
req, err := c.newRequest(ctx, http.MethodDelete, endpointURL, nil)
|
|
415
|
-
if err != nil {
|
|
416
|
-
return false, fmt.Errorf("failed to create delete goldness request: %w", err)
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
420
|
-
if err != nil {
|
|
421
|
-
return false, err
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
return true, nil
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
func (c *Client) DeleteCardsClosure(ctx context.Context, cardNumber int) (bool, error) {
|
|
428
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/closure", c.AccountBaseURL, cardNumber)
|
|
429
|
-
|
|
430
|
-
req, err := c.newRequest(ctx, http.MethodDelete, endpointURL, nil)
|
|
431
|
-
if err != nil {
|
|
432
|
-
return false, fmt.Errorf("failed to create delete closure card request: %w", err)
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
436
|
-
if err != nil {
|
|
437
|
-
return false, err
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
return true, nil
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
func (c *Client) PostCardAssignments(ctx context.Context, cardNumber int, userID string) (bool, error) {
|
|
444
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/assignments", c.AccountBaseURL, cardNumber)
|
|
445
|
-
|
|
446
|
-
body := map[string]string{"assignee_id": userID}
|
|
447
|
-
|
|
448
|
-
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, body)
|
|
449
|
-
if err != nil {
|
|
450
|
-
return false, fmt.Errorf("failed to create assignment request: %w", err)
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
454
|
-
if err != nil {
|
|
455
|
-
return false, err
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
return true, nil
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
func (c *Client) PostCardTagging(ctx context.Context, cardNumber int, tagTitle string) (bool, error) {
|
|
462
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/taggings", c.AccountBaseURL, cardNumber)
|
|
463
|
-
|
|
464
|
-
body := map[string]string{"tag_title": tagTitle}
|
|
465
|
-
|
|
466
|
-
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, body)
|
|
467
|
-
if err != nil {
|
|
468
|
-
return false, fmt.Errorf("failed to create tagging request: %w", err)
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
472
|
-
if err != nil {
|
|
473
|
-
return false, err
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
return true, nil
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
func (c *Client) GetMyIdentity(ctx context.Context) (*GetMyIdentityResponse, error) {
|
|
480
|
-
endpointURL := c.BaseURL + "/my/identity"
|
|
481
|
-
|
|
482
|
-
req, err := c.newRequest(ctx, http.MethodGet, endpointURL, nil)
|
|
483
|
-
if err != nil {
|
|
484
|
-
return nil, fmt.Errorf("failed to create request: %w", err)
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
var response GetMyIdentityResponse
|
|
488
|
-
_, err = c.decodeResponse(req, &response)
|
|
489
|
-
if err != nil {
|
|
490
|
-
return nil, err
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
return &response, nil
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
func (c *Client) GetNotifications(ctx context.Context) ([]Notification, error) {
|
|
497
|
-
endpointURL := c.AccountBaseURL + "/notifications"
|
|
498
|
-
|
|
499
|
-
req, err := c.newRequest(ctx, http.MethodGet, endpointURL, nil)
|
|
500
|
-
if err != nil {
|
|
501
|
-
return nil, fmt.Errorf("failed to create get notifications request: %w", err)
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
var response []Notification
|
|
505
|
-
_, err = c.decodeResponse(req, &response)
|
|
506
|
-
if err != nil {
|
|
507
|
-
return nil, err
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
return response, nil
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
func (c *Client) GetNotification(ctx context.Context, notificationID string) (*Notification, error) {
|
|
514
|
-
endpointURL := fmt.Sprintf("%s/notifications/%s", c.AccountBaseURL, notificationID)
|
|
515
|
-
|
|
516
|
-
req, err := c.newRequest(ctx, http.MethodGet, endpointURL, nil)
|
|
517
|
-
if err != nil {
|
|
518
|
-
return nil, fmt.Errorf("failed to create get notification request: %w", err)
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
var response Notification
|
|
522
|
-
_, err = c.decodeResponse(req, &response)
|
|
523
|
-
if err != nil {
|
|
524
|
-
return nil, err
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
return &response, nil
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
func (c *Client) PostNotificationReading(ctx context.Context, notificationID string) (bool, error) {
|
|
531
|
-
endpointURL := fmt.Sprintf("%s/notifications/%s/reading", c.AccountBaseURL, notificationID)
|
|
532
|
-
|
|
533
|
-
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, nil)
|
|
534
|
-
if err != nil {
|
|
535
|
-
return false, fmt.Errorf("failed to create mark notification as read request: %w", err)
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
539
|
-
if err != nil {
|
|
540
|
-
return false, err
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
return true, nil
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
func (c *Client) DeleteNotificationReading(ctx context.Context, notificationID string) (bool, error) {
|
|
547
|
-
endpointURL := fmt.Sprintf("%s/notifications/%s/reading", c.AccountBaseURL, notificationID)
|
|
548
|
-
|
|
549
|
-
req, err := c.newRequest(ctx, http.MethodDelete, endpointURL, nil)
|
|
550
|
-
if err != nil {
|
|
551
|
-
return false, fmt.Errorf("failed to create delete notification request: %w", err)
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
555
|
-
if err != nil {
|
|
556
|
-
return false, err
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
return true, nil
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
func (c *Client) PostBulkNotificationsReading(ctx context.Context) (bool, error) {
|
|
563
|
-
endpointURL := c.AccountBaseURL + "/notifications/bulk_reading"
|
|
564
|
-
|
|
565
|
-
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, nil)
|
|
566
|
-
if err != nil {
|
|
567
|
-
return false, fmt.Errorf("failed to create bulk notifications reading request: %w", err)
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
571
|
-
if err != nil {
|
|
572
|
-
return false, err
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
return true, nil
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
func (c *Client) GetTags(ctx context.Context) ([]Tag, error) {
|
|
579
|
-
endpointURL := c.AccountBaseURL + "/tags"
|
|
580
|
-
|
|
581
|
-
req, err := c.newRequest(ctx, http.MethodGet, endpointURL, nil)
|
|
582
|
-
if err != nil {
|
|
583
|
-
return nil, fmt.Errorf("failed to create get tags request: %w", err)
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
var response []Tag
|
|
587
|
-
_, err = c.decodeResponse(req, &response)
|
|
588
|
-
if err != nil {
|
|
589
|
-
return nil, err
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
return response, nil
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
func (c *Client) GetCardComments(ctx context.Context, cardNumber int) ([]Comment, error) {
|
|
596
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/comments", c.AccountBaseURL, cardNumber)
|
|
597
|
-
|
|
598
|
-
req, err := c.newRequest(ctx, http.MethodGet, endpointURL, nil)
|
|
599
|
-
if err != nil {
|
|
600
|
-
return nil, fmt.Errorf("failed to create get card comments request: %w", err)
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
var response []Comment
|
|
604
|
-
_, err = c.decodeResponse(req, &response)
|
|
605
|
-
if err != nil {
|
|
606
|
-
return nil, err
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
return response, nil
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
func (c *Client) GetCardComment(ctx context.Context, cardNumber int, commentID string) (*Comment, error) {
|
|
613
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/comments/%s", c.AccountBaseURL, cardNumber, commentID)
|
|
614
|
-
|
|
615
|
-
req, err := c.newRequest(ctx, http.MethodGet, endpointURL, nil)
|
|
616
|
-
if err != nil {
|
|
617
|
-
return nil, fmt.Errorf("failed to create get card comment request: %w", err)
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
var response Comment
|
|
621
|
-
_, err = c.decodeResponse(req, &response)
|
|
622
|
-
if err != nil {
|
|
623
|
-
return nil, err
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
return &response, nil
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
func (c *Client) PostCardComment(ctx context.Context, cardNumber int, body string) (*Comment, error) {
|
|
630
|
-
endpointURL := fmt.Sprintf("%s/cards/%d/comments", c.AccountBaseURL, cardNumber)
|
|
631
|
-
|
|
632
|
-
payload := map[string]map[string]string{
|
|
633
|
-
"comment": {"body": body},
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, payload)
|
|
637
|
-
if err != nil {
|
|
638
|
-
return nil, fmt.Errorf("failed to create post card comment request: %w", err)
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
var response Comment
|
|
642
|
-
_, err = c.decodeResponse(req, &response, http.StatusCreated)
|
|
643
|
-
if err != nil {
|
|
644
|
-
return nil, err
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
return &response, nil
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
type Board struct {
|
|
651
|
-
ID string `json:"id"`
|
|
652
|
-
Name string `json:"name"`
|
|
653
|
-
AllAccess bool `json:"all_access"`
|
|
654
|
-
CreatedAt string `json:"created_at"`
|
|
655
|
-
URL string `json:"url"`
|
|
656
|
-
Creator User `json:"creator"`
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
type CreateBoardPayload struct {
|
|
660
|
-
Name string `json:"name"`
|
|
661
|
-
AllAccess bool `json:"all_access"`
|
|
662
|
-
AutoPostponePeriod int `json:"auto_postpone_period"`
|
|
663
|
-
PublicDescription string `json:"public_description"`
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
type Column struct {
|
|
667
|
-
ID string `json:"id"`
|
|
668
|
-
Name string `json:"name"`
|
|
669
|
-
Color ColorObject `json:"color"`
|
|
670
|
-
CreatedAt string `json:"created_at"`
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
type ColorObject struct {
|
|
674
|
-
Name string `json:"name"`
|
|
675
|
-
Value Color `json:"value"`
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
type CreateColumnPayload struct {
|
|
679
|
-
Name string `json:"name"`
|
|
680
|
-
Color *Color `json:"color,omitempty"`
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
type Card struct {
|
|
684
|
-
ID string `json:"id"`
|
|
685
|
-
Number int `json:"number"`
|
|
686
|
-
Title string `json:"title"`
|
|
687
|
-
Status string `json:"status"`
|
|
688
|
-
Description string `json:"description"`
|
|
689
|
-
DescriptionHTML string `json:"description_html"`
|
|
690
|
-
ImageURL string `json:"image_url"`
|
|
691
|
-
Tags []string `json:"tags"`
|
|
692
|
-
Golden bool `json:"golden"`
|
|
693
|
-
LastActiveAt string `json:"last_active_at"`
|
|
694
|
-
CreatedAt string `json:"created_at"`
|
|
695
|
-
URL string `json:"url"`
|
|
696
|
-
Board Board `json:"board"`
|
|
697
|
-
Creator User `json:"creator"`
|
|
698
|
-
CommentsURL string `json:"comments_url"`
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
type CardFilters struct {
|
|
702
|
-
BoardIDs []string
|
|
703
|
-
TagIDs []string
|
|
704
|
-
AssigneeIDs []string
|
|
705
|
-
CreatorIDs []string
|
|
706
|
-
CloserIDs []string
|
|
707
|
-
CardIDs []string
|
|
708
|
-
IndexedBy string
|
|
709
|
-
SortedBy string
|
|
710
|
-
AssignmentStatus string
|
|
711
|
-
CreationStatus string
|
|
712
|
-
ClosureStatus string
|
|
713
|
-
Terms []string
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
type CreateCardPayload struct {
|
|
717
|
-
Title string `json:"title"`
|
|
718
|
-
Description string `json:"description,omitempty"`
|
|
719
|
-
Status string `json:"status,omitempty"`
|
|
720
|
-
ImageURL string `json:"image_url,omitempty"`
|
|
721
|
-
TagIDS []string `json:"tag_ids,omitempty"`
|
|
722
|
-
CreatedAt string `json:"created_at,omitempty"`
|
|
723
|
-
LastActiveAt string `json:"last_active_at,omitempty"`
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
// UpdateCardPayload image not included because we don't support files yet
|
|
727
|
-
type UpdateCardPayload struct {
|
|
728
|
-
Title string `json:"title,omitempty"`
|
|
729
|
-
Description string `json:"description,omitempty"`
|
|
730
|
-
Status string `json:"status,omitempty"`
|
|
731
|
-
TagIDS []string `json:"tag_ids,omitempty"`
|
|
732
|
-
LastActiveAt string `json:"last_active_at,omitempty"`
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
type GetMyIdentityResponse struct {
|
|
736
|
-
Accounts []Account `json:"accounts"`
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
type Account struct {
|
|
740
|
-
ID string `json:"id"`
|
|
741
|
-
Name string `json:"name"`
|
|
742
|
-
User User `json:"user"`
|
|
743
|
-
Slug string `json:"slug"`
|
|
744
|
-
CreatedAt string `json:"created_at"`
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
type User struct {
|
|
748
|
-
ID string `json:"id"`
|
|
749
|
-
Email string `json:"email_address"`
|
|
750
|
-
Role string `json:"role"`
|
|
751
|
-
Active bool `json:"active"`
|
|
752
|
-
Name string `json:"name"`
|
|
753
|
-
CreatedAt string `json:"created_at"`
|
|
754
|
-
URL string `json:"url"`
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
type Notification struct {
|
|
758
|
-
ID string `json:"id"`
|
|
759
|
-
Read bool `json:"read"`
|
|
760
|
-
ReadAt string `json:"read_at"`
|
|
761
|
-
CreatedAt string `json:"created_at"`
|
|
762
|
-
Title string `json:"title"`
|
|
763
|
-
Body string `json:"body"`
|
|
764
|
-
Creator User `json:"creator"`
|
|
765
|
-
Card CardReference `json:"card"`
|
|
766
|
-
URL string `json:"url"`
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
type CardReference struct {
|
|
770
|
-
ID string `json:"id"`
|
|
771
|
-
Title string `json:"title"`
|
|
772
|
-
Status string `json:"status"`
|
|
773
|
-
URL string `json:"url"`
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
type Tag struct {
|
|
777
|
-
ID string `json:"id"`
|
|
778
|
-
Title string `json:"title"`
|
|
779
|
-
CreatedAt string `json:"created_at"`
|
|
780
|
-
URL string `json:"url"`
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
type Comment struct {
|
|
784
|
-
ID string `json:"id"`
|
|
785
|
-
CreatedAt string `json:"created_at"`
|
|
786
|
-
UpdatedAt string `json:"updated_at"`
|
|
787
|
-
Body struct {
|
|
788
|
-
PlainText string `json:"plain_text"`
|
|
789
|
-
HTML string `json:"html"`
|
|
790
|
-
} `json:"body"`
|
|
791
|
-
Creator User `json:"creator"`
|
|
792
|
-
Card CardReference `json:"card"`
|
|
793
|
-
ReactionsURL string `json:"reactions_url"`
|
|
794
|
-
URL string `json:"url"`
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
type Color string
|
|
798
|
-
|
|
799
|
-
// Color constants using centralized definitions
|
|
800
|
-
var (
|
|
801
|
-
Blue Color = Color(colors.Blue.CSSValue)
|
|
802
|
-
Gray Color = Color(colors.Gray.CSSValue)
|
|
803
|
-
Tan Color = Color(colors.Tan.CSSValue)
|
|
804
|
-
Yellow Color = Color(colors.Yellow.CSSValue)
|
|
805
|
-
Lime Color = Color(colors.Lime.CSSValue)
|
|
806
|
-
Aqua Color = Color(colors.Aqua.CSSValue)
|
|
807
|
-
Violet Color = Color(colors.Violet.CSSValue)
|
|
808
|
-
Purple Color = Color(colors.Purple.CSSValue)
|
|
809
|
-
Pink Color = Color(colors.Pink.CSSValue)
|
|
810
|
-
)
|