4 Commits

Author SHA1 Message Date
b99d06a2de u 2025-10-28 22:07:44 +11:00
4b6f488f59 feat(proto): Regenerate Go protobufs for new IGDB API types
Regenerated `proto/igdbapi.pb.go` to reflect updates in the IGDB API schema.
This update incorporates new API types, such as `AgeRatingContentDescriptionType` and its corresponding result type.

The regeneration was performed with:
- `protoc-gen-go` updated from `v1.36.5` to `v1.36.10`
- `protoc` updated from `v6.30.1` to `v6.32.1`
2025-10-28 20:12:19 +11:00
3df648929d u 2025-05-17 16:27:46 +10:00
5cb4ab4c61 u 2025-04-09 17:10:53 +10:00
81 changed files with 3050 additions and 3745 deletions

View File

@@ -1,19 +1,23 @@
package igdb package igdb
import ( import (
"context"
"fmt" "fmt"
"strings"
"github.com/bestnite/go-flaresolverr" "github.com/bestnite/go-flaresolverr"
"github.com/bestnite/go-igdb/endpoint" "github.com/bestnite/go-igdb/endpoint"
"golang.org/x/time/rate"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
) )
type Client struct { type Client struct {
clientID string clientID string
token *TwitchToken token *twitchToken
flaresolverr *flaresolverr.Flaresolverr flaresolverr *flaresolverr.Flaresolverr
limiter *rateLimiter restyClient *resty.Client
limiter *rate.Limiter
AgeRatingCategories *endpoint.AgeRatingCategories AgeRatingCategories *endpoint.AgeRatingCategories
AgeRatingContentDescriptions *endpoint.AgeRatingContentDescriptions AgeRatingContentDescriptions *endpoint.AgeRatingContentDescriptions
@@ -91,36 +95,45 @@ type Client struct {
func New(clientID, clientSecret string) *Client { func New(clientID, clientSecret string) *Client {
c := &Client{ c := &Client{
clientID: clientID, clientID: clientID,
limiter: newRateLimiter(4), restyClient: NewRestyClient(),
token: NewTwitchToken(clientID, clientSecret), token: newTwitchToken(clientID, clientSecret),
flaresolverr: nil, flaresolverr: nil,
limiter: rate.NewLimiter(rate.Limit(4), 4),
} }
registerAllEndpoints(c) registerAllEndpoints(c)
return c return c
} }
type RequestFunc func(method string, URL string, dataBody any) (*resty.Response, error)
func NewWithFlaresolverr(clientID, clientSecret string, f *flaresolverr.Flaresolverr) *Client { func NewWithFlaresolverr(clientID, clientSecret string, f *flaresolverr.Flaresolverr) *Client {
c := New(clientID, clientSecret) c := New(clientID, clientSecret)
c.flaresolverr = f c.flaresolverr = f
return c return c
} }
func (g *Client) Request(URL string, dataBody any) (*resty.Response, error) { func (g *Client) Request(ctx context.Context, method string, URL string, dataBody any) (*resty.Response, error) {
g.limiter.wait() err := g.limiter.Wait(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get rate limiter token: %w", err)
}
t, err := g.token.getToken() t, err := g.token.GetToken(ctx)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to get twitch token: %w", err) return nil, fmt.Errorf("failed to get twitch token: %w", err)
} }
resp, err := request().SetBody(dataBody).SetHeaders(map[string]string{ resp, err := g.restyClient.R().SetContext(ctx).SetBody(dataBody).SetHeaders(map[string]string{
"Client-ID": g.clientID, "Client-ID": g.clientID,
"Authorization": "Bearer " + t, "Authorization": "Bearer " + t,
"User-Agent": "", "User-Agent": "",
"Content-Type": "text/plain", "Content-Type": "text/plain",
}).Post(URL) }).Execute(strings.ToUpper(method), URL)
if resp.StatusCode() != 200 {
return nil, fmt.Errorf("failed to request, expected 200 but got: %v", resp.StatusCode())
}
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %s: %w", URL, err) return nil, fmt.Errorf("failed to request: %s: %w", URL, err)

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type AgeRatingCategories struct {
BaseEndpoint[pb.AgeRatingCategory] BaseEndpoint[pb.AgeRatingCategory]
} }
func NewAgeRatingCategories(request func(URL string, dataBody any) (*resty.Response, error)) *AgeRatingCategories { func NewAgeRatingCategories(request RequestFunc) *AgeRatingCategories {
a := &AgeRatingCategories{ a := &AgeRatingCategories{
BaseEndpoint: BaseEndpoint[pb.AgeRatingCategory]{ BaseEndpoint: BaseEndpoint[pb.AgeRatingCategory]{
endpointName: EPAgeRatingCategories, endpointName: EPAgeRatingCategories,
@@ -24,8 +24,8 @@ func NewAgeRatingCategories(request func(URL string, dataBody any) (*resty.Respo
return a return a
} }
func (a *AgeRatingCategories) Query(query string) ([]*pb.AgeRatingCategory, error) { func (a *AgeRatingCategories) Query(ctx context.Context, query string) ([]*pb.AgeRatingCategory, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type AgeRatingContentDescriptions struct {
BaseEndpoint[pb.AgeRatingContentDescription] BaseEndpoint[pb.AgeRatingContentDescription]
} }
func NewAgeRatingContentDescriptions(request func(URL string, dataBody any) (*resty.Response, error)) *AgeRatingContentDescriptions { func NewAgeRatingContentDescriptions(request RequestFunc) *AgeRatingContentDescriptions {
a := &AgeRatingContentDescriptions{ a := &AgeRatingContentDescriptions{
BaseEndpoint[pb.AgeRatingContentDescription]{ BaseEndpoint[pb.AgeRatingContentDescription]{
endpointName: EPAgeRatingContentDescriptions, endpointName: EPAgeRatingContentDescriptions,
@@ -24,8 +24,8 @@ func NewAgeRatingContentDescriptions(request func(URL string, dataBody any) (*re
return a return a
} }
func (a *AgeRatingContentDescriptions) Query(query string) ([]*pb.AgeRatingContentDescription, error) { func (a *AgeRatingContentDescriptions) Query(ctx context.Context, query string) ([]*pb.AgeRatingContentDescription, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type AgeRatingContentDescriptionsV2 struct {
BaseEndpoint[pb.AgeRatingContentDescriptionV2] BaseEndpoint[pb.AgeRatingContentDescriptionV2]
} }
func NewAgeRatingContentDescriptionsV2(request func(URL string, dataBody any) (*resty.Response, error)) *AgeRatingContentDescriptionsV2 { func NewAgeRatingContentDescriptionsV2(request RequestFunc) *AgeRatingContentDescriptionsV2 {
a := &AgeRatingContentDescriptionsV2{ a := &AgeRatingContentDescriptionsV2{
BaseEndpoint[pb.AgeRatingContentDescriptionV2]{ BaseEndpoint[pb.AgeRatingContentDescriptionV2]{
endpointName: EPAgeRatingContentDescriptionsV2, endpointName: EPAgeRatingContentDescriptionsV2,
@@ -24,8 +24,8 @@ func NewAgeRatingContentDescriptionsV2(request func(URL string, dataBody any) (*
return a return a
} }
func (a *AgeRatingContentDescriptionsV2) Query(query string) ([]*pb.AgeRatingContentDescriptionV2, error) { func (a *AgeRatingContentDescriptionsV2) Query(ctx context.Context, query string) ([]*pb.AgeRatingContentDescriptionV2, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type AgeRatingOrganizations struct {
BaseEndpoint[pb.AgeRatingOrganization] BaseEndpoint[pb.AgeRatingOrganization]
} }
func NewAgeRatingOrganizations(request func(URL string, dataBody any) (*resty.Response, error)) *AgeRatingOrganizations { func NewAgeRatingOrganizations(request RequestFunc) *AgeRatingOrganizations {
a := &AgeRatingOrganizations{ a := &AgeRatingOrganizations{
BaseEndpoint[pb.AgeRatingOrganization]{ BaseEndpoint[pb.AgeRatingOrganization]{
endpointName: EPAgeRatingOrganizations, endpointName: EPAgeRatingOrganizations,
@@ -24,8 +24,8 @@ func NewAgeRatingOrganizations(request func(URL string, dataBody any) (*resty.Re
return a return a
} }
func (a *AgeRatingOrganizations) Query(query string) ([]*pb.AgeRatingOrganization, error) { func (a *AgeRatingOrganizations) Query(ctx context.Context, query string) ([]*pb.AgeRatingOrganization, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type AgeRatings struct {
BaseEndpoint[pb.AgeRating] BaseEndpoint[pb.AgeRating]
} }
func NewAgeRatings(request func(URL string, dataBody any) (*resty.Response, error)) *AgeRatings { func NewAgeRatings(request RequestFunc) *AgeRatings {
a := &AgeRatings{ a := &AgeRatings{
BaseEndpoint[pb.AgeRating]{ BaseEndpoint[pb.AgeRating]{
endpointName: EPAgeRatings, endpointName: EPAgeRatings,
@@ -24,8 +24,8 @@ func NewAgeRatings(request func(URL string, dataBody any) (*resty.Response, erro
return a return a
} }
func (a *AgeRatings) Query(query string) ([]*pb.AgeRating, error) { func (a *AgeRatings) Query(ctx context.Context, query string) ([]*pb.AgeRating, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type AlternativeNames struct {
BaseEndpoint[pb.AlternativeName] BaseEndpoint[pb.AlternativeName]
} }
func NewAlternativeNames(request func(URL string, dataBody any) (*resty.Response, error)) *AlternativeNames { func NewAlternativeNames(request RequestFunc) *AlternativeNames {
a := &AlternativeNames{ a := &AlternativeNames{
BaseEndpoint[pb.AlternativeName]{ BaseEndpoint[pb.AlternativeName]{
endpointName: EPAlternativeNames, endpointName: EPAlternativeNames,
@@ -24,8 +24,8 @@ func NewAlternativeNames(request func(URL string, dataBody any) (*resty.Response
return a return a
} }
func (a *AlternativeNames) Query(query string) ([]*pb.AlternativeName, error) { func (a *AlternativeNames) Query(ctx context.Context, query string) ([]*pb.AlternativeName, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type Artworks struct {
BaseEndpoint[pb.Artwork] BaseEndpoint[pb.Artwork]
} }
func NewArtworks(request func(URL string, dataBody any) (*resty.Response, error)) *Artworks { func NewArtworks(request RequestFunc) *Artworks {
a := &Artworks{ a := &Artworks{
BaseEndpoint[pb.Artwork]{ BaseEndpoint[pb.Artwork]{
endpointName: EPArtworks, endpointName: EPArtworks,
@@ -24,8 +24,8 @@ func NewArtworks(request func(URL string, dataBody any) (*resty.Response, error)
return a return a
} }
func (a *Artworks) Query(query string) ([]*pb.Artwork, error) { func (a *Artworks) Query(ctx context.Context, query string) ([]*pb.Artwork, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,34 +1,38 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto"
"google.golang.org/protobuf/proto"
"strconv" "strconv"
"strings" "strings"
pb "github.com/bestnite/go-igdb/proto"
"google.golang.org/protobuf/proto"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
) )
type RequestFunc func(ctx context.Context, method string, URL string, dataBody any) (*resty.Response, error)
type BaseEndpoint[T any] struct { type BaseEndpoint[T any] struct {
request func(URL string, dataBody any) (*resty.Response, error) request RequestFunc
endpointName Name endpointName Name
queryFunc func(string) ([]*T, error) queryFunc func(context.Context, string) ([]*T, error)
} }
func (b *BaseEndpoint[T]) GetEndpointName() Name { func (b *BaseEndpoint[T]) GetEndpointName() Name {
return b.endpointName return b.endpointName
} }
func (b *BaseEndpoint[T]) Query(query string) ([]*T, error) { func (b *BaseEndpoint[T]) Query(ctx context.Context, query string) ([]*T, error) {
if b.queryFunc == nil { if b.queryFunc == nil {
return nil, fmt.Errorf("query method must be implemented by specific endpoint") return nil, fmt.Errorf("query method must be implemented by specific endpoint")
} }
return b.queryFunc(query) return b.queryFunc(ctx, query)
} }
func (b *BaseEndpoint[T]) GetByID(id uint64) (*T, error) { func (b *BaseEndpoint[T]) GetByID(ctx context.Context, id uint64) (*T, error) {
res, err := b.Query(fmt.Sprintf("where id = %d; fields *;", id)) res, err := b.Query(ctx, fmt.Sprintf("where id = %d; fields *;", id))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -38,19 +42,35 @@ func (b *BaseEndpoint[T]) GetByID(id uint64) (*T, error) {
return res[0], nil return res[0], nil
} }
func (b *BaseEndpoint[T]) GetByIDs(ids []uint64) ([]*T, error) { func (b *BaseEndpoint[T]) GetByIDs(ctx context.Context, ids []uint64) ([]*T, error) {
if len(ids) == 0 {
return nil, fmt.Errorf("ids cant be empty")
}
batches := make([][]uint64, 0)
for i := 0; i < len(ids); i += 500 {
end := min(i+500, len(ids))
batches = append(batches, ids[i:end])
}
res := []*T{}
for _, batch := range batches {
builder := strings.Builder{} builder := strings.Builder{}
for i, v := range ids { for i, v := range batch {
if i > 0 { if i > 0 {
builder.WriteByte(',') builder.WriteByte(',')
} }
builder.WriteString(strconv.FormatUint(v, 10)) builder.WriteString(strconv.FormatUint(v, 10))
} }
return b.Query(fmt.Sprintf("where id = (%s); fields *;", builder.String())) batchRes, err := b.Query(ctx, fmt.Sprintf("where id = (%s); fields *; limit 500;", builder.String()))
if err != nil {
return nil, err
}
res = append(res, batchRes...)
}
return res, nil
} }
func (b *BaseEndpoint[T]) Count() (uint64, error) { func (b *BaseEndpoint[T]) Count(ctx context.Context) (uint64, error) {
resp, err := b.request(fmt.Sprintf("https://api.igdb.com/v4/%s/count.pb", b.endpointName), "") resp, err := b.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s/count.pb", b.endpointName), "")
if err != nil { if err != nil {
return 0, fmt.Errorf("failed to request: %w", err) return 0, fmt.Errorf("failed to request: %w", err)
} }
@@ -63,15 +83,15 @@ func (b *BaseEndpoint[T]) Count() (uint64, error) {
return uint64(res.Count), nil return uint64(res.Count), nil
} }
func (b *BaseEndpoint[T]) Paginated(offset, limit uint64) ([]*T, error) { func (b *BaseEndpoint[T]) Paginated(ctx context.Context, offset, limit uint64) ([]*T, error) {
return b.Query(fmt.Sprintf("offset %d; limit %d; fields *; sort id asc;", offset, limit)) return b.Query(ctx, fmt.Sprintf("offset %d; limit %d; fields *; sort id asc;", offset, limit))
} }
type EntityEndpoint[T any] interface { type EntityEndpoint[T any] interface {
GetEndpointName() Name GetEndpointName() Name
Query(string) ([]*T, error) Query(context.Context, string) ([]*T, error)
GetByID(uint64) (*T, error) GetByID(context.Context, uint64) (*T, error)
GetByIDs([]uint64) ([]*T, error) GetByIDs(context.Context, []uint64) ([]*T, error)
Count() (uint64, error) Count(context.Context) (uint64, error)
Paginated(uint64, uint64) ([]*T, error) Paginated(context.Context, uint64, uint64) ([]*T, error)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type CharacterGenders struct {
BaseEndpoint[pb.CharacterGender] BaseEndpoint[pb.CharacterGender]
} }
func NewCharacterGenders(request func(URL string, dataBody any) (*resty.Response, error)) *CharacterGenders { func NewCharacterGenders(request RequestFunc) *CharacterGenders {
a := &CharacterGenders{ a := &CharacterGenders{
BaseEndpoint[pb.CharacterGender]{ BaseEndpoint[pb.CharacterGender]{
endpointName: EPCharacterGenders, endpointName: EPCharacterGenders,
@@ -24,8 +24,8 @@ func NewCharacterGenders(request func(URL string, dataBody any) (*resty.Response
return a return a
} }
func (a *CharacterGenders) Query(query string) ([]*pb.CharacterGender, error) { func (a *CharacterGenders) Query(ctx context.Context, query string) ([]*pb.CharacterGender, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type CharacterMugShots struct {
BaseEndpoint[pb.CharacterMugShot] BaseEndpoint[pb.CharacterMugShot]
} }
func NewCharacterMugShots(request func(URL string, dataBody any) (*resty.Response, error)) *CharacterMugShots { func NewCharacterMugShots(request RequestFunc) *CharacterMugShots {
a := &CharacterMugShots{ a := &CharacterMugShots{
BaseEndpoint[pb.CharacterMugShot]{ BaseEndpoint[pb.CharacterMugShot]{
endpointName: EPCharacterMugShots, endpointName: EPCharacterMugShots,
@@ -24,8 +24,8 @@ func NewCharacterMugShots(request func(URL string, dataBody any) (*resty.Respons
return a return a
} }
func (a *CharacterMugShots) Query(query string) ([]*pb.CharacterMugShot, error) { func (a *CharacterMugShots) Query(ctx context.Context, query string) ([]*pb.CharacterMugShot, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type CharacterSpecies struct {
BaseEndpoint[pb.CharacterSpecie] BaseEndpoint[pb.CharacterSpecie]
} }
func NewCharacterSpecies(request func(URL string, dataBody any) (*resty.Response, error)) *CharacterSpecies { func NewCharacterSpecies(request RequestFunc) *CharacterSpecies {
a := &CharacterSpecies{ a := &CharacterSpecies{
BaseEndpoint[pb.CharacterSpecie]{ BaseEndpoint[pb.CharacterSpecie]{
endpointName: EPCharacterSpecies, endpointName: EPCharacterSpecies,
@@ -24,8 +24,8 @@ func NewCharacterSpecies(request func(URL string, dataBody any) (*resty.Response
return a return a
} }
func (a *CharacterSpecies) Query(query string) ([]*pb.CharacterSpecie, error) { func (a *CharacterSpecies) Query(ctx context.Context, query string) ([]*pb.CharacterSpecie, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type Characters struct {
BaseEndpoint[pb.Character] BaseEndpoint[pb.Character]
} }
func NewCharacters(request func(URL string, dataBody any) (*resty.Response, error)) *Characters { func NewCharacters(request RequestFunc) *Characters {
a := &Characters{ a := &Characters{
BaseEndpoint[pb.Character]{ BaseEndpoint[pb.Character]{
endpointName: EPCharacters, endpointName: EPCharacters,
@@ -24,8 +24,8 @@ func NewCharacters(request func(URL string, dataBody any) (*resty.Response, erro
return a return a
} }
func (a *Characters) Query(query string) ([]*pb.Character, error) { func (a *Characters) Query(ctx context.Context, query string) ([]*pb.Character, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type CollectionMembershipTypes struct {
BaseEndpoint[pb.CollectionMembershipType] BaseEndpoint[pb.CollectionMembershipType]
} }
func NewCollectionMembershipTypes(request func(URL string, dataBody any) (*resty.Response, error)) *CollectionMembershipTypes { func NewCollectionMembershipTypes(request RequestFunc) *CollectionMembershipTypes {
a := &CollectionMembershipTypes{ a := &CollectionMembershipTypes{
BaseEndpoint[pb.CollectionMembershipType]{ BaseEndpoint[pb.CollectionMembershipType]{
endpointName: EPCollectionMembershipTypes, endpointName: EPCollectionMembershipTypes,
@@ -24,8 +24,8 @@ func NewCollectionMembershipTypes(request func(URL string, dataBody any) (*resty
return a return a
} }
func (a *CollectionMembershipTypes) Query(query string) ([]*pb.CollectionMembershipType, error) { func (a *CollectionMembershipTypes) Query(ctx context.Context, query string) ([]*pb.CollectionMembershipType, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type CollectionMemberships struct {
BaseEndpoint[pb.CollectionMembership] BaseEndpoint[pb.CollectionMembership]
} }
func NewCollectionMemberships(request func(URL string, dataBody any) (*resty.Response, error)) *CollectionMemberships { func NewCollectionMemberships(request RequestFunc) *CollectionMemberships {
a := &CollectionMemberships{ a := &CollectionMemberships{
BaseEndpoint[pb.CollectionMembership]{ BaseEndpoint[pb.CollectionMembership]{
endpointName: EPCollectionMemberships, endpointName: EPCollectionMemberships,
@@ -24,8 +24,8 @@ func NewCollectionMemberships(request func(URL string, dataBody any) (*resty.Res
return a return a
} }
func (a *CollectionMemberships) Query(query string) ([]*pb.CollectionMembership, error) { func (a *CollectionMemberships) Query(ctx context.Context, query string) ([]*pb.CollectionMembership, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type CollectionRelationTypes struct {
BaseEndpoint[pb.CollectionRelationType] BaseEndpoint[pb.CollectionRelationType]
} }
func NewCollectionRelationTypes(request func(URL string, dataBody any) (*resty.Response, error)) *CollectionRelationTypes { func NewCollectionRelationTypes(request RequestFunc) *CollectionRelationTypes {
a := &CollectionRelationTypes{ a := &CollectionRelationTypes{
BaseEndpoint[pb.CollectionRelationType]{ BaseEndpoint[pb.CollectionRelationType]{
endpointName: EPCollectionRelationTypes, endpointName: EPCollectionRelationTypes,
@@ -24,8 +24,8 @@ func NewCollectionRelationTypes(request func(URL string, dataBody any) (*resty.R
return a return a
} }
func (a *CollectionRelationTypes) Query(query string) ([]*pb.CollectionRelationType, error) { func (a *CollectionRelationTypes) Query(ctx context.Context, query string) ([]*pb.CollectionRelationType, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type CollectionRelations struct {
BaseEndpoint[pb.CollectionRelation] BaseEndpoint[pb.CollectionRelation]
} }
func NewCollectionRelations(request func(URL string, dataBody any) (*resty.Response, error)) *CollectionRelations { func NewCollectionRelations(request RequestFunc) *CollectionRelations {
a := &CollectionRelations{ a := &CollectionRelations{
BaseEndpoint[pb.CollectionRelation]{ BaseEndpoint[pb.CollectionRelation]{
endpointName: EPCollectionRelations, endpointName: EPCollectionRelations,
@@ -24,8 +24,8 @@ func NewCollectionRelations(request func(URL string, dataBody any) (*resty.Respo
return a return a
} }
func (a *CollectionRelations) Query(query string) ([]*pb.CollectionRelation, error) { func (a *CollectionRelations) Query(ctx context.Context, query string) ([]*pb.CollectionRelation, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type CollectionTypes struct {
BaseEndpoint[pb.CollectionType] BaseEndpoint[pb.CollectionType]
} }
func NewCollectionTypes(request func(URL string, dataBody any) (*resty.Response, error)) *CollectionTypes { func NewCollectionTypes(request RequestFunc) *CollectionTypes {
a := &CollectionTypes{ a := &CollectionTypes{
BaseEndpoint[pb.CollectionType]{ BaseEndpoint[pb.CollectionType]{
endpointName: EPCollectionTypes, endpointName: EPCollectionTypes,
@@ -24,8 +24,8 @@ func NewCollectionTypes(request func(URL string, dataBody any) (*resty.Response,
return a return a
} }
func (a *CollectionTypes) Query(query string) ([]*pb.CollectionType, error) { func (a *CollectionTypes) Query(ctx context.Context, query string) ([]*pb.CollectionType, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type Collections struct {
BaseEndpoint[pb.Collection] BaseEndpoint[pb.Collection]
} }
func NewCollections(request func(URL string, dataBody any) (*resty.Response, error)) *Collections { func NewCollections(request RequestFunc) *Collections {
a := &Collections{ a := &Collections{
BaseEndpoint[pb.Collection]{ BaseEndpoint[pb.Collection]{
endpointName: EPCollections, endpointName: EPCollections,
@@ -24,8 +24,8 @@ func NewCollections(request func(URL string, dataBody any) (*resty.Response, err
return a return a
} }
func (a *Collections) Query(query string) ([]*pb.Collection, error) { func (a *Collections) Query(ctx context.Context, query string) ([]*pb.Collection, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,11 +1,11 @@
package endpoint package endpoint
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -14,7 +14,7 @@ type Companies struct {
BaseEndpoint[pb.Company] BaseEndpoint[pb.Company]
} }
func NewCompanies(request func(URL string, dataBody any) (*resty.Response, error)) *Companies { func NewCompanies(request RequestFunc) *Companies {
a := &Companies{ a := &Companies{
BaseEndpoint[pb.Company]{ BaseEndpoint[pb.Company]{
endpointName: EPCompanies, endpointName: EPCompanies,
@@ -25,8 +25,8 @@ func NewCompanies(request func(URL string, dataBody any) (*resty.Response, error
return a return a
} }
func (a *Companies) Query(query string) ([]*pb.Company, error) { func (a *Companies) Query(ctx context.Context, query string) ([]*pb.Company, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type CompanyLogos struct {
BaseEndpoint[pb.CompanyLogo] BaseEndpoint[pb.CompanyLogo]
} }
func NewCompanyLogos(request func(URL string, dataBody any) (*resty.Response, error)) *CompanyLogos { func NewCompanyLogos(request RequestFunc) *CompanyLogos {
a := &CompanyLogos{ a := &CompanyLogos{
BaseEndpoint[pb.CompanyLogo]{ BaseEndpoint[pb.CompanyLogo]{
endpointName: EPCompanyLogos, endpointName: EPCompanyLogos,
@@ -24,8 +24,8 @@ func NewCompanyLogos(request func(URL string, dataBody any) (*resty.Response, er
return a return a
} }
func (a *CompanyLogos) Query(query string) ([]*pb.CompanyLogo, error) { func (a *CompanyLogos) Query(ctx context.Context, query string) ([]*pb.CompanyLogo, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type CompanyStatuses struct {
BaseEndpoint[pb.CompanyStatus] BaseEndpoint[pb.CompanyStatus]
} }
func NewCompanyStatuses(request func(URL string, dataBody any) (*resty.Response, error)) *CompanyStatuses { func NewCompanyStatuses(request RequestFunc) *CompanyStatuses {
a := &CompanyStatuses{ a := &CompanyStatuses{
BaseEndpoint[pb.CompanyStatus]{ BaseEndpoint[pb.CompanyStatus]{
endpointName: EPCompanyStatuses, endpointName: EPCompanyStatuses,
@@ -24,8 +24,8 @@ func NewCompanyStatuses(request func(URL string, dataBody any) (*resty.Response,
return a return a
} }
func (a *CompanyStatuses) Query(query string) ([]*pb.CompanyStatus, error) { func (a *CompanyStatuses) Query(ctx context.Context, query string) ([]*pb.CompanyStatus, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type CompanyWebsites struct {
BaseEndpoint[pb.CompanyWebsite] BaseEndpoint[pb.CompanyWebsite]
} }
func NewCompanyWebsites(request func(URL string, dataBody any) (*resty.Response, error)) *CompanyWebsites { func NewCompanyWebsites(request RequestFunc) *CompanyWebsites {
a := &CompanyWebsites{ a := &CompanyWebsites{
BaseEndpoint[pb.CompanyWebsite]{ BaseEndpoint[pb.CompanyWebsite]{
endpointName: EPCompanyWebsites, endpointName: EPCompanyWebsites,
@@ -24,8 +24,8 @@ func NewCompanyWebsites(request func(URL string, dataBody any) (*resty.Response,
return a return a
} }
func (a *CompanyWebsites) Query(query string) ([]*pb.CompanyWebsite, error) { func (a *CompanyWebsites) Query(ctx context.Context, query string) ([]*pb.CompanyWebsite, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type Covers struct {
BaseEndpoint[pb.Cover] BaseEndpoint[pb.Cover]
} }
func NewCovers(request func(URL string, dataBody any) (*resty.Response, error)) *Covers { func NewCovers(request RequestFunc) *Covers {
a := &Covers{ a := &Covers{
BaseEndpoint[pb.Cover]{ BaseEndpoint[pb.Cover]{
endpointName: EPCovers, endpointName: EPCovers,
@@ -24,8 +24,8 @@ func NewCovers(request func(URL string, dataBody any) (*resty.Response, error))
return a return a
} }
func (a *Covers) Query(query string) ([]*pb.Cover, error) { func (a *Covers) Query(ctx context.Context, query string) ([]*pb.Cover, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type DateFormats struct {
BaseEndpoint[pb.DateFormat] BaseEndpoint[pb.DateFormat]
} }
func NewDateFormats(request func(URL string, dataBody any) (*resty.Response, error)) *DateFormats { func NewDateFormats(request RequestFunc) *DateFormats {
a := &DateFormats{ a := &DateFormats{
BaseEndpoint[pb.DateFormat]{ BaseEndpoint[pb.DateFormat]{
endpointName: EPDateFormats, endpointName: EPDateFormats,
@@ -24,8 +24,8 @@ func NewDateFormats(request func(URL string, dataBody any) (*resty.Response, err
return a return a
} }
func (a *DateFormats) Query(query string) ([]*pb.DateFormat, error) { func (a *DateFormats) Query(ctx context.Context, query string) ([]*pb.DateFormat, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type EventLogos struct {
BaseEndpoint[pb.EventLogo] BaseEndpoint[pb.EventLogo]
} }
func NewEventLogos(request func(URL string, dataBody any) (*resty.Response, error)) *EventLogos { func NewEventLogos(request RequestFunc) *EventLogos {
a := &EventLogos{ a := &EventLogos{
BaseEndpoint[pb.EventLogo]{ BaseEndpoint[pb.EventLogo]{
endpointName: EPEventLogos, endpointName: EPEventLogos,
@@ -24,8 +24,8 @@ func NewEventLogos(request func(URL string, dataBody any) (*resty.Response, erro
return a return a
} }
func (a *EventLogos) Query(query string) ([]*pb.EventLogo, error) { func (a *EventLogos) Query(ctx context.Context, query string) ([]*pb.EventLogo, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type EventNetworks struct {
BaseEndpoint[pb.EventNetwork] BaseEndpoint[pb.EventNetwork]
} }
func NewEventNetworks(request func(URL string, dataBody any) (*resty.Response, error)) *EventNetworks { func NewEventNetworks(request RequestFunc) *EventNetworks {
a := &EventNetworks{ a := &EventNetworks{
BaseEndpoint[pb.EventNetwork]{ BaseEndpoint[pb.EventNetwork]{
endpointName: EPEventNetworks, endpointName: EPEventNetworks,
@@ -24,8 +24,8 @@ func NewEventNetworks(request func(URL string, dataBody any) (*resty.Response, e
return a return a
} }
func (a *EventNetworks) Query(query string) ([]*pb.EventNetwork, error) { func (a *EventNetworks) Query(ctx context.Context, query string) ([]*pb.EventNetwork, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type Events struct {
BaseEndpoint[pb.Event] BaseEndpoint[pb.Event]
} }
func NewEvents(request func(URL string, dataBody any) (*resty.Response, error)) *Events { func NewEvents(request RequestFunc) *Events {
a := &Events{ a := &Events{
BaseEndpoint[pb.Event]{ BaseEndpoint[pb.Event]{
endpointName: EPEvents, endpointName: EPEvents,
@@ -24,8 +24,8 @@ func NewEvents(request func(URL string, dataBody any) (*resty.Response, error))
return a return a
} }
func (a *Events) Query(query string) ([]*pb.Event, error) { func (a *Events) Query(ctx context.Context, query string) ([]*pb.Event, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type ExternalGameSources struct {
BaseEndpoint[pb.ExternalGameSource] BaseEndpoint[pb.ExternalGameSource]
} }
func NewExternalGameSources(request func(URL string, dataBody any) (*resty.Response, error)) *ExternalGameSources { func NewExternalGameSources(request RequestFunc) *ExternalGameSources {
a := &ExternalGameSources{ a := &ExternalGameSources{
BaseEndpoint[pb.ExternalGameSource]{ BaseEndpoint[pb.ExternalGameSource]{
endpointName: EPExternalGameSources, endpointName: EPExternalGameSources,
@@ -24,8 +24,8 @@ func NewExternalGameSources(request func(URL string, dataBody any) (*resty.Respo
return a return a
} }
func (a *ExternalGameSources) Query(query string) ([]*pb.ExternalGameSource, error) { func (a *ExternalGameSources) Query(ctx context.Context, query string) ([]*pb.ExternalGameSource, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type ExternalGames struct {
BaseEndpoint[pb.ExternalGame] BaseEndpoint[pb.ExternalGame]
} }
func NewExternalGames(request func(URL string, dataBody any) (*resty.Response, error)) *ExternalGames { func NewExternalGames(request RequestFunc) *ExternalGames {
a := &ExternalGames{ a := &ExternalGames{
BaseEndpoint[pb.ExternalGame]{ BaseEndpoint[pb.ExternalGame]{
endpointName: EPExternalGames, endpointName: EPExternalGames,
@@ -24,8 +24,8 @@ func NewExternalGames(request func(URL string, dataBody any) (*resty.Response, e
return a return a
} }
func (a *ExternalGames) Query(query string) ([]*pb.ExternalGame, error) { func (a *ExternalGames) Query(ctx context.Context, query string) ([]*pb.ExternalGame, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type Franchises struct {
BaseEndpoint[pb.Franchise] BaseEndpoint[pb.Franchise]
} }
func NewFranchises(request func(URL string, dataBody any) (*resty.Response, error)) *Franchises { func NewFranchises(request RequestFunc) *Franchises {
a := &Franchises{ a := &Franchises{
BaseEndpoint[pb.Franchise]{ BaseEndpoint: BaseEndpoint[pb.Franchise]{
endpointName: EPFranchises, endpointName: EPFranchises,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewFranchises(request func(URL string, dataBody any) (*resty.Response, erro
return a return a
} }
func (a *Franchises) Query(query string) ([]*pb.Franchise, error) { func (a *Franchises) Query(ctx context.Context, query string) ([]*pb.Franchise, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type GameEngineLogos struct {
BaseEndpoint[pb.GameEngineLogo] BaseEndpoint[pb.GameEngineLogo]
} }
func NewGameEngineLogos(request func(URL string, dataBody any) (*resty.Response, error)) *GameEngineLogos { func NewGameEngineLogos(request RequestFunc) *GameEngineLogos {
a := &GameEngineLogos{ a := &GameEngineLogos{
BaseEndpoint[pb.GameEngineLogo]{ BaseEndpoint[pb.GameEngineLogo]{
endpointName: EPGameEngineLogos, endpointName: EPGameEngineLogos,
@@ -24,8 +24,8 @@ func NewGameEngineLogos(request func(URL string, dataBody any) (*resty.Response,
return a return a
} }
func (a *GameEngineLogos) Query(query string) ([]*pb.GameEngineLogo, error) { func (a *GameEngineLogos) Query(ctx context.Context, query string) ([]*pb.GameEngineLogo, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type GameEngines struct {
BaseEndpoint[pb.GameEngine] BaseEndpoint[pb.GameEngine]
} }
func NewGameEngines(request func(URL string, dataBody any) (*resty.Response, error)) *GameEngines { func NewGameEngines(request RequestFunc) *GameEngines {
a := &GameEngines{ a := &GameEngines{
BaseEndpoint[pb.GameEngine]{ BaseEndpoint: BaseEndpoint[pb.GameEngine]{
endpointName: EPGameEngines, endpointName: EPGameEngines,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewGameEngines(request func(URL string, dataBody any) (*resty.Response, err
return a return a
} }
func (a *GameEngines) Query(query string) ([]*pb.GameEngine, error) { func (a *GameEngines) Query(ctx context.Context, query string) ([]*pb.GameEngine, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type GameLocalizations struct {
BaseEndpoint[pb.GameLocalization] BaseEndpoint[pb.GameLocalization]
} }
func NewGameLocalizations(request func(URL string, dataBody any) (*resty.Response, error)) *GameLocalizations { func NewGameLocalizations(request RequestFunc) *GameLocalizations {
a := &GameLocalizations{ a := &GameLocalizations{
BaseEndpoint[pb.GameLocalization]{ BaseEndpoint: BaseEndpoint[pb.GameLocalization]{
endpointName: EPGameLocalizations, endpointName: EPGameLocalizations,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewGameLocalizations(request func(URL string, dataBody any) (*resty.Respons
return a return a
} }
func (a *GameLocalizations) Query(query string) ([]*pb.GameLocalization, error) { func (a *GameLocalizations) Query(ctx context.Context, query string) ([]*pb.GameLocalization, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type GameModes struct {
BaseEndpoint[pb.GameMode] BaseEndpoint[pb.GameMode]
} }
func NewGameModes(request func(URL string, dataBody any) (*resty.Response, error)) *GameModes { func NewGameModes(request RequestFunc) *GameModes {
a := &GameModes{ a := &GameModes{
BaseEndpoint[pb.GameMode]{ BaseEndpoint: BaseEndpoint[pb.GameMode]{
endpointName: EPGameModes, endpointName: EPGameModes,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewGameModes(request func(URL string, dataBody any) (*resty.Response, error
return a return a
} }
func (a *GameModes) Query(query string) ([]*pb.GameMode, error) { func (a *GameModes) Query(ctx context.Context, query string) ([]*pb.GameMode, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type GameReleaseFormats struct {
BaseEndpoint[pb.GameReleaseFormat] BaseEndpoint[pb.GameReleaseFormat]
} }
func NewGameReleaseFormats(request func(URL string, dataBody any) (*resty.Response, error)) *GameReleaseFormats { func NewGameReleaseFormats(request RequestFunc) *GameReleaseFormats {
a := &GameReleaseFormats{ a := &GameReleaseFormats{
BaseEndpoint[pb.GameReleaseFormat]{ BaseEndpoint: BaseEndpoint[pb.GameReleaseFormat]{
endpointName: EPGameReleaseFormats, endpointName: EPGameReleaseFormats,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewGameReleaseFormats(request func(URL string, dataBody any) (*resty.Respon
return a return a
} }
func (a *GameReleaseFormats) Query(query string) ([]*pb.GameReleaseFormat, error) { func (a *GameReleaseFormats) Query(ctx context.Context, query string) ([]*pb.GameReleaseFormat, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type GameStatuses struct {
BaseEndpoint[pb.GameStatus] BaseEndpoint[pb.GameStatus]
} }
func NewGameStatuses(request func(URL string, dataBody any) (*resty.Response, error)) *GameStatuses { func NewGameStatuses(request RequestFunc) *GameStatuses {
a := &GameStatuses{ a := &GameStatuses{
BaseEndpoint[pb.GameStatus]{ BaseEndpoint: BaseEndpoint[pb.GameStatus]{
endpointName: EPGameStatuses, endpointName: EPGameStatuses,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewGameStatuses(request func(URL string, dataBody any) (*resty.Response, er
return a return a
} }
func (a *GameStatuses) Query(query string) ([]*pb.GameStatus, error) { func (a *GameStatuses) Query(ctx context.Context, query string) ([]*pb.GameStatus, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type GameTimeToBeats struct {
BaseEndpoint[pb.GameTimeToBeat] BaseEndpoint[pb.GameTimeToBeat]
} }
func NewGameTimeToBeats(request func(URL string, dataBody any) (*resty.Response, error)) *GameTimeToBeats { func NewGameTimeToBeats(request RequestFunc) *GameTimeToBeats {
a := &GameTimeToBeats{ a := &GameTimeToBeats{
BaseEndpoint[pb.GameTimeToBeat]{ BaseEndpoint: BaseEndpoint[pb.GameTimeToBeat]{
endpointName: EPGameTimeToBeats, endpointName: EPGameTimeToBeats,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewGameTimeToBeats(request func(URL string, dataBody any) (*resty.Response,
return a return a
} }
func (a *GameTimeToBeats) Query(query string) ([]*pb.GameTimeToBeat, error) { func (a *GameTimeToBeats) Query(ctx context.Context, query string) ([]*pb.GameTimeToBeat, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type GameTypes struct {
BaseEndpoint[pb.GameType] BaseEndpoint[pb.GameType]
} }
func NewGameTypes(request func(URL string, dataBody any) (*resty.Response, error)) *GameTypes { func NewGameTypes(request RequestFunc) *GameTypes {
a := &GameTypes{ a := &GameTypes{
BaseEndpoint[pb.GameType]{ BaseEndpoint: BaseEndpoint[pb.GameType]{
endpointName: EPGameTypes, endpointName: EPGameTypes,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewGameTypes(request func(URL string, dataBody any) (*resty.Response, error
return a return a
} }
func (a *GameTypes) Query(query string) ([]*pb.GameType, error) { func (a *GameTypes) Query(ctx context.Context, query string) ([]*pb.GameType, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type GameVersionFeatureValues struct {
BaseEndpoint[pb.GameVersionFeatureValue] BaseEndpoint[pb.GameVersionFeatureValue]
} }
func NewGameVersionFeatureValues(request func(URL string, dataBody any) (*resty.Response, error)) *GameVersionFeatureValues { func NewGameVersionFeatureValues(request RequestFunc) *GameVersionFeatureValues {
a := &GameVersionFeatureValues{ a := &GameVersionFeatureValues{
BaseEndpoint[pb.GameVersionFeatureValue]{ BaseEndpoint: BaseEndpoint[pb.GameVersionFeatureValue]{
endpointName: EPGameVersionFeatureValues, endpointName: EPGameVersionFeatureValues,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewGameVersionFeatureValues(request func(URL string, dataBody any) (*resty.
return a return a
} }
func (a *GameVersionFeatureValues) Query(query string) ([]*pb.GameVersionFeatureValue, error) { func (a *GameVersionFeatureValues) Query(ctx context.Context, query string) ([]*pb.GameVersionFeatureValue, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type GameVersionFeatures struct {
BaseEndpoint[pb.GameVersionFeature] BaseEndpoint[pb.GameVersionFeature]
} }
func NewGameVersionFeatures(request func(URL string, dataBody any) (*resty.Response, error)) *GameVersionFeatures { func NewGameVersionFeatures(request RequestFunc) *GameVersionFeatures {
a := &GameVersionFeatures{ a := &GameVersionFeatures{
BaseEndpoint[pb.GameVersionFeature]{ BaseEndpoint: BaseEndpoint[pb.GameVersionFeature]{
endpointName: EPGameVersionFeatures, endpointName: EPGameVersionFeatures,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewGameVersionFeatures(request func(URL string, dataBody any) (*resty.Respo
return a return a
} }
func (a *GameVersionFeatures) Query(query string) ([]*pb.GameVersionFeature, error) { func (a *GameVersionFeatures) Query(ctx context.Context, query string) ([]*pb.GameVersionFeature, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type GameVersions struct {
BaseEndpoint[pb.GameVersion] BaseEndpoint[pb.GameVersion]
} }
func NewGameVersions(request func(URL string, dataBody any) (*resty.Response, error)) *GameVersions { func NewGameVersions(request RequestFunc) *GameVersions {
a := &GameVersions{ a := &GameVersions{
BaseEndpoint[pb.GameVersion]{ BaseEndpoint: BaseEndpoint[pb.GameVersion]{
endpointName: EPGameVersions, endpointName: EPGameVersions,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewGameVersions(request func(URL string, dataBody any) (*resty.Response, er
return a return a
} }
func (a *GameVersions) Query(query string) ([]*pb.GameVersion, error) { func (a *GameVersions) Query(ctx context.Context, query string) ([]*pb.GameVersion, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type GameVideos struct {
BaseEndpoint[pb.GameVideo] BaseEndpoint[pb.GameVideo]
} }
func NewGameVideos(request func(URL string, dataBody any) (*resty.Response, error)) *GameVideos { func NewGameVideos(request RequestFunc) *GameVideos {
a := &GameVideos{ a := &GameVideos{
BaseEndpoint[pb.GameVideo]{ BaseEndpoint: BaseEndpoint[pb.GameVideo]{
endpointName: EPGameVideos, endpointName: EPGameVideos,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewGameVideos(request func(URL string, dataBody any) (*resty.Response, erro
return a return a
} }
func (a *GameVideos) Query(query string) ([]*pb.GameVideo, error) { func (a *GameVideos) Query(ctx context.Context, query string) ([]*pb.GameVideo, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type Games struct {
BaseEndpoint[pb.Game] BaseEndpoint[pb.Game]
} }
func NewGames(request func(URL string, dataBody any) (*resty.Response, error)) *Games { func NewGames(request RequestFunc) *Games {
a := &Games{ a := &Games{
BaseEndpoint[pb.Game]{ BaseEndpoint: BaseEndpoint[pb.Game]{
endpointName: EPGames, endpointName: EPGames,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewGames(request func(URL string, dataBody any) (*resty.Response, error)) *
return a return a
} }
func (a *Games) Query(query string) ([]*pb.Game, error) { func (a *Games) Query(ctx context.Context, query string) ([]*pb.Game, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type Genres struct {
BaseEndpoint[pb.Genre] BaseEndpoint[pb.Genre]
} }
func NewGenres(request func(URL string, dataBody any) (*resty.Response, error)) *Genres { func NewGenres(request RequestFunc) *Genres {
a := &Genres{ a := &Genres{
BaseEndpoint[pb.Genre]{ BaseEndpoint: BaseEndpoint[pb.Genre]{
endpointName: EPGenres, endpointName: EPGenres,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewGenres(request func(URL string, dataBody any) (*resty.Response, error))
return a return a
} }
func (a *Genres) Query(query string) ([]*pb.Genre, error) { func (a *Genres) Query(ctx context.Context, query string) ([]*pb.Genre, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type InvolvedCompanies struct {
BaseEndpoint[pb.InvolvedCompany] BaseEndpoint[pb.InvolvedCompany]
} }
func NewInvolvedCompanies(request func(URL string, dataBody any) (*resty.Response, error)) *InvolvedCompanies { func NewInvolvedCompanies(request RequestFunc) *InvolvedCompanies {
a := &InvolvedCompanies{ a := &InvolvedCompanies{
BaseEndpoint[pb.InvolvedCompany]{ BaseEndpoint: BaseEndpoint[pb.InvolvedCompany]{
endpointName: EPInvolvedCompanies, endpointName: EPInvolvedCompanies,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewInvolvedCompanies(request func(URL string, dataBody any) (*resty.Respons
return a return a
} }
func (a *InvolvedCompanies) Query(query string) ([]*pb.InvolvedCompany, error) { func (a *InvolvedCompanies) Query(ctx context.Context, query string) ([]*pb.InvolvedCompany, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type Keywords struct {
BaseEndpoint[pb.Keyword] BaseEndpoint[pb.Keyword]
} }
func NewKeywords(request func(URL string, dataBody any) (*resty.Response, error)) *Keywords { func NewKeywords(request RequestFunc) *Keywords {
a := &Keywords{ a := &Keywords{
BaseEndpoint[pb.Keyword]{ BaseEndpoint: BaseEndpoint[pb.Keyword]{
endpointName: EPKeywords, endpointName: EPKeywords,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewKeywords(request func(URL string, dataBody any) (*resty.Response, error)
return a return a
} }
func (a *Keywords) Query(query string) ([]*pb.Keyword, error) { func (a *Keywords) Query(ctx context.Context, query string) ([]*pb.Keyword, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type LanguageSupportTypes struct {
BaseEndpoint[pb.LanguageSupportType] BaseEndpoint[pb.LanguageSupportType]
} }
func NewLanguageSupportTypes(request func(URL string, dataBody any) (*resty.Response, error)) *LanguageSupportTypes { func NewLanguageSupportTypes(request RequestFunc) *LanguageSupportTypes {
a := &LanguageSupportTypes{ a := &LanguageSupportTypes{
BaseEndpoint[pb.LanguageSupportType]{ BaseEndpoint[pb.LanguageSupportType]{
endpointName: EPLanguageSupportTypes, endpointName: EPLanguageSupportTypes,
@@ -24,8 +24,8 @@ func NewLanguageSupportTypes(request func(URL string, dataBody any) (*resty.Resp
return a return a
} }
func (a *LanguageSupportTypes) Query(query string) ([]*pb.LanguageSupportType, error) { func (a *LanguageSupportTypes) Query(ctx context.Context, query string) ([]*pb.LanguageSupportType, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type LanguageSupports struct {
BaseEndpoint[pb.LanguageSupport] BaseEndpoint[pb.LanguageSupport]
} }
func NewLanguageSupports(request func(URL string, dataBody any) (*resty.Response, error)) *LanguageSupports { func NewLanguageSupports(request RequestFunc) *LanguageSupports {
a := &LanguageSupports{ a := &LanguageSupports{
BaseEndpoint[pb.LanguageSupport]{ BaseEndpoint: BaseEndpoint[pb.LanguageSupport]{
endpointName: EPLanguageSupports, endpointName: EPLanguageSupports,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewLanguageSupports(request func(URL string, dataBody any) (*resty.Response
return a return a
} }
func (a *LanguageSupports) Query(query string) ([]*pb.LanguageSupport, error) { func (a *LanguageSupports) Query(ctx context.Context, query string) ([]*pb.LanguageSupport, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type Languages struct {
BaseEndpoint[pb.Language] BaseEndpoint[pb.Language]
} }
func NewLanguages(request func(URL string, dataBody any) (*resty.Response, error)) *Languages { func NewLanguages(request RequestFunc) *Languages {
a := &Languages{ a := &Languages{
BaseEndpoint[pb.Language]{ BaseEndpoint: BaseEndpoint[pb.Language]{
endpointName: EPLanguages, endpointName: EPLanguages,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewLanguages(request func(URL string, dataBody any) (*resty.Response, error
return a return a
} }
func (a *Languages) Query(query string) ([]*pb.Language, error) { func (a *Languages) Query(ctx context.Context, query string) ([]*pb.Language, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type MultiplayerModes struct {
BaseEndpoint[pb.MultiplayerMode] BaseEndpoint[pb.MultiplayerMode]
} }
func NewMultiplayerModes(request func(URL string, dataBody any) (*resty.Response, error)) *MultiplayerModes { func NewMultiplayerModes(request RequestFunc) *MultiplayerModes {
a := &MultiplayerModes{ a := &MultiplayerModes{
BaseEndpoint[pb.MultiplayerMode]{ BaseEndpoint: BaseEndpoint[pb.MultiplayerMode]{
endpointName: EPMultiplayerModes, endpointName: EPMultiplayerModes,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewMultiplayerModes(request func(URL string, dataBody any) (*resty.Response
return a return a
} }
func (a *MultiplayerModes) Query(query string) ([]*pb.MultiplayerMode, error) { func (a *MultiplayerModes) Query(ctx context.Context, query string) ([]*pb.MultiplayerMode, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type NetworkTypes struct {
BaseEndpoint[pb.NetworkType] BaseEndpoint[pb.NetworkType]
} }
func NewNetworkTypes(request func(URL string, dataBody any) (*resty.Response, error)) *NetworkTypes { func NewNetworkTypes(request RequestFunc) *NetworkTypes {
a := &NetworkTypes{ a := &NetworkTypes{
BaseEndpoint[pb.NetworkType]{ BaseEndpoint: BaseEndpoint[pb.NetworkType]{
endpointName: EPNetworkTypes, endpointName: EPNetworkTypes,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewNetworkTypes(request func(URL string, dataBody any) (*resty.Response, er
return a return a
} }
func (a *NetworkTypes) Query(query string) ([]*pb.NetworkType, error) { func (a *NetworkTypes) Query(ctx context.Context, query string) ([]*pb.NetworkType, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type PlatformFamilies struct {
BaseEndpoint[pb.PlatformFamily] BaseEndpoint[pb.PlatformFamily]
} }
func NewPlatformFamilies(request func(URL string, dataBody any) (*resty.Response, error)) *PlatformFamilies { func NewPlatformFamilies(request RequestFunc) *PlatformFamilies {
a := &PlatformFamilies{ a := &PlatformFamilies{
BaseEndpoint[pb.PlatformFamily]{ BaseEndpoint: BaseEndpoint[pb.PlatformFamily]{
endpointName: EPPlatformFamilies, endpointName: EPPlatformFamilies,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewPlatformFamilies(request func(URL string, dataBody any) (*resty.Response
return a return a
} }
func (a *PlatformFamilies) Query(query string) ([]*pb.PlatformFamily, error) { func (a *PlatformFamilies) Query(ctx context.Context, query string) ([]*pb.PlatformFamily, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type PlatformLogos struct {
BaseEndpoint[pb.PlatformLogo] BaseEndpoint[pb.PlatformLogo]
} }
func NewPlatformLogos(request func(URL string, dataBody any) (*resty.Response, error)) *PlatformLogos { func NewPlatformLogos(request RequestFunc) *PlatformLogos {
a := &PlatformLogos{ a := &PlatformLogos{
BaseEndpoint[pb.PlatformLogo]{ BaseEndpoint: BaseEndpoint[pb.PlatformLogo]{
endpointName: EPPlatformLogos, endpointName: EPPlatformLogos,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewPlatformLogos(request func(URL string, dataBody any) (*resty.Response, e
return a return a
} }
func (a *PlatformLogos) Query(query string) ([]*pb.PlatformLogo, error) { func (a *PlatformLogos) Query(ctx context.Context, query string) ([]*pb.PlatformLogo, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type PlatformTypes struct {
BaseEndpoint[pb.PlatformType] BaseEndpoint[pb.PlatformType]
} }
func NewPlatformTypes(request func(URL string, dataBody any) (*resty.Response, error)) *PlatformTypes { func NewPlatformTypes(request RequestFunc) *PlatformTypes {
a := &PlatformTypes{ a := &PlatformTypes{
BaseEndpoint[pb.PlatformType]{ BaseEndpoint: BaseEndpoint[pb.PlatformType]{
endpointName: EPPlatformTypes, endpointName: EPPlatformTypes,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewPlatformTypes(request func(URL string, dataBody any) (*resty.Response, e
return a return a
} }
func (a *PlatformTypes) Query(query string) ([]*pb.PlatformType, error) { func (a *PlatformTypes) Query(ctx context.Context, query string) ([]*pb.PlatformType, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type PlatformVersionCompanies struct {
BaseEndpoint[pb.PlatformVersionCompany] BaseEndpoint[pb.PlatformVersionCompany]
} }
func NewPlatformVersionCompanies(request func(URL string, dataBody any) (*resty.Response, error)) *PlatformVersionCompanies { func NewPlatformVersionCompanies(request RequestFunc) *PlatformVersionCompanies {
a := &PlatformVersionCompanies{ a := &PlatformVersionCompanies{
BaseEndpoint[pb.PlatformVersionCompany]{ BaseEndpoint: BaseEndpoint[pb.PlatformVersionCompany]{
endpointName: EPPlatformVersionCompanies, endpointName: EPPlatformVersionCompanies,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewPlatformVersionCompanies(request func(URL string, dataBody any) (*resty.
return a return a
} }
func (a *PlatformVersionCompanies) Query(query string) ([]*pb.PlatformVersionCompany, error) { func (a *PlatformVersionCompanies) Query(ctx context.Context, query string) ([]*pb.PlatformVersionCompany, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type PlatformVersionReleaseDates struct {
BaseEndpoint[pb.PlatformVersionReleaseDate] BaseEndpoint[pb.PlatformVersionReleaseDate]
} }
func NewPlatformVersionReleaseDates(request func(URL string, dataBody any) (*resty.Response, error)) *PlatformVersionReleaseDates { func NewPlatformVersionReleaseDates(request RequestFunc) *PlatformVersionReleaseDates {
a := &PlatformVersionReleaseDates{ a := &PlatformVersionReleaseDates{
BaseEndpoint[pb.PlatformVersionReleaseDate]{ BaseEndpoint: BaseEndpoint[pb.PlatformVersionReleaseDate]{
endpointName: EPPlatformVersionReleaseDates, endpointName: EPPlatformVersionReleaseDates,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewPlatformVersionReleaseDates(request func(URL string, dataBody any) (*res
return a return a
} }
func (a *PlatformVersionReleaseDates) Query(query string) ([]*pb.PlatformVersionReleaseDate, error) { func (a *PlatformVersionReleaseDates) Query(ctx context.Context, query string) ([]*pb.PlatformVersionReleaseDate, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type PlatformVersions struct {
BaseEndpoint[pb.PlatformVersion] BaseEndpoint[pb.PlatformVersion]
} }
func NewPlatformVersions(request func(URL string, dataBody any) (*resty.Response, error)) *PlatformVersions { func NewPlatformVersions(request RequestFunc) *PlatformVersions {
a := &PlatformVersions{ a := &PlatformVersions{
BaseEndpoint[pb.PlatformVersion]{ BaseEndpoint: BaseEndpoint[pb.PlatformVersion]{
endpointName: EPPlatformVersions, endpointName: EPPlatformVersions,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewPlatformVersions(request func(URL string, dataBody any) (*resty.Response
return a return a
} }
func (a *PlatformVersions) Query(query string) ([]*pb.PlatformVersion, error) { func (a *PlatformVersions) Query(ctx context.Context, query string) ([]*pb.PlatformVersion, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type PlatformWebsites struct {
BaseEndpoint[pb.PlatformWebsite] BaseEndpoint[pb.PlatformWebsite]
} }
func NewPlatformWebsites(request func(URL string, dataBody any) (*resty.Response, error)) *PlatformWebsites { func NewPlatformWebsites(request RequestFunc) *PlatformWebsites {
a := &PlatformWebsites{ a := &PlatformWebsites{
BaseEndpoint[pb.PlatformWebsite]{ BaseEndpoint: BaseEndpoint[pb.PlatformWebsite]{
endpointName: EPPlatformWebsites, endpointName: EPPlatformWebsites,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewPlatformWebsites(request func(URL string, dataBody any) (*resty.Response
return a return a
} }
func (a *PlatformWebsites) Query(query string) ([]*pb.PlatformWebsite, error) { func (a *PlatformWebsites) Query(ctx context.Context, query string) ([]*pb.PlatformWebsite, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type Platforms struct {
BaseEndpoint[pb.Platform] BaseEndpoint[pb.Platform]
} }
func NewPlatforms(request func(URL string, dataBody any) (*resty.Response, error)) *Platforms { func NewPlatforms(request RequestFunc) *Platforms {
a := &Platforms{ a := &Platforms{
BaseEndpoint[pb.Platform]{ BaseEndpoint[pb.Platform]{
endpointName: EPPlatforms, endpointName: EPPlatforms,
@@ -24,8 +24,8 @@ func NewPlatforms(request func(URL string, dataBody any) (*resty.Response, error
return a return a
} }
func (a *Platforms) Query(query string) ([]*pb.Platform, error) { func (a *Platforms) Query(ctx context.Context, query string) ([]*pb.Platform, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type PlayerPerspectives struct {
BaseEndpoint[pb.PlayerPerspective] BaseEndpoint[pb.PlayerPerspective]
} }
func NewPlayerPerspectives(request func(URL string, dataBody any) (*resty.Response, error)) *PlayerPerspectives { func NewPlayerPerspectives(request RequestFunc) *PlayerPerspectives {
a := &PlayerPerspectives{ a := &PlayerPerspectives{
BaseEndpoint[pb.PlayerPerspective]{ BaseEndpoint: BaseEndpoint[pb.PlayerPerspective]{
endpointName: EPPlayerPerspectives, endpointName: EPPlayerPerspectives,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewPlayerPerspectives(request func(URL string, dataBody any) (*resty.Respon
return a return a
} }
func (a *PlayerPerspectives) Query(query string) ([]*pb.PlayerPerspective, error) { func (a *PlayerPerspectives) Query(ctx context.Context, query string) ([]*pb.PlayerPerspective, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,7 +13,7 @@ type PopularityPrimitives struct {
BaseEndpoint[pb.PopularityPrimitive] BaseEndpoint[pb.PopularityPrimitive]
} }
func NewPopularityPrimitives(request func(URL string, dataBody any) (*resty.Response, error)) *PopularityPrimitives { func NewPopularityPrimitives(request RequestFunc) *PopularityPrimitives {
a := &PopularityPrimitives{ a := &PopularityPrimitives{
BaseEndpoint[pb.PopularityPrimitive]{ BaseEndpoint[pb.PopularityPrimitive]{
endpointName: EPPopularityPrimitives, endpointName: EPPopularityPrimitives,
@@ -24,8 +24,8 @@ func NewPopularityPrimitives(request func(URL string, dataBody any) (*resty.Resp
return a return a
} }
func (a *PopularityPrimitives) Query(query string) ([]*pb.PopularityPrimitive, error) { func (a *PopularityPrimitives) Query(ctx context.Context, query string) ([]*pb.PopularityPrimitive, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type PopularityTypes struct {
BaseEndpoint[pb.PopularityType] BaseEndpoint[pb.PopularityType]
} }
func NewPopularityTypes(request func(URL string, dataBody any) (*resty.Response, error)) *PopularityTypes { func NewPopularityTypes(request RequestFunc) *PopularityTypes {
a := &PopularityTypes{ a := &PopularityTypes{
BaseEndpoint[pb.PopularityType]{ BaseEndpoint: BaseEndpoint[pb.PopularityType]{
endpointName: EPPopularityTypes, endpointName: EPPopularityTypes,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewPopularityTypes(request func(URL string, dataBody any) (*resty.Response,
return a return a
} }
func (a *PopularityTypes) Query(query string) ([]*pb.PopularityType, error) { func (a *PopularityTypes) Query(ctx context.Context, query string) ([]*pb.PopularityType, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type Regions struct {
BaseEndpoint[pb.Region] BaseEndpoint[pb.Region]
} }
func NewRegions(request func(URL string, dataBody any) (*resty.Response, error)) *Regions { func NewRegions(request RequestFunc) *Regions {
a := &Regions{ a := &Regions{
BaseEndpoint[pb.Region]{ BaseEndpoint: BaseEndpoint[pb.Region]{
endpointName: EPRegions, endpointName: EPRegions,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewRegions(request func(URL string, dataBody any) (*resty.Response, error))
return a return a
} }
func (a *Regions) Query(query string) ([]*pb.Region, error) { func (a *Regions) Query(ctx context.Context, query string) ([]*pb.Region, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type ReleaseDateRegions struct {
BaseEndpoint[pb.ReleaseDateRegion] BaseEndpoint[pb.ReleaseDateRegion]
} }
func NewReleaseDateRegions(request func(URL string, dataBody any) (*resty.Response, error)) *ReleaseDateRegions { func NewReleaseDateRegions(request RequestFunc) *ReleaseDateRegions {
a := &ReleaseDateRegions{ a := &ReleaseDateRegions{
BaseEndpoint[pb.ReleaseDateRegion]{ BaseEndpoint: BaseEndpoint[pb.ReleaseDateRegion]{
endpointName: EPReleaseDateRegions, endpointName: EPReleaseDateRegions,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewReleaseDateRegions(request func(URL string, dataBody any) (*resty.Respon
return a return a
} }
func (a *ReleaseDateRegions) Query(query string) ([]*pb.ReleaseDateRegion, error) { func (a *ReleaseDateRegions) Query(ctx context.Context, query string) ([]*pb.ReleaseDateRegion, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type ReleaseDateStatuses struct {
BaseEndpoint[pb.ReleaseDateStatus] BaseEndpoint[pb.ReleaseDateStatus]
} }
func NewReleaseDateStatuses(request func(URL string, dataBody any) (*resty.Response, error)) *ReleaseDateStatuses { func NewReleaseDateStatuses(request RequestFunc) *ReleaseDateStatuses {
a := &ReleaseDateStatuses{ a := &ReleaseDateStatuses{
BaseEndpoint[pb.ReleaseDateStatus]{ BaseEndpoint: BaseEndpoint[pb.ReleaseDateStatus]{
endpointName: EPReleaseDateStatuses, endpointName: EPReleaseDateStatuses,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewReleaseDateStatuses(request func(URL string, dataBody any) (*resty.Respo
return a return a
} }
func (a *ReleaseDateStatuses) Query(query string) ([]*pb.ReleaseDateStatus, error) { func (a *ReleaseDateStatuses) Query(ctx context.Context, query string) ([]*pb.ReleaseDateStatus, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type ReleaseDates struct {
BaseEndpoint[pb.ReleaseDate] BaseEndpoint[pb.ReleaseDate]
} }
func NewReleaseDates(request func(URL string, dataBody any) (*resty.Response, error)) *ReleaseDates { func NewReleaseDates(request RequestFunc) *ReleaseDates {
a := &ReleaseDates{ a := &ReleaseDates{
BaseEndpoint[pb.ReleaseDate]{ BaseEndpoint: BaseEndpoint[pb.ReleaseDate]{
endpointName: EPReleaseDates, endpointName: EPReleaseDates,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewReleaseDates(request func(URL string, dataBody any) (*resty.Response, er
return a return a
} }
func (a *ReleaseDates) Query(query string) ([]*pb.ReleaseDate, error) { func (a *ReleaseDates) Query(ctx context.Context, query string) ([]*pb.ReleaseDate, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type Screenshots struct {
BaseEndpoint[pb.Screenshot] BaseEndpoint[pb.Screenshot]
} }
func NewScreenshots(request func(URL string, dataBody any) (*resty.Response, error)) *Screenshots { func NewScreenshots(request RequestFunc) *Screenshots {
a := &Screenshots{ a := &Screenshots{
BaseEndpoint[pb.Screenshot]{ BaseEndpoint: BaseEndpoint[pb.Screenshot]{
endpointName: EPScreenshots, endpointName: EPScreenshots,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewScreenshots(request func(URL string, dataBody any) (*resty.Response, err
return a return a
} }
func (a *Screenshots) Query(query string) ([]*pb.Screenshot, error) { func (a *Screenshots) Query(ctx context.Context, query string) ([]*pb.Screenshot, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,6 +1,7 @@
package endpoint package endpoint
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
@@ -10,7 +11,6 @@ import (
"time" "time"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"github.com/PuerkitoBio/goquery" "github.com/PuerkitoBio/goquery"
"github.com/bestnite/go-flaresolverr" "github.com/bestnite/go-flaresolverr"
@@ -24,19 +24,19 @@ var webSearchCFCookies struct {
type Search struct { type Search struct {
endpointName Name endpointName Name
request func(URL string, dataBody any) (*resty.Response, error) request RequestFunc
flaresolverr *flaresolverr.Flaresolverr flaresolverr *flaresolverr.Flaresolverr
} }
func NewSearch(request func(URL string, dataBody any) (*resty.Response, error)) *Search { func NewSearch(request RequestFunc) *Search {
return &Search{ return &Search{
endpointName: EPSearch, endpointName: EPSearch,
request: request, request: request,
} }
} }
func (a *Search) Search(query string) ([]*pb.Search, error) { func (a *Search) Search(ctx context.Context, query string) ([]*pb.Search, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type Themes struct {
BaseEndpoint[pb.Theme] BaseEndpoint[pb.Theme]
} }
func NewThemes(request func(URL string, dataBody any) (*resty.Response, error)) *Themes { func NewThemes(request RequestFunc) *Themes {
a := &Themes{ a := &Themes{
BaseEndpoint[pb.Theme]{ BaseEndpoint: BaseEndpoint[pb.Theme]{
endpointName: EPThemes, endpointName: EPThemes,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewThemes(request func(URL string, dataBody any) (*resty.Response, error))
return a return a
} }
func (a *Themes) Query(query string) ([]*pb.Theme, error) { func (a *Themes) Query(ctx context.Context, query string) ([]*pb.Theme, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,36 +1,104 @@
package endpoint package endpoint
import ( import (
"context"
"encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"net/url" "net/url"
"github.com/go-resty/resty/v2"
) )
type Webhooks struct { type Webhooks struct {
request func(URL string, dataBody any) (*resty.Response, error) request RequestFunc
} }
func NewWebhooks(request func(URL string, dataBody any) (*resty.Response, error)) *Webhooks { func NewWebhooks(request RequestFunc) *Webhooks {
return &Webhooks{ return &Webhooks{
request: request, request: request,
} }
} }
func (a *Webhooks) Register(endpoint Name, secret, callbackUrl string) error { type WebhookMethod string
const (
WebhookMethodUpdate WebhookMethod = "update"
WebhookMethodDelete WebhookMethod = "delete"
WebhookMethodCreate WebhookMethod = "create"
)
type WebhookResponse struct {
Id uint64 `json:"id"`
Url string `json:"url"`
Category uint64 `json:"category"`
SubCategory uint64 `json:"sub_category"`
Active bool `json:"active"`
ApiKey string `json:"api_key"`
Secret string `json:"secret"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
func (a *Webhooks) Register(ctx context.Context, endpoint Name, secret, callbackUrl string, method WebhookMethod) (*WebhookResponse, error) {
dataBody := url.Values{} dataBody := url.Values{}
dataBody.Set("url", callbackUrl) dataBody.Set("url", callbackUrl)
dataBody.Set("secret", secret) dataBody.Set("secret", secret)
dataBody.Set("method", "update") dataBody.Set("method", string(method))
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s/webhooks/", endpoint), dataBody.Encode())
resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s/webhooks/", endpoint), dataBody.Encode())
if err != nil { if err != nil {
return fmt.Errorf("failed to make request: %s: %w", callbackUrl, err) return nil, fmt.Errorf("failed to make request: %s: %w", callbackUrl, err)
}
if resp.StatusCode() == http.StatusOK {
return nil, nil
}
var data WebhookResponse
if err = json.Unmarshal(resp.Body(), &data); err != nil {
return nil, fmt.Errorf("failed to unmarshal: %w", err)
}
return &data, fmt.Errorf("failed to activate webhook: %s: %s", callbackUrl, resp.String())
}
func (a *Webhooks) Unregister(ctx context.Context, webhookId uint64) error {
resp, err := a.request(ctx, "DELETE", fmt.Sprintf("https://api.igdb.com/v4/webhooks/%v", webhookId), "")
if err != nil {
return fmt.Errorf("failed to make request: %w", err)
} }
if resp.StatusCode() == http.StatusOK { if resp.StatusCode() == http.StatusOK {
return nil return nil
} }
return fmt.Errorf("failed to activate webhook: %s: %s", callbackUrl, resp.String())
return fmt.Errorf("failed to unregister webhook: %s", resp.String())
}
func (a *Webhooks) List(ctx context.Context) ([]*WebhookResponse, error) {
resp, err := a.request(ctx, "GET", "https://api.igdb.com/v4/webhooks/", "")
if err != nil {
return nil, fmt.Errorf("failed to make request: %w", err)
}
var data []*WebhookResponse
if err = json.Unmarshal(resp.Body(), &data); err != nil {
return nil, fmt.Errorf("failed to unmarshal: %w", err)
}
return data, nil
}
func (a *Webhooks) Get(ctx context.Context, webhookId uint64) (*WebhookResponse, error) {
resp, err := a.request(ctx, "GET", fmt.Sprintf("https://api.igdb.com/v4/webhooks/%v", webhookId), "")
if err != nil {
return nil, fmt.Errorf("failed to make request: %w", err)
}
var data WebhookResponse
if err = json.Unmarshal(resp.Body(), &data); err != nil {
return nil, fmt.Errorf("failed to unmarshal: %w", err)
}
return &data, nil
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type WebsiteTypes struct {
BaseEndpoint[pb.WebsiteType] BaseEndpoint[pb.WebsiteType]
} }
func NewWebsiteTypes(request func(URL string, dataBody any) (*resty.Response, error)) *WebsiteTypes { func NewWebsiteTypes(request RequestFunc) *WebsiteTypes {
a := &WebsiteTypes{ a := &WebsiteTypes{
BaseEndpoint[pb.WebsiteType]{ BaseEndpoint: BaseEndpoint[pb.WebsiteType]{
endpointName: EPWebsiteTypes, endpointName: EPWebsiteTypes,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewWebsiteTypes(request func(URL string, dataBody any) (*resty.Response, er
return a return a
} }
func (a *WebsiteTypes) Query(query string) ([]*pb.WebsiteType, error) { func (a *WebsiteTypes) Query(ctx context.Context, query string) ([]*pb.WebsiteType, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

View File

@@ -1,10 +1,10 @@
package endpoint package endpoint
import ( import (
"context"
"fmt" "fmt"
pb "github.com/bestnite/go-igdb/proto" pb "github.com/bestnite/go-igdb/proto"
"github.com/go-resty/resty/v2"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -13,9 +13,9 @@ type Websites struct {
BaseEndpoint[pb.Website] BaseEndpoint[pb.Website]
} }
func NewWebsites(request func(URL string, dataBody any) (*resty.Response, error)) *Websites { func NewWebsites(request RequestFunc) *Websites {
a := &Websites{ a := &Websites{
BaseEndpoint[pb.Website]{ BaseEndpoint: BaseEndpoint[pb.Website]{
endpointName: EPWebsites, endpointName: EPWebsites,
request: request, request: request,
}, },
@@ -24,8 +24,8 @@ func NewWebsites(request func(URL string, dataBody any) (*resty.Response, error)
return a return a
} }
func (a *Websites) Query(query string) ([]*pb.Website, error) { func (a *Websites) Query(ctx context.Context, query string) ([]*pb.Website, error) {
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query) resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to request: %w", err) return nil, fmt.Errorf("failed to request: %w", err)
} }

1
go.mod
View File

@@ -6,6 +6,7 @@ require (
github.com/PuerkitoBio/goquery v1.10.2 github.com/PuerkitoBio/goquery v1.10.2
github.com/bestnite/go-flaresolverr v0.0.0-20250404141941-4644c2e66727 github.com/bestnite/go-flaresolverr v0.0.0-20250404141941-4644c2e66727
github.com/go-resty/resty/v2 v2.16.5 github.com/go-resty/resty/v2 v2.16.5
golang.org/x/time v0.14.0
google.golang.org/protobuf v1.36.6 google.golang.org/protobuf v1.36.6
) )

4
go.sum
View File

@@ -367,8 +367,8 @@ golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

File diff suppressed because it is too large Load Diff

View File

@@ -209,6 +209,19 @@ enum AgeRatingContentDescriptionCategoryEnum {
CLASS_IND_ATOS_CRIMINOSOS = 85 [deprecated = true]; CLASS_IND_ATOS_CRIMINOSOS = 85 [deprecated = true];
} }
message AgeRatingContentDescriptionTypeResult {
repeated AgeRatingContentDescriptionType ageratingcontentdescriptiontypes = 1;
}
message AgeRatingContentDescriptionType {
uint64 id = 1;
string slug = 2;
string name = 3;
google.protobuf.Timestamp created_at = 4;
google.protobuf.Timestamp updated_at = 5;
string checksum = 6;
}
message AgeRatingContentDescriptionV2Result { message AgeRatingContentDescriptionV2Result {
repeated AgeRatingContentDescriptionV2 ageratingcontentdescriptionsv2 = 1; repeated AgeRatingContentDescriptionV2 ageratingcontentdescriptionsv2 = 1;
} }
@@ -220,6 +233,7 @@ message AgeRatingContentDescriptionV2 {
google.protobuf.Timestamp created_at = 4; google.protobuf.Timestamp created_at = 4;
google.protobuf.Timestamp updated_at = 5; google.protobuf.Timestamp updated_at = 5;
string checksum = 6; string checksum = 6;
AgeRatingContentDescriptionType description_type = 7;
} }
message AgeRatingOrganizationResult { message AgeRatingOrganizationResult {
@@ -260,6 +274,20 @@ message Artwork {
string url = 7; string url = 7;
int32 width = 8; int32 width = 8;
string checksum = 9; string checksum = 9;
ArtworkType artwork_type = 10;
}
message ArtworkTypeResult {
repeated ArtworkType artworktypes = 1;
}
message ArtworkType {
uint64 id = 1;
string slug = 2;
string name = 3;
google.protobuf.Timestamp created_at = 4;
google.protobuf.Timestamp updated_at = 5;
string checksum = 6;
} }
message CharacterResult { message CharacterResult {
@@ -1342,6 +1370,7 @@ message ReleaseDate {
ReleaseDateStatus status = 13; ReleaseDateStatus status = 13;
DateFormat date_format = 14; DateFormat date_format = 14;
ReleaseDateRegion release_region = 15; ReleaseDateRegion release_region = 15;
int32 d = 16;
} }
message ReleaseDateRegionResult { message ReleaseDateRegionResult {

View File

@@ -1,4 +1,4 @@
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
wget https://api.igdb.com/v4/igdbapi.proto -O ./igdbapi.proto wget https://api.igdb.com/v4/igdbapi.proto -O ./proto/igdbapi.proto
protoc --go_out=. --go_opt=Mproto/igdbapi.proto=/proto ./proto/igdbapi.proto protoc --go_out=. --go_opt=Mproto/igdbapi.proto=/proto ./proto/igdbapi.proto

View File

@@ -1,48 +0,0 @@
package igdb
import (
"sync"
"time"
)
type rateLimiter struct {
mu sync.Mutex
rate int
interval time.Duration
tokens int
lastRefill time.Time
}
func newRateLimiter(rate int) *rateLimiter {
return &rateLimiter{
rate: rate,
interval: time.Second,
tokens: rate,
lastRefill: time.Now(),
}
}
func (r *rateLimiter) wait() {
r.mu.Lock()
defer r.mu.Unlock()
now := time.Now()
elapsed := now.Sub(r.lastRefill)
if elapsed >= r.interval {
r.tokens = r.rate
r.lastRefill = now
}
if r.tokens <= 0 {
waitTime := r.interval - elapsed
r.mu.Unlock()
time.Sleep(waitTime)
r.mu.Lock()
r.tokens = r.rate - 1
r.lastRefill = time.Now()
return
}
r.tokens--
}

View File

@@ -7,23 +7,19 @@ import (
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
) )
var client *resty.Client type SilentLogger struct{}
func init() { func (s SilentLogger) Errorf(string, ...any) {}
client = resty.New() func (s SilentLogger) Warnf(string, ...any) {}
client.SetRetryCount(3).SetRetryWaitTime(3 * time.Second).AddRetryCondition( func (s SilentLogger) Debugf(string, ...any) {}
func NewRestyClient() *resty.Client {
return resty.New().SetRetryCount(10).SetRetryWaitTime(3 * time.Second).AddRetryCondition(
func(r *resty.Response, err error) bool { func(r *resty.Response, err error) bool {
return err != nil || r.StatusCode() == http.StatusTooManyRequests if err != nil || r.StatusCode() == http.StatusTooManyRequests {
return true
}
return false
}, },
) )
} }
func request() *resty.Request {
return client.R().SetLogger(disableLogger{}).SetHeader("Accept-Charset", "utf-8").SetHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0")
}
type disableLogger struct{}
func (d disableLogger) Errorf(string, ...interface{}) {}
func (d disableLogger) Warnf(string, ...interface{}) {}
func (d disableLogger) Debugf(string, ...interface{}) {}

View File

@@ -1,31 +1,32 @@
package igdb package igdb
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/url" "net/url"
"time" "time"
) )
type TwitchToken struct { type twitchToken struct {
clientID string clientID string
clientSecret string clientSecret string
token string token string
expires time.Time expires time.Time
} }
func NewTwitchToken(clientID, clientSecret string) *TwitchToken { func newTwitchToken(clientID, clientSecret string) *twitchToken {
return &TwitchToken{ return &twitchToken{
clientID: clientID, clientID: clientID,
clientSecret: clientSecret, clientSecret: clientSecret,
} }
} }
func (t *TwitchToken) getToken() (string, error) { func (t *twitchToken) GetToken(ctx context.Context) (string, error) {
if t.token != "" && time.Now().Before(t.expires) { if t.token != "" && time.Now().Before(t.expires) {
return t.token, nil return t.token, nil
} }
token, expires, err := t.loginTwitch() token, expires, err := t.LoginTwitch(ctx)
if err != nil { if err != nil {
return "", fmt.Errorf("failed to login twitch: %w", err) return "", fmt.Errorf("failed to login twitch: %w", err)
} }
@@ -34,7 +35,7 @@ func (t *TwitchToken) getToken() (string, error) {
return token, nil return token, nil
} }
func (t *TwitchToken) loginTwitch() (string, time.Duration, error) { func (t *twitchToken) LoginTwitch(ctx context.Context) (string, time.Duration, error) {
baseURL, _ := url.Parse("https://id.twitch.tv/oauth2/token") baseURL, _ := url.Parse("https://id.twitch.tv/oauth2/token")
params := url.Values{} params := url.Values{}
params.Add("client_id", t.clientID) params.Add("client_id", t.clientID)
@@ -42,7 +43,7 @@ func (t *TwitchToken) loginTwitch() (string, time.Duration, error) {
params.Add("grant_type", "client_credentials") params.Add("grant_type", "client_credentials")
baseURL.RawQuery = params.Encode() baseURL.RawQuery = params.Encode()
resp, err := request().SetHeader("User-Agent", "").Post(baseURL.String()) resp, err := NewRestyClient().R().SetContext(ctx).SetHeader("User-Agent", "").Post(baseURL.String())
if err != nil { if err != nil {
return "", 0, fmt.Errorf("failed to make request: %s: %w", baseURL.String(), err) return "", 0, fmt.Errorf("failed to make request: %s: %w", baseURL.String(), err)
} }