summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-01-19 09:58:10 -1000
committerPeter Stone <thepeterstone@gmail.com>2026-01-19 09:58:10 -1000
commitbff78e417d2bf41e16eb1e4141bcaaa7d2d566e0 (patch)
tree5d2cff83216e8a9ee56c7ec31be253dc891db83c
parenta38abc90ee4fe00bf0fbdf897c5ef93e80e0c256 (diff)
Refactor Trello client to use url.Values for query params
Replace manual string concatenation with url.Values for cleaner, safer query parameter construction in GetBoards, GetCards, and getLists. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
-rw-r--r--internal/api/trello.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/internal/api/trello.go b/internal/api/trello.go
index be5d81b..91d6d66 100644
--- a/internal/api/trello.go
+++ b/internal/api/trello.go
@@ -64,9 +64,13 @@ type trelloListResponse struct {
// GetBoards fetches all boards for the authenticated user
func (c *TrelloClient) GetBoards(ctx context.Context) ([]models.Board, error) {
- url := fmt.Sprintf("%s/members/me/boards?key=%s&token=%s&filter=open", c.baseURL, c.apiKey, c.token)
+ params := url.Values{}
+ params.Set("key", c.apiKey)
+ params.Set("token", c.token)
+ params.Set("filter", "open")
- req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
+ reqURL := fmt.Sprintf("%s/members/me/boards?%s", c.baseURL, params.Encode())
+ req, err := http.NewRequestWithContext(ctx, "GET", reqURL, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %w", err)
}
@@ -103,9 +107,13 @@ func (c *TrelloClient) GetBoards(ctx context.Context) ([]models.Board, error) {
// GetCards fetches all cards for a specific board
func (c *TrelloClient) GetCards(ctx context.Context, boardID string) ([]models.Card, error) {
- url := fmt.Sprintf("%s/boards/%s/cards?key=%s&token=%s&filter=visible", c.baseURL, boardID, c.apiKey, c.token)
+ params := url.Values{}
+ params.Set("key", c.apiKey)
+ params.Set("token", c.token)
+ params.Set("filter", "visible")
- req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
+ reqURL := fmt.Sprintf("%s/boards/%s/cards?%s", c.baseURL, boardID, params.Encode())
+ req, err := http.NewRequestWithContext(ctx, "GET", reqURL, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %w", err)
}
@@ -163,9 +171,12 @@ func (c *TrelloClient) GetCards(ctx context.Context, boardID string) ([]models.C
// getLists fetches lists for a board
func (c *TrelloClient) getLists(ctx context.Context, boardID string) ([]models.List, error) {
- url := fmt.Sprintf("%s/boards/%s/lists?key=%s&token=%s", c.baseURL, boardID, c.apiKey, c.token)
+ params := url.Values{}
+ params.Set("key", c.apiKey)
+ params.Set("token", c.token)
- req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
+ reqURL := fmt.Sprintf("%s/boards/%s/lists?%s", c.baseURL, boardID, params.Encode())
+ req, err := http.NewRequestWithContext(ctx, "GET", reqURL, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %w", err)
}