feat: add missing endpoitn implementation
This commit is contained in:
28
client/stages.go
Normal file
28
client/stages.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/kratisto/tcgdex-golang/models"
|
||||
)
|
||||
|
||||
// Stages retrieves all Pokemon stages.
|
||||
func (s *tcgDexClient) Stages(ctx context.Context) ([]string, error) {
|
||||
request, err := http.NewRequestWithContext(ctx, http.MethodGet, s.baseURL+"/stages", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return doRequestSlice[string](s.httpClient, request)
|
||||
}
|
||||
|
||||
// GetCardsByStage retrieves all cards for a given stage.
|
||||
func (s *tcgDexClient) GetCardsByStage(ctx context.Context, stage string) ([]models.Card, error) {
|
||||
request, err := http.NewRequestWithContext(ctx, http.MethodGet, s.baseURL+"/stages/"+stage, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return doRequestSlice[models.Card](s.httpClient, request)
|
||||
}
|
||||
Reference in New Issue
Block a user