feat: add missing endpoitn implementation
This commit is contained in:
29
client/dexids.go
Normal file
29
client/dexids.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/kratisto/tcgdex-golang/models"
|
||||
)
|
||||
|
||||
// DexIDs retrieves all Pokedex IDs.
|
||||
func (s *tcgDexClient) DexIDs(ctx context.Context) ([]int, error) {
|
||||
request, err := http.NewRequestWithContext(ctx, http.MethodGet, s.baseURL+"/dex-ids", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return doRequestSlice[int](s.httpClient, request)
|
||||
}
|
||||
|
||||
// GetCardsByDexID retrieves all cards for a given Pokedex ID.
|
||||
func (s *tcgDexClient) GetCardsByDexID(ctx context.Context, dexID int) ([]models.Card, error) {
|
||||
request, err := http.NewRequestWithContext(ctx, http.MethodGet, s.baseURL+"/dex-ids/"+fmt.Sprint(dexID), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return doRequestSlice[models.Card](s.httpClient, request)
|
||||
}
|
||||
Reference in New Issue
Block a user