fizzy-cli 0.2.1 → 0.3.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 +16 -0
- package/bin/fizzy +0 -0
- package/cmd/board.go +1 -1
- package/cmd/card_assign.go +55 -0
- package/cmd/card_assign_test.go +130 -0
- package/cmd/card_triage.go +46 -0
- package/cmd/card_update.go +0 -1
- package/cmd/card_update_test.go +0 -2
- package/cmd/login.go +2 -1
- package/cmd/notification.go +14 -0
- package/cmd/notification_list.go +69 -0
- package/cmd/notification_list_test.go +288 -0
- package/cmd/notification_read.go +51 -0
- package/cmd/notification_read_all.go +38 -0
- package/cmd/notification_read_all_test.go +75 -0
- package/cmd/notification_read_test.go +138 -0
- package/cmd/notification_unread.go +44 -0
- package/cmd/notification_unread_test.go +99 -0
- package/docs/API.md +144 -1
- package/go.mod +1 -1
- package/internal/api/client.go +137 -0
- package/internal/config/config.go +1 -0
- package/internal/ui/notification_list.go +27 -0
- package/package.json +1 -1
package/internal/api/client.go
CHANGED
|
@@ -307,6 +307,24 @@ func (c *Client) PostCardsClosure(ctx context.Context, cardNumber int) (bool, er
|
|
|
307
307
|
return true, nil
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
func (c *Client) PostCardTriage(ctx context.Context, cardNumber int, columnID string) (bool, error) {
|
|
311
|
+
endpointURL := fmt.Sprintf("%s/cards/%d/triage", c.AccountBaseURL, cardNumber)
|
|
312
|
+
|
|
313
|
+
body := map[string]any{"column_id": columnID}
|
|
314
|
+
|
|
315
|
+
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, body)
|
|
316
|
+
if err != nil {
|
|
317
|
+
return false, fmt.Errorf("failed to create post triage request: %w", err)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
321
|
+
if err != nil {
|
|
322
|
+
return false, err
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return true, nil
|
|
326
|
+
}
|
|
327
|
+
|
|
310
328
|
func (c *Client) DeleteCardsClosure(ctx context.Context, cardNumber int) (bool, error) {
|
|
311
329
|
endpointURL := fmt.Sprintf("%s/cards/%d/closure", c.AccountBaseURL, cardNumber)
|
|
312
330
|
|
|
@@ -323,6 +341,24 @@ func (c *Client) DeleteCardsClosure(ctx context.Context, cardNumber int) (bool,
|
|
|
323
341
|
return true, nil
|
|
324
342
|
}
|
|
325
343
|
|
|
344
|
+
func (c *Client) PostCardAssignments(ctx context.Context, cardNumber int, userID string) (bool, error) {
|
|
345
|
+
endpointURL := fmt.Sprintf("%s/cards/%d/assignments", c.AccountBaseURL, cardNumber)
|
|
346
|
+
|
|
347
|
+
body := map[string]string{"assignee_id": userID}
|
|
348
|
+
|
|
349
|
+
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, body)
|
|
350
|
+
if err != nil {
|
|
351
|
+
return false, fmt.Errorf("failed to create assignment request: %w", err)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
355
|
+
if err != nil {
|
|
356
|
+
return false, err
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return true, nil
|
|
360
|
+
}
|
|
361
|
+
|
|
326
362
|
func (c *Client) GetMyIdentity(ctx context.Context) (*GetMyIdentityResponse, error) {
|
|
327
363
|
endpointURL := c.BaseURL + "/my/identity"
|
|
328
364
|
|
|
@@ -340,6 +376,88 @@ func (c *Client) GetMyIdentity(ctx context.Context) (*GetMyIdentityResponse, err
|
|
|
340
376
|
return &response, nil
|
|
341
377
|
}
|
|
342
378
|
|
|
379
|
+
func (c *Client) GetNotifications(ctx context.Context) ([]Notification, error) {
|
|
380
|
+
endpointURL := c.AccountBaseURL + "/notifications"
|
|
381
|
+
|
|
382
|
+
req, err := c.newRequest(ctx, http.MethodGet, endpointURL, nil)
|
|
383
|
+
if err != nil {
|
|
384
|
+
return nil, fmt.Errorf("failed to create get notifications request: %w", err)
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
var response []Notification
|
|
388
|
+
_, err = c.decodeResponse(req, &response)
|
|
389
|
+
if err != nil {
|
|
390
|
+
return nil, err
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return response, nil
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
func (c *Client) GetNotification(ctx context.Context, notificationID string) (*Notification, error) {
|
|
397
|
+
endpointURL := fmt.Sprintf("%s/notifications/%s", c.AccountBaseURL, notificationID)
|
|
398
|
+
|
|
399
|
+
req, err := c.newRequest(ctx, http.MethodGet, endpointURL, nil)
|
|
400
|
+
if err != nil {
|
|
401
|
+
return nil, fmt.Errorf("failed to create get notification request: %w", err)
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
var response Notification
|
|
405
|
+
_, err = c.decodeResponse(req, &response)
|
|
406
|
+
if err != nil {
|
|
407
|
+
return nil, err
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return &response, nil
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
func (c *Client) PostNotificationReading(ctx context.Context, notificationID string) (bool, error) {
|
|
414
|
+
endpointURL := fmt.Sprintf("%s/notifications/%s/reading", c.AccountBaseURL, notificationID)
|
|
415
|
+
|
|
416
|
+
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, nil)
|
|
417
|
+
if err != nil {
|
|
418
|
+
return false, fmt.Errorf("failed to create mark notification as read request: %w", err)
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
422
|
+
if err != nil {
|
|
423
|
+
return false, err
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return true, nil
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
func (c *Client) DeleteNotificationReading(ctx context.Context, notificationID string) (bool, error) {
|
|
430
|
+
endpointURL := fmt.Sprintf("%s/notifications/%s/reading", c.AccountBaseURL, notificationID)
|
|
431
|
+
|
|
432
|
+
req, err := c.newRequest(ctx, http.MethodDelete, endpointURL, nil)
|
|
433
|
+
if err != nil {
|
|
434
|
+
return false, fmt.Errorf("failed to create delete notification request: %w", err)
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
_, err = c.decodeResponse(req, nil, http.StatusNoContent)
|
|
438
|
+
if err != nil {
|
|
439
|
+
return false, err
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
return true, nil
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
func (c *Client) PostBulkNotificationsReading(ctx context.Context) (bool, error) {
|
|
446
|
+
endpointURL := c.AccountBaseURL + "/notifications/bulk_reading"
|
|
447
|
+
|
|
448
|
+
req, err := c.newRequest(ctx, http.MethodPost, endpointURL, nil)
|
|
449
|
+
if err != nil {
|
|
450
|
+
return false, fmt.Errorf("failed to create bulk notifications reading 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
|
+
|
|
343
461
|
type Board struct {
|
|
344
462
|
ID string `json:"id"`
|
|
345
463
|
Name string `json:"name"`
|
|
@@ -447,6 +565,25 @@ type User struct {
|
|
|
447
565
|
URL string `json:"url"`
|
|
448
566
|
}
|
|
449
567
|
|
|
568
|
+
type Notification struct {
|
|
569
|
+
ID string `json:"id"`
|
|
570
|
+
Read bool `json:"read"`
|
|
571
|
+
ReadAt string `json:"read_at"`
|
|
572
|
+
CreatedAt string `json:"created_at"`
|
|
573
|
+
Title string `json:"title"`
|
|
574
|
+
Body string `json:"body"`
|
|
575
|
+
Creator User `json:"creator"`
|
|
576
|
+
Card CardReference `json:"card"`
|
|
577
|
+
URL string `json:"url"`
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
type CardReference struct {
|
|
581
|
+
ID string `json:"id"`
|
|
582
|
+
Title string `json:"title"`
|
|
583
|
+
Status string `json:"status"`
|
|
584
|
+
URL string `json:"url"`
|
|
585
|
+
}
|
|
586
|
+
|
|
450
587
|
type Color string
|
|
451
588
|
|
|
452
589
|
// Color constants using centralized definitions
|
|
@@ -16,6 +16,7 @@ const (
|
|
|
16
16
|
type Config struct {
|
|
17
17
|
SelectedAccount string `json:"selected_account"`
|
|
18
18
|
SelectedBoard string `json:"selected_board"`
|
|
19
|
+
CurrentUserID string `json:"current_user_id"`
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
// Load reads the config file from $HOME/.config/fizzy-cli/config.json.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package ui
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
|
|
6
|
+
"github.com/rogeriopvl/fizzy/internal/api"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
func DisplayNotifications(notifications []api.Notification) error {
|
|
10
|
+
for _, notification := range notifications {
|
|
11
|
+
fmt.Printf("%s (%s)\n", notification.Title, DisplayID(notification.ID))
|
|
12
|
+
}
|
|
13
|
+
return nil
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
func DisplayNotification(notification *api.Notification) error {
|
|
17
|
+
status := "read"
|
|
18
|
+
if !notification.Read {
|
|
19
|
+
status = "unread"
|
|
20
|
+
}
|
|
21
|
+
fmt.Printf("%s (%s)\n", notification.Title, DisplayID(notification.ID))
|
|
22
|
+
fmt.Printf("Status: %s\n", status)
|
|
23
|
+
fmt.Printf("Card: %s\n", notification.Card.Title)
|
|
24
|
+
fmt.Printf("From: %s\n", notification.Creator.Name)
|
|
25
|
+
fmt.Printf("Message: %s\n", notification.Body)
|
|
26
|
+
return nil
|
|
27
|
+
}
|