From 35ff956fab00cec8b22f1c612410e3b4511ab2ab Mon Sep 17 00:00:00 2001 From: Utku Ufuk Date: Thu, 11 Jun 2020 23:59:33 +0300 Subject: [PATCH] Delete stale cards instead of archiving them (#21) --- cmd/entrello/main.go | 6 +++--- internal/trello/api.go | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/entrello/main.go b/cmd/entrello/main.go index 32ae35d..d08a410 100644 --- a/cmd/entrello/main.go +++ b/cmd/entrello/main.go @@ -98,11 +98,11 @@ func processActionables(ctx context.Context, client trello.Client, q CardQueue) } logger.Printf("created new card: %s", c.Name) case c := <-q.del: - if err := client.ArchiveCard(c); err != nil { - logger.Errorf("could not archive card card: %v", err) + if err := client.DeleteCard(c); err != nil { + logger.Errorf("could not delete Trello card: %v", err) break } - logger.Printf("archived stale card: %s", c.Name) + logger.Printf("deleted stale card: %s", c.Name) case err := <-q.err: logger.Errorf("%v", err) case <-ctx.Done(): diff --git a/internal/trello/api.go b/internal/trello/api.go index 6beb6c5..d6913f8 100644 --- a/internal/trello/api.go +++ b/internal/trello/api.go @@ -6,9 +6,10 @@ import ( "github.com/adlio/trello" ) -// ArchiveCard archives a Trello card using the the Trello API -func (c Client) ArchiveCard(card Card) error { - return (*trello.Card)(card).Update(trello.Arguments{"closed": "true"}) +// DeleteCard deletes a Trello card using the the Trello API +func (c Client) DeleteCard(card Card) error { + path := fmt.Sprintf("cards/%s", card.ID) + return c.api.Delete(path, trello.Defaults(), card) } // CreateCard creates a Trello card using the the Trello API