Compare commits
	
		
			6 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						aaf697a005
	
				 | 
					
					
						|||
| 
						
						
							
						
						7ef9cb37e6
	
				 | 
					
					
						|||
| 
						
						
							
						
						87afdc63b8
	
				 | 
					
					
						|||
| 
						
						
							
						
						b99d06a2de
	
				 | 
					
					
						|||
| 
						
						
							
						
						4b6f488f59
	
				 | 
					
					
						|||
| 3df648929d | 
@@ -14,7 +14,7 @@ A Go client library for the IGDB (Internet Game Database) API v4. This library p
 | 
			
		||||
## Installation
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
go get github.com/bestnite/go-igdb
 | 
			
		||||
go get git.nite07.com/nite/go-igdb
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Quick Start
 | 
			
		||||
@@ -25,7 +25,7 @@ package main
 | 
			
		||||
import (
 | 
			
		||||
	"log"
 | 
			
		||||
 | 
			
		||||
	"github.com/bestnite/go-igdb"
 | 
			
		||||
	"git.nite07.com/nite/go-igdb"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func Test1(c *igdb.Client) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										34
									
								
								client.go
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								client.go
									
									
									
									
									
								
							@@ -1,20 +1,23 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"git.nite07.com/nite/go-igdb/endpoint"
 | 
			
		||||
	"github.com/bestnite/go-flaresolverr"
 | 
			
		||||
	"github.com/bestnite/go-igdb/endpoint"
 | 
			
		||||
	"golang.org/x/time/rate"
 | 
			
		||||
 | 
			
		||||
	"github.com/go-resty/resty/v2"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Client struct {
 | 
			
		||||
	clientID     string
 | 
			
		||||
	token        *TwitchToken
 | 
			
		||||
	token        *twitchToken
 | 
			
		||||
	flaresolverr *flaresolverr.Flaresolverr
 | 
			
		||||
	limiter      *rateLimiter
 | 
			
		||||
	restyClient  *resty.Client
 | 
			
		||||
	limiter      *rate.Limiter
 | 
			
		||||
 | 
			
		||||
	AgeRatingCategories            *endpoint.AgeRatingCategories
 | 
			
		||||
	AgeRatingContentDescriptions   *endpoint.AgeRatingContentDescriptions
 | 
			
		||||
@@ -92,11 +95,11 @@ type Client struct {
 | 
			
		||||
func New(clientID, clientSecret string) *Client {
 | 
			
		||||
	c := &Client{
 | 
			
		||||
		clientID:     clientID,
 | 
			
		||||
		limiter:      newRateLimiter(4),
 | 
			
		||||
		token:        NewTwitchToken(clientID, clientSecret),
 | 
			
		||||
		restyClient:  NewRestyClient(),
 | 
			
		||||
		token:        newTwitchToken(clientID, clientSecret),
 | 
			
		||||
		flaresolverr: nil,
 | 
			
		||||
		limiter:      rate.NewLimiter(rate.Limit(4), 4),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	registerAllEndpoints(c)
 | 
			
		||||
 | 
			
		||||
	return c
 | 
			
		||||
@@ -110,23 +113,30 @@ func NewWithFlaresolverr(clientID, clientSecret string, f *flaresolverr.Flaresol
 | 
			
		||||
	return c
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (g *Client) Request(method string, URL string, dataBody any) (*resty.Response, error) {
 | 
			
		||||
	g.limiter.wait()
 | 
			
		||||
func (g *Client) Request(ctx context.Context, method string, requestURL string, dataBody any) (*resty.Response, error) {
 | 
			
		||||
	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 {
 | 
			
		||||
		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,
 | 
			
		||||
		"Authorization": "Bearer " + t,
 | 
			
		||||
		"User-Agent":    "",
 | 
			
		||||
		"Content-Type":  "text/plain",
 | 
			
		||||
	}).Execute(strings.ToUpper(method), URL)
 | 
			
		||||
	}).Execute(strings.ToUpper(method), requestURL)
 | 
			
		||||
 | 
			
		||||
	if resp.StatusCode() != 200 {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request, expected 200 but got: %v", resp.StatusCode())
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %s: %w", URL, err)
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %s: %w", requestURL, err)
 | 
			
		||||
	}
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewAgeRatingCategories(request RequestFunc) *AgeRatingCategories {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AgeRatingCategories) Query(query string) ([]*pb.AgeRatingCategory, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *AgeRatingCategories) Query(ctx context.Context, query string) ([]*pb.AgeRatingCategory, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *AgeRatingCategories) Query(query string) ([]*pb.AgeRatingCategory, erro
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Ageratingcategories) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Ageratingcategories, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewAgeRatingContentDescriptions(request RequestFunc) *AgeRatingContentDescr
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AgeRatingContentDescriptions) Query(query string) ([]*pb.AgeRatingContentDescription, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *AgeRatingContentDescriptions) Query(ctx context.Context, query string) ([]*pb.AgeRatingContentDescription, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *AgeRatingContentDescriptions) Query(query string) ([]*pb.AgeRatingConte
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Ageratingcontentdescriptions) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Ageratingcontentdescriptions, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewAgeRatingContentDescriptionsV2(request RequestFunc) *AgeRatingContentDes
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AgeRatingContentDescriptionsV2) Query(query string) ([]*pb.AgeRatingContentDescriptionV2, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *AgeRatingContentDescriptionsV2) Query(ctx context.Context, query string) ([]*pb.AgeRatingContentDescriptionV2, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *AgeRatingContentDescriptionsV2) Query(query string) ([]*pb.AgeRatingCon
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Ageratingcontentdescriptionsv2) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Ageratingcontentdescriptionsv2, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewAgeRatingOrganizations(request RequestFunc) *AgeRatingOrganizations {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AgeRatingOrganizations) Query(query string) ([]*pb.AgeRatingOrganization, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *AgeRatingOrganizations) Query(ctx context.Context, query string) ([]*pb.AgeRatingOrganization, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *AgeRatingOrganizations) Query(query string) ([]*pb.AgeRatingOrganizatio
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Ageratingorganizations) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Ageratingorganizations, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewAgeRatings(request RequestFunc) *AgeRatings {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AgeRatings) Query(query string) ([]*pb.AgeRating, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *AgeRatings) Query(ctx context.Context, query string) ([]*pb.AgeRating, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *AgeRatings) Query(query string) ([]*pb.AgeRating, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Ageratings) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Ageratings, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewAlternativeNames(request RequestFunc) *AlternativeNames {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AlternativeNames) Query(query string) ([]*pb.AlternativeName, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *AlternativeNames) Query(ctx context.Context, query string) ([]*pb.AlternativeName, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *AlternativeNames) Query(query string) ([]*pb.AlternativeName, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Alternativenames) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Alternativenames, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewArtworks(request RequestFunc) *Artworks {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Artworks) Query(query string) ([]*pb.Artwork, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Artworks) Query(ctx context.Context, query string) ([]*pb.Artwork, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Artworks) Query(query string) ([]*pb.Artwork, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Artworks) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Artworks, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,37 +1,42 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
 | 
			
		||||
	"github.com/go-resty/resty/v2"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type RequestFunc func(method string, URL string, dataBody any) (*resty.Response, error)
 | 
			
		||||
type RequestFunc func(ctx context.Context, method string, URL string, dataBody any) (*resty.Response, error)
 | 
			
		||||
 | 
			
		||||
type BaseEndpoint[T any] struct {
 | 
			
		||||
	request      RequestFunc
 | 
			
		||||
	endpointName Name
 | 
			
		||||
	queryFunc    func(string) ([]*T, error)
 | 
			
		||||
	queryFunc    func(context.Context, string) ([]*T, error)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *BaseEndpoint[T]) GetEndpointName() Name {
 | 
			
		||||
	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 {
 | 
			
		||||
		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) {
 | 
			
		||||
	res, err := b.Query(fmt.Sprintf("where id = %d; fields *;", id))
 | 
			
		||||
func (b *BaseEndpoint[T]) GetByID(ctx context.Context, id uint64) (*T, error) {
 | 
			
		||||
	if id == 0 {
 | 
			
		||||
		return nil, errors.New("id cant be 0")
 | 
			
		||||
	}
 | 
			
		||||
	res, err := b.Query(ctx, fmt.Sprintf("where id = %d; fields *;", id))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
@@ -41,19 +46,35 @@ func (b *BaseEndpoint[T]) GetByID(id uint64) (*T, error) {
 | 
			
		||||
	return res[0], nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *BaseEndpoint[T]) GetByIDs(ids []uint64) ([]*T, error) {
 | 
			
		||||
	builder := strings.Builder{}
 | 
			
		||||
	for i, v := range ids {
 | 
			
		||||
		if i > 0 {
 | 
			
		||||
			builder.WriteByte(',')
 | 
			
		||||
		}
 | 
			
		||||
		builder.WriteString(strconv.FormatUint(v, 10))
 | 
			
		||||
func (b *BaseEndpoint[T]) GetByIDs(ctx context.Context, ids []uint64) ([]*T, error) {
 | 
			
		||||
	if len(ids) == 0 {
 | 
			
		||||
		return []*T{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	return b.Query(fmt.Sprintf("where id = (%s); fields *;", builder.String()))
 | 
			
		||||
	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{}
 | 
			
		||||
		for i, v := range batch {
 | 
			
		||||
			if i > 0 {
 | 
			
		||||
				builder.WriteByte(',')
 | 
			
		||||
			}
 | 
			
		||||
			builder.WriteString(strconv.FormatUint(v, 10))
 | 
			
		||||
		}
 | 
			
		||||
		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) {
 | 
			
		||||
	resp, err := b.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s/count.pb", b.endpointName), "")
 | 
			
		||||
func (b *BaseEndpoint[T]) Count(ctx context.Context) (uint64, error) {
 | 
			
		||||
	resp, err := b.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s/count.pb", b.endpointName), "")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -63,18 +84,22 @@ func (b *BaseEndpoint[T]) Count() (uint64, error) {
 | 
			
		||||
		return 0, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return uint64(res.Count), nil
 | 
			
		||||
	if res.Count > 0 {
 | 
			
		||||
		return uint64(res.Count), nil
 | 
			
		||||
	} else {
 | 
			
		||||
		return 0, fmt.Errorf("failed to count, count should larger than 0, but got %v", res.Count)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *BaseEndpoint[T]) Paginated(offset, limit uint64) ([]*T, error) {
 | 
			
		||||
	return b.Query(fmt.Sprintf("offset %d; limit %d; fields *; sort id asc;", offset, limit))
 | 
			
		||||
func (b *BaseEndpoint[T]) Paginated(ctx context.Context, offset, limit uint64) ([]*T, error) {
 | 
			
		||||
	return b.Query(ctx, fmt.Sprintf("offset %d; limit %d; fields *; sort id asc;", offset, limit))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type EntityEndpoint[T any] interface {
 | 
			
		||||
	GetEndpointName() Name
 | 
			
		||||
	Query(string) ([]*T, error)
 | 
			
		||||
	GetByID(uint64) (*T, error)
 | 
			
		||||
	GetByIDs([]uint64) ([]*T, error)
 | 
			
		||||
	Count() (uint64, error)
 | 
			
		||||
	Paginated(uint64, uint64) ([]*T, error)
 | 
			
		||||
	Query(context.Context, string) ([]*T, error)
 | 
			
		||||
	GetByID(context.Context, uint64) (*T, error)
 | 
			
		||||
	GetByIDs(context.Context, []uint64) ([]*T, error)
 | 
			
		||||
	Count(context.Context) (uint64, error)
 | 
			
		||||
	Paginated(context.Context, uint64, uint64) ([]*T, error)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCharacterGenders(request RequestFunc) *CharacterGenders {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CharacterGenders) Query(query string) ([]*pb.CharacterGender, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *CharacterGenders) Query(ctx context.Context, query string) ([]*pb.CharacterGender, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *CharacterGenders) Query(query string) ([]*pb.CharacterGender, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Charactergenders) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Charactergenders, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCharacterMugShots(request RequestFunc) *CharacterMugShots {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CharacterMugShots) Query(query string) ([]*pb.CharacterMugShot, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *CharacterMugShots) Query(ctx context.Context, query string) ([]*pb.CharacterMugShot, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *CharacterMugShots) Query(query string) ([]*pb.CharacterMugShot, error)
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Charactermugshots) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Charactermugshots, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCharacterSpecies(request RequestFunc) *CharacterSpecies {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CharacterSpecies) Query(query string) ([]*pb.CharacterSpecie, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *CharacterSpecies) Query(ctx context.Context, query string) ([]*pb.CharacterSpecie, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *CharacterSpecies) Query(query string) ([]*pb.CharacterSpecie, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Characterspecies) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Characterspecies, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCharacters(request RequestFunc) *Characters {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Characters) Query(query string) ([]*pb.Character, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Characters) Query(ctx context.Context, query string) ([]*pb.Character, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Characters) Query(query string) ([]*pb.Character, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Characters) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Characters, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCollectionMembershipTypes(request RequestFunc) *CollectionMembershipType
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CollectionMembershipTypes) Query(query string) ([]*pb.CollectionMembershipType, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *CollectionMembershipTypes) Query(ctx context.Context, query string) ([]*pb.CollectionMembershipType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *CollectionMembershipTypes) Query(query string) ([]*pb.CollectionMembers
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Collectionmembershiptypes) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Collectionmembershiptypes, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCollectionMemberships(request RequestFunc) *CollectionMemberships {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CollectionMemberships) Query(query string) ([]*pb.CollectionMembership, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *CollectionMemberships) Query(ctx context.Context, query string) ([]*pb.CollectionMembership, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *CollectionMemberships) Query(query string) ([]*pb.CollectionMembership,
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Collectionmemberships) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Collectionmemberships, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCollectionRelationTypes(request RequestFunc) *CollectionRelationTypes {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CollectionRelationTypes) Query(query string) ([]*pb.CollectionRelationType, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *CollectionRelationTypes) Query(ctx context.Context, query string) ([]*pb.CollectionRelationType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *CollectionRelationTypes) Query(query string) ([]*pb.CollectionRelationT
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Collectionrelationtypes) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Collectionrelationtypes, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCollectionRelations(request RequestFunc) *CollectionRelations {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CollectionRelations) Query(query string) ([]*pb.CollectionRelation, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *CollectionRelations) Query(ctx context.Context, query string) ([]*pb.CollectionRelation, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *CollectionRelations) Query(query string) ([]*pb.CollectionRelation, err
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Collectionrelations) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Collectionrelations, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCollectionTypes(request RequestFunc) *CollectionTypes {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CollectionTypes) Query(query string) ([]*pb.CollectionType, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *CollectionTypes) Query(ctx context.Context, query string) ([]*pb.CollectionType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *CollectionTypes) Query(query string) ([]*pb.CollectionType, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Collectiontypes) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Collectiontypes, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCollections(request RequestFunc) *Collections {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Collections) Query(query string) ([]*pb.Collection, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Collections) Query(ctx context.Context, query string) ([]*pb.Collection, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Collections) Query(query string) ([]*pb.Collection, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Collections) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Collections, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -24,8 +24,8 @@ func NewCompanies(request RequestFunc) *Companies {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Companies) Query(query string) ([]*pb.Company, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Companies) Query(ctx context.Context, query string) ([]*pb.Company, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -35,9 +35,5 @@ func (a *Companies) Query(query string) ([]*pb.Company, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Companies) == 0 {
 | 
			
		||||
		return nil, errors.New("no results")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Companies, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCompanyLogos(request RequestFunc) *CompanyLogos {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CompanyLogos) Query(query string) ([]*pb.CompanyLogo, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *CompanyLogos) Query(ctx context.Context, query string) ([]*pb.CompanyLogo, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *CompanyLogos) Query(query string) ([]*pb.CompanyLogo, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Companylogos) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Companylogos, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCompanyStatuses(request RequestFunc) *CompanyStatuses {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CompanyStatuses) Query(query string) ([]*pb.CompanyStatus, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *CompanyStatuses) Query(ctx context.Context, query string) ([]*pb.CompanyStatus, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *CompanyStatuses) Query(query string) ([]*pb.CompanyStatus, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Companystatuses) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Companystatuses, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCompanyWebsites(request RequestFunc) *CompanyWebsites {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CompanyWebsites) Query(query string) ([]*pb.CompanyWebsite, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *CompanyWebsites) Query(ctx context.Context, query string) ([]*pb.CompanyWebsite, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *CompanyWebsites) Query(query string) ([]*pb.CompanyWebsite, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Companywebsites) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Companywebsites, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewCovers(request RequestFunc) *Covers {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Covers) Query(query string) ([]*pb.Cover, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Covers) Query(ctx context.Context, query string) ([]*pb.Cover, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Covers) Query(query string) ([]*pb.Cover, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Covers) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Covers, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewDateFormats(request RequestFunc) *DateFormats {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *DateFormats) Query(query string) ([]*pb.DateFormat, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *DateFormats) Query(ctx context.Context, query string) ([]*pb.DateFormat, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *DateFormats) Query(query string) ([]*pb.DateFormat, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Dateformats) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Dateformats, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewEventLogos(request RequestFunc) *EventLogos {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *EventLogos) Query(query string) ([]*pb.EventLogo, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *EventLogos) Query(ctx context.Context, query string) ([]*pb.EventLogo, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *EventLogos) Query(query string) ([]*pb.EventLogo, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Eventlogos) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Eventlogos, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewEventNetworks(request RequestFunc) *EventNetworks {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *EventNetworks) Query(query string) ([]*pb.EventNetwork, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *EventNetworks) Query(ctx context.Context, query string) ([]*pb.EventNetwork, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *EventNetworks) Query(query string) ([]*pb.EventNetwork, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Eventnetworks) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Eventnetworks, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewEvents(request RequestFunc) *Events {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Events) Query(query string) ([]*pb.Event, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Events) Query(ctx context.Context, query string) ([]*pb.Event, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Events) Query(query string) ([]*pb.Event, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Events) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Events, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewExternalGameSources(request RequestFunc) *ExternalGameSources {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *ExternalGameSources) Query(query string) ([]*pb.ExternalGameSource, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *ExternalGameSources) Query(ctx context.Context, query string) ([]*pb.ExternalGameSource, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *ExternalGameSources) Query(query string) ([]*pb.ExternalGameSource, err
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Externalgamesources) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Externalgamesources, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewExternalGames(request RequestFunc) *ExternalGames {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *ExternalGames) Query(query string) ([]*pb.ExternalGame, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *ExternalGames) Query(ctx context.Context, query string) ([]*pb.ExternalGame, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *ExternalGames) Query(query string) ([]*pb.ExternalGame, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Externalgames) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Externalgames, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type Franchises struct {
 | 
			
		||||
 | 
			
		||||
func NewFranchises(request RequestFunc) *Franchises {
 | 
			
		||||
	a := &Franchises{
 | 
			
		||||
		BaseEndpoint[pb.Franchise]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Franchise]{
 | 
			
		||||
			endpointName: EPFranchises,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewFranchises(request RequestFunc) *Franchises {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Franchises) Query(query string) ([]*pb.Franchise, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Franchises) Query(ctx context.Context, query string) ([]*pb.Franchise, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Franchises) Query(query string) ([]*pb.Franchise, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Franchises) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Franchises, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGameEngineLogos(request RequestFunc) *GameEngineLogos {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameEngineLogos) Query(query string) ([]*pb.GameEngineLogo, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *GameEngineLogos) Query(ctx context.Context, query string) ([]*pb.GameEngineLogo, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *GameEngineLogos) Query(query string) ([]*pb.GameEngineLogo, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Gameenginelogos) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gameenginelogos, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type GameEngines struct {
 | 
			
		||||
 | 
			
		||||
func NewGameEngines(request RequestFunc) *GameEngines {
 | 
			
		||||
	a := &GameEngines{
 | 
			
		||||
		BaseEndpoint[pb.GameEngine]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameEngine]{
 | 
			
		||||
			endpointName: EPGameEngines,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGameEngines(request RequestFunc) *GameEngines {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameEngines) Query(query string) ([]*pb.GameEngine, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *GameEngines) Query(ctx context.Context, query string) ([]*pb.GameEngine, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *GameEngines) Query(query string) ([]*pb.GameEngine, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Gameengines) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gameengines, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type GameLocalizations struct {
 | 
			
		||||
 | 
			
		||||
func NewGameLocalizations(request RequestFunc) *GameLocalizations {
 | 
			
		||||
	a := &GameLocalizations{
 | 
			
		||||
		BaseEndpoint[pb.GameLocalization]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameLocalization]{
 | 
			
		||||
			endpointName: EPGameLocalizations,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGameLocalizations(request RequestFunc) *GameLocalizations {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameLocalizations) Query(query string) ([]*pb.GameLocalization, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *GameLocalizations) Query(ctx context.Context, query string) ([]*pb.GameLocalization, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *GameLocalizations) Query(query string) ([]*pb.GameLocalization, error)
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Gamelocalizations) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gamelocalizations, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type GameModes struct {
 | 
			
		||||
 | 
			
		||||
func NewGameModes(request RequestFunc) *GameModes {
 | 
			
		||||
	a := &GameModes{
 | 
			
		||||
		BaseEndpoint[pb.GameMode]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameMode]{
 | 
			
		||||
			endpointName: EPGameModes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGameModes(request RequestFunc) *GameModes {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameModes) Query(query string) ([]*pb.GameMode, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *GameModes) Query(ctx context.Context, query string) ([]*pb.GameMode, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *GameModes) Query(query string) ([]*pb.GameMode, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Gamemodes) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gamemodes, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type GameReleaseFormats struct {
 | 
			
		||||
 | 
			
		||||
func NewGameReleaseFormats(request RequestFunc) *GameReleaseFormats {
 | 
			
		||||
	a := &GameReleaseFormats{
 | 
			
		||||
		BaseEndpoint[pb.GameReleaseFormat]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameReleaseFormat]{
 | 
			
		||||
			endpointName: EPGameReleaseFormats,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGameReleaseFormats(request RequestFunc) *GameReleaseFormats {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameReleaseFormats) Query(query string) ([]*pb.GameReleaseFormat, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *GameReleaseFormats) Query(ctx context.Context, query string) ([]*pb.GameReleaseFormat, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *GameReleaseFormats) Query(query string) ([]*pb.GameReleaseFormat, error
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Gamereleaseformats) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gamereleaseformats, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type GameStatuses struct {
 | 
			
		||||
 | 
			
		||||
func NewGameStatuses(request RequestFunc) *GameStatuses {
 | 
			
		||||
	a := &GameStatuses{
 | 
			
		||||
		BaseEndpoint[pb.GameStatus]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameStatus]{
 | 
			
		||||
			endpointName: EPGameStatuses,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGameStatuses(request RequestFunc) *GameStatuses {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameStatuses) Query(query string) ([]*pb.GameStatus, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *GameStatuses) Query(ctx context.Context, query string) ([]*pb.GameStatus, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *GameStatuses) Query(query string) ([]*pb.GameStatus, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Gamestatuses) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gamestatuses, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type GameTimeToBeats struct {
 | 
			
		||||
 | 
			
		||||
func NewGameTimeToBeats(request RequestFunc) *GameTimeToBeats {
 | 
			
		||||
	a := &GameTimeToBeats{
 | 
			
		||||
		BaseEndpoint[pb.GameTimeToBeat]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameTimeToBeat]{
 | 
			
		||||
			endpointName: EPGameTimeToBeats,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGameTimeToBeats(request RequestFunc) *GameTimeToBeats {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameTimeToBeats) Query(query string) ([]*pb.GameTimeToBeat, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *GameTimeToBeats) Query(ctx context.Context, query string) ([]*pb.GameTimeToBeat, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *GameTimeToBeats) Query(query string) ([]*pb.GameTimeToBeat, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Gametimetobeats) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gametimetobeats, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type GameTypes struct {
 | 
			
		||||
 | 
			
		||||
func NewGameTypes(request RequestFunc) *GameTypes {
 | 
			
		||||
	a := &GameTypes{
 | 
			
		||||
		BaseEndpoint[pb.GameType]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameType]{
 | 
			
		||||
			endpointName: EPGameTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGameTypes(request RequestFunc) *GameTypes {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameTypes) Query(query string) ([]*pb.GameType, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *GameTypes) Query(ctx context.Context, query string) ([]*pb.GameType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *GameTypes) Query(query string) ([]*pb.GameType, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Gametypes) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gametypes, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type GameVersionFeatureValues struct {
 | 
			
		||||
 | 
			
		||||
func NewGameVersionFeatureValues(request RequestFunc) *GameVersionFeatureValues {
 | 
			
		||||
	a := &GameVersionFeatureValues{
 | 
			
		||||
		BaseEndpoint[pb.GameVersionFeatureValue]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameVersionFeatureValue]{
 | 
			
		||||
			endpointName: EPGameVersionFeatureValues,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGameVersionFeatureValues(request RequestFunc) *GameVersionFeatureValues
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameVersionFeatureValues) Query(query string) ([]*pb.GameVersionFeatureValue, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *GameVersionFeatureValues) Query(ctx context.Context, query string) ([]*pb.GameVersionFeatureValue, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *GameVersionFeatureValues) Query(query string) ([]*pb.GameVersionFeature
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Gameversionfeaturevalues) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gameversionfeaturevalues, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type GameVersionFeatures struct {
 | 
			
		||||
 | 
			
		||||
func NewGameVersionFeatures(request RequestFunc) *GameVersionFeatures {
 | 
			
		||||
	a := &GameVersionFeatures{
 | 
			
		||||
		BaseEndpoint[pb.GameVersionFeature]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameVersionFeature]{
 | 
			
		||||
			endpointName: EPGameVersionFeatures,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGameVersionFeatures(request RequestFunc) *GameVersionFeatures {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameVersionFeatures) Query(query string) ([]*pb.GameVersionFeature, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *GameVersionFeatures) Query(ctx context.Context, query string) ([]*pb.GameVersionFeature, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *GameVersionFeatures) Query(query string) ([]*pb.GameVersionFeature, err
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Gameversionfeatures) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gameversionfeatures, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type GameVersions struct {
 | 
			
		||||
 | 
			
		||||
func NewGameVersions(request RequestFunc) *GameVersions {
 | 
			
		||||
	a := &GameVersions{
 | 
			
		||||
		BaseEndpoint[pb.GameVersion]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameVersion]{
 | 
			
		||||
			endpointName: EPGameVersions,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGameVersions(request RequestFunc) *GameVersions {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameVersions) Query(query string) ([]*pb.GameVersion, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *GameVersions) Query(ctx context.Context, query string) ([]*pb.GameVersion, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *GameVersions) Query(query string) ([]*pb.GameVersion, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Gameversions) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gameversions, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type GameVideos struct {
 | 
			
		||||
 | 
			
		||||
func NewGameVideos(request RequestFunc) *GameVideos {
 | 
			
		||||
	a := &GameVideos{
 | 
			
		||||
		BaseEndpoint[pb.GameVideo]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameVideo]{
 | 
			
		||||
			endpointName: EPGameVideos,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGameVideos(request RequestFunc) *GameVideos {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameVideos) Query(query string) ([]*pb.GameVideo, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *GameVideos) Query(ctx context.Context, query string) ([]*pb.GameVideo, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *GameVideos) Query(query string) ([]*pb.GameVideo, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Gamevideos) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gamevideos, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type Games struct {
 | 
			
		||||
 | 
			
		||||
func NewGames(request RequestFunc) *Games {
 | 
			
		||||
	a := &Games{
 | 
			
		||||
		BaseEndpoint[pb.Game]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Game]{
 | 
			
		||||
			endpointName: EPGames,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGames(request RequestFunc) *Games {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Games) Query(query string) ([]*pb.Game, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Games) Query(ctx context.Context, query string) ([]*pb.Game, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Games) Query(query string) ([]*pb.Game, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Games) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Games, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type Genres struct {
 | 
			
		||||
 | 
			
		||||
func NewGenres(request RequestFunc) *Genres {
 | 
			
		||||
	a := &Genres{
 | 
			
		||||
		BaseEndpoint[pb.Genre]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Genre]{
 | 
			
		||||
			endpointName: EPGenres,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewGenres(request RequestFunc) *Genres {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Genres) Query(query string) ([]*pb.Genre, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Genres) Query(ctx context.Context, query string) ([]*pb.Genre, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Genres) Query(query string) ([]*pb.Genre, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Genres) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Genres, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type InvolvedCompanies struct {
 | 
			
		||||
 | 
			
		||||
func NewInvolvedCompanies(request RequestFunc) *InvolvedCompanies {
 | 
			
		||||
	a := &InvolvedCompanies{
 | 
			
		||||
		BaseEndpoint[pb.InvolvedCompany]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.InvolvedCompany]{
 | 
			
		||||
			endpointName: EPInvolvedCompanies,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewInvolvedCompanies(request RequestFunc) *InvolvedCompanies {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *InvolvedCompanies) Query(query string) ([]*pb.InvolvedCompany, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *InvolvedCompanies) Query(ctx context.Context, query string) ([]*pb.InvolvedCompany, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *InvolvedCompanies) Query(query string) ([]*pb.InvolvedCompany, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Involvedcompanies) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Involvedcompanies, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type Keywords struct {
 | 
			
		||||
 | 
			
		||||
func NewKeywords(request RequestFunc) *Keywords {
 | 
			
		||||
	a := &Keywords{
 | 
			
		||||
		BaseEndpoint[pb.Keyword]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Keyword]{
 | 
			
		||||
			endpointName: EPKeywords,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewKeywords(request RequestFunc) *Keywords {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Keywords) Query(query string) ([]*pb.Keyword, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Keywords) Query(ctx context.Context, query string) ([]*pb.Keyword, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Keywords) Query(query string) ([]*pb.Keyword, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Keywords) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Keywords, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewLanguageSupportTypes(request RequestFunc) *LanguageSupportTypes {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *LanguageSupportTypes) Query(query string) ([]*pb.LanguageSupportType, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *LanguageSupportTypes) Query(ctx context.Context, query string) ([]*pb.LanguageSupportType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *LanguageSupportTypes) Query(query string) ([]*pb.LanguageSupportType, e
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Languagesupporttypes) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Languagesupporttypes, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type LanguageSupports struct {
 | 
			
		||||
 | 
			
		||||
func NewLanguageSupports(request RequestFunc) *LanguageSupports {
 | 
			
		||||
	a := &LanguageSupports{
 | 
			
		||||
		BaseEndpoint[pb.LanguageSupport]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.LanguageSupport]{
 | 
			
		||||
			endpointName: EPLanguageSupports,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewLanguageSupports(request RequestFunc) *LanguageSupports {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *LanguageSupports) Query(query string) ([]*pb.LanguageSupport, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *LanguageSupports) Query(ctx context.Context, query string) ([]*pb.LanguageSupport, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *LanguageSupports) Query(query string) ([]*pb.LanguageSupport, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Languagesupports) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Languagesupports, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type Languages struct {
 | 
			
		||||
 | 
			
		||||
func NewLanguages(request RequestFunc) *Languages {
 | 
			
		||||
	a := &Languages{
 | 
			
		||||
		BaseEndpoint[pb.Language]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Language]{
 | 
			
		||||
			endpointName: EPLanguages,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewLanguages(request RequestFunc) *Languages {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Languages) Query(query string) ([]*pb.Language, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Languages) Query(ctx context.Context, query string) ([]*pb.Language, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Languages) Query(query string) ([]*pb.Language, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Languages) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Languages, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type MultiplayerModes struct {
 | 
			
		||||
 | 
			
		||||
func NewMultiplayerModes(request RequestFunc) *MultiplayerModes {
 | 
			
		||||
	a := &MultiplayerModes{
 | 
			
		||||
		BaseEndpoint[pb.MultiplayerMode]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.MultiplayerMode]{
 | 
			
		||||
			endpointName: EPMultiplayerModes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewMultiplayerModes(request RequestFunc) *MultiplayerModes {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *MultiplayerModes) Query(query string) ([]*pb.MultiplayerMode, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *MultiplayerModes) Query(ctx context.Context, query string) ([]*pb.MultiplayerMode, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *MultiplayerModes) Query(query string) ([]*pb.MultiplayerMode, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Multiplayermodes) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Multiplayermodes, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type NetworkTypes struct {
 | 
			
		||||
 | 
			
		||||
func NewNetworkTypes(request RequestFunc) *NetworkTypes {
 | 
			
		||||
	a := &NetworkTypes{
 | 
			
		||||
		BaseEndpoint[pb.NetworkType]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.NetworkType]{
 | 
			
		||||
			endpointName: EPNetworkTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewNetworkTypes(request RequestFunc) *NetworkTypes {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *NetworkTypes) Query(query string) ([]*pb.NetworkType, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *NetworkTypes) Query(ctx context.Context, query string) ([]*pb.NetworkType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *NetworkTypes) Query(query string) ([]*pb.NetworkType, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Networktypes) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Networktypes, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type PlatformFamilies struct {
 | 
			
		||||
 | 
			
		||||
func NewPlatformFamilies(request RequestFunc) *PlatformFamilies {
 | 
			
		||||
	a := &PlatformFamilies{
 | 
			
		||||
		BaseEndpoint[pb.PlatformFamily]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformFamily]{
 | 
			
		||||
			endpointName: EPPlatformFamilies,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewPlatformFamilies(request RequestFunc) *PlatformFamilies {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformFamilies) Query(query string) ([]*pb.PlatformFamily, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *PlatformFamilies) Query(ctx context.Context, query string) ([]*pb.PlatformFamily, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *PlatformFamilies) Query(query string) ([]*pb.PlatformFamily, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Platformfamilies) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformfamilies, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type PlatformLogos struct {
 | 
			
		||||
 | 
			
		||||
func NewPlatformLogos(request RequestFunc) *PlatformLogos {
 | 
			
		||||
	a := &PlatformLogos{
 | 
			
		||||
		BaseEndpoint[pb.PlatformLogo]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformLogo]{
 | 
			
		||||
			endpointName: EPPlatformLogos,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewPlatformLogos(request RequestFunc) *PlatformLogos {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformLogos) Query(query string) ([]*pb.PlatformLogo, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *PlatformLogos) Query(ctx context.Context, query string) ([]*pb.PlatformLogo, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *PlatformLogos) Query(query string) ([]*pb.PlatformLogo, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Platformlogos) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformlogos, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type PlatformTypes struct {
 | 
			
		||||
 | 
			
		||||
func NewPlatformTypes(request RequestFunc) *PlatformTypes {
 | 
			
		||||
	a := &PlatformTypes{
 | 
			
		||||
		BaseEndpoint[pb.PlatformType]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformType]{
 | 
			
		||||
			endpointName: EPPlatformTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewPlatformTypes(request RequestFunc) *PlatformTypes {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformTypes) Query(query string) ([]*pb.PlatformType, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *PlatformTypes) Query(ctx context.Context, query string) ([]*pb.PlatformType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *PlatformTypes) Query(query string) ([]*pb.PlatformType, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Platformtypes) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformtypes, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type PlatformVersionCompanies struct {
 | 
			
		||||
 | 
			
		||||
func NewPlatformVersionCompanies(request RequestFunc) *PlatformVersionCompanies {
 | 
			
		||||
	a := &PlatformVersionCompanies{
 | 
			
		||||
		BaseEndpoint[pb.PlatformVersionCompany]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformVersionCompany]{
 | 
			
		||||
			endpointName: EPPlatformVersionCompanies,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewPlatformVersionCompanies(request RequestFunc) *PlatformVersionCompanies
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformVersionCompanies) Query(query string) ([]*pb.PlatformVersionCompany, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *PlatformVersionCompanies) Query(ctx context.Context, query string) ([]*pb.PlatformVersionCompany, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *PlatformVersionCompanies) Query(query string) ([]*pb.PlatformVersionCom
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Platformversioncompanies) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformversioncompanies, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type PlatformVersionReleaseDates struct {
 | 
			
		||||
 | 
			
		||||
func NewPlatformVersionReleaseDates(request RequestFunc) *PlatformVersionReleaseDates {
 | 
			
		||||
	a := &PlatformVersionReleaseDates{
 | 
			
		||||
		BaseEndpoint[pb.PlatformVersionReleaseDate]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformVersionReleaseDate]{
 | 
			
		||||
			endpointName: EPPlatformVersionReleaseDates,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewPlatformVersionReleaseDates(request RequestFunc) *PlatformVersionRelease
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformVersionReleaseDates) Query(query string) ([]*pb.PlatformVersionReleaseDate, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *PlatformVersionReleaseDates) Query(ctx context.Context, query string) ([]*pb.PlatformVersionReleaseDate, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *PlatformVersionReleaseDates) Query(query string) ([]*pb.PlatformVersion
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Platformversionreleasedates) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformversionreleasedates, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type PlatformVersions struct {
 | 
			
		||||
 | 
			
		||||
func NewPlatformVersions(request RequestFunc) *PlatformVersions {
 | 
			
		||||
	a := &PlatformVersions{
 | 
			
		||||
		BaseEndpoint[pb.PlatformVersion]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformVersion]{
 | 
			
		||||
			endpointName: EPPlatformVersions,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewPlatformVersions(request RequestFunc) *PlatformVersions {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformVersions) Query(query string) ([]*pb.PlatformVersion, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *PlatformVersions) Query(ctx context.Context, query string) ([]*pb.PlatformVersion, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *PlatformVersions) Query(query string) ([]*pb.PlatformVersion, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Platformversions) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformversions, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type PlatformWebsites struct {
 | 
			
		||||
 | 
			
		||||
func NewPlatformWebsites(request RequestFunc) *PlatformWebsites {
 | 
			
		||||
	a := &PlatformWebsites{
 | 
			
		||||
		BaseEndpoint[pb.PlatformWebsite]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformWebsite]{
 | 
			
		||||
			endpointName: EPPlatformWebsites,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewPlatformWebsites(request RequestFunc) *PlatformWebsites {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformWebsites) Query(query string) ([]*pb.PlatformWebsite, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *PlatformWebsites) Query(ctx context.Context, query string) ([]*pb.PlatformWebsite, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *PlatformWebsites) Query(query string) ([]*pb.PlatformWebsite, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Platformwebsites) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformwebsites, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewPlatforms(request RequestFunc) *Platforms {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Platforms) Query(query string) ([]*pb.Platform, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Platforms) Query(ctx context.Context, query string) ([]*pb.Platform, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,8 +35,5 @@ func (a *Platforms) Query(query string) ([]*pb.Platform, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Platforms) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
	return data.Platforms, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type PlayerPerspectives struct {
 | 
			
		||||
 | 
			
		||||
func NewPlayerPerspectives(request RequestFunc) *PlayerPerspectives {
 | 
			
		||||
	a := &PlayerPerspectives{
 | 
			
		||||
		BaseEndpoint[pb.PlayerPerspective]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlayerPerspective]{
 | 
			
		||||
			endpointName: EPPlayerPerspectives,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewPlayerPerspectives(request RequestFunc) *PlayerPerspectives {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlayerPerspectives) Query(query string) ([]*pb.PlayerPerspective, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *PlayerPerspectives) Query(ctx context.Context, query string) ([]*pb.PlayerPerspective, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *PlayerPerspectives) Query(query string) ([]*pb.PlayerPerspective, error
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Playerperspectives) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Playerperspectives, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewPopularityPrimitives(request RequestFunc) *PopularityPrimitives {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PopularityPrimitives) Query(query string) ([]*pb.PopularityPrimitive, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *PopularityPrimitives) Query(ctx context.Context, query string) ([]*pb.PopularityPrimitive, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *PopularityPrimitives) Query(query string) ([]*pb.PopularityPrimitive, e
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Popularityprimitives) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Popularityprimitives, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type PopularityTypes struct {
 | 
			
		||||
 | 
			
		||||
func NewPopularityTypes(request RequestFunc) *PopularityTypes {
 | 
			
		||||
	a := &PopularityTypes{
 | 
			
		||||
		BaseEndpoint[pb.PopularityType]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PopularityType]{
 | 
			
		||||
			endpointName: EPPopularityTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewPopularityTypes(request RequestFunc) *PopularityTypes {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PopularityTypes) Query(query string) ([]*pb.PopularityType, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *PopularityTypes) Query(ctx context.Context, query string) ([]*pb.PopularityType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *PopularityTypes) Query(query string) ([]*pb.PopularityType, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Popularitytypes) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Popularitytypes, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type Regions struct {
 | 
			
		||||
 | 
			
		||||
func NewRegions(request RequestFunc) *Regions {
 | 
			
		||||
	a := &Regions{
 | 
			
		||||
		BaseEndpoint[pb.Region]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Region]{
 | 
			
		||||
			endpointName: EPRegions,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewRegions(request RequestFunc) *Regions {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Regions) Query(query string) ([]*pb.Region, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Regions) Query(ctx context.Context, query string) ([]*pb.Region, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Regions) Query(query string) ([]*pb.Region, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Regions) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Regions, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type ReleaseDateRegions struct {
 | 
			
		||||
 | 
			
		||||
func NewReleaseDateRegions(request RequestFunc) *ReleaseDateRegions {
 | 
			
		||||
	a := &ReleaseDateRegions{
 | 
			
		||||
		BaseEndpoint[pb.ReleaseDateRegion]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.ReleaseDateRegion]{
 | 
			
		||||
			endpointName: EPReleaseDateRegions,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewReleaseDateRegions(request RequestFunc) *ReleaseDateRegions {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *ReleaseDateRegions) Query(query string) ([]*pb.ReleaseDateRegion, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *ReleaseDateRegions) Query(ctx context.Context, query string) ([]*pb.ReleaseDateRegion, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *ReleaseDateRegions) Query(query string) ([]*pb.ReleaseDateRegion, error
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Releasedateregions) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Releasedateregions, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type ReleaseDateStatuses struct {
 | 
			
		||||
 | 
			
		||||
func NewReleaseDateStatuses(request RequestFunc) *ReleaseDateStatuses {
 | 
			
		||||
	a := &ReleaseDateStatuses{
 | 
			
		||||
		BaseEndpoint[pb.ReleaseDateStatus]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.ReleaseDateStatus]{
 | 
			
		||||
			endpointName: EPReleaseDateStatuses,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewReleaseDateStatuses(request RequestFunc) *ReleaseDateStatuses {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *ReleaseDateStatuses) Query(query string) ([]*pb.ReleaseDateStatus, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *ReleaseDateStatuses) Query(ctx context.Context, query string) ([]*pb.ReleaseDateStatus, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *ReleaseDateStatuses) Query(query string) ([]*pb.ReleaseDateStatus, erro
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Releasedatestatuses) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Releasedatestatuses, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type ReleaseDates struct {
 | 
			
		||||
 | 
			
		||||
func NewReleaseDates(request RequestFunc) *ReleaseDates {
 | 
			
		||||
	a := &ReleaseDates{
 | 
			
		||||
		BaseEndpoint[pb.ReleaseDate]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.ReleaseDate]{
 | 
			
		||||
			endpointName: EPReleaseDates,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewReleaseDates(request RequestFunc) *ReleaseDates {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *ReleaseDates) Query(query string) ([]*pb.ReleaseDate, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *ReleaseDates) Query(ctx context.Context, query string) ([]*pb.ReleaseDate, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *ReleaseDates) Query(query string) ([]*pb.ReleaseDate, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Releasedates) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Releasedates, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type Screenshots struct {
 | 
			
		||||
 | 
			
		||||
func NewScreenshots(request RequestFunc) *Screenshots {
 | 
			
		||||
	a := &Screenshots{
 | 
			
		||||
		BaseEndpoint[pb.Screenshot]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Screenshot]{
 | 
			
		||||
			endpointName: EPScreenshots,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewScreenshots(request RequestFunc) *Screenshots {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Screenshots) Query(query string) ([]*pb.Screenshot, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Screenshots) Query(ctx context.Context, query string) ([]*pb.Screenshot, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Screenshots) Query(query string) ([]*pb.Screenshot, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Screenshots) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Screenshots, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
@@ -9,7 +10,7 @@ import (
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"github.com/PuerkitoBio/goquery"
 | 
			
		||||
	"github.com/bestnite/go-flaresolverr"
 | 
			
		||||
@@ -34,8 +35,8 @@ func NewSearch(request RequestFunc) *Search {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Search) Search(query string) ([]*pb.Search, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Search) Search(ctx context.Context, query string) ([]*pb.Search, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -45,10 +46,6 @@ func (a *Search) Search(query string) ([]*pb.Search, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Searches) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Searches, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type Themes struct {
 | 
			
		||||
 | 
			
		||||
func NewThemes(request RequestFunc) *Themes {
 | 
			
		||||
	a := &Themes{
 | 
			
		||||
		BaseEndpoint[pb.Theme]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Theme]{
 | 
			
		||||
			endpointName: EPThemes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewThemes(request RequestFunc) *Themes {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Themes) Query(query string) ([]*pb.Theme, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Themes) Query(ctx context.Context, query string) ([]*pb.Theme, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Themes) Query(query string) ([]*pb.Theme, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Themes) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Themes, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
@@ -37,13 +38,13 @@ type WebhookResponse struct {
 | 
			
		||||
	UpdatedAt   string `json:"updated_at"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Webhooks) Register(endpoint Name, secret, callbackUrl string, method WebhookMethod) (*WebhookResponse, error) {
 | 
			
		||||
func (a *Webhooks) Register(ctx context.Context, endpoint Name, secret, callbackUrl string, method WebhookMethod) (*WebhookResponse, error) {
 | 
			
		||||
	dataBody := url.Values{}
 | 
			
		||||
	dataBody.Set("url", callbackUrl)
 | 
			
		||||
	dataBody.Set("secret", secret)
 | 
			
		||||
	dataBody.Set("method", string(method))
 | 
			
		||||
 | 
			
		||||
	resp, err := a.request("POST", 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 {
 | 
			
		||||
		return nil, fmt.Errorf("failed to make request: %s: %w", callbackUrl, err)
 | 
			
		||||
@@ -61,8 +62,8 @@ func (a *Webhooks) Register(endpoint Name, secret, callbackUrl string, method We
 | 
			
		||||
	return &data, fmt.Errorf("failed to activate webhook: %s: %s", callbackUrl, resp.String())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Webhooks) Unregister(webhookId uint64) error {
 | 
			
		||||
	resp, err := a.request("DELETE", fmt.Sprintf("https://api.igdb.com/v4/webhooks/%v", webhookId), "")
 | 
			
		||||
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)
 | 
			
		||||
	}
 | 
			
		||||
@@ -74,8 +75,8 @@ func (a *Webhooks) Unregister(webhookId uint64) error {
 | 
			
		||||
	return fmt.Errorf("failed to unregister webhook: %s", resp.String())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Webhooks) List() ([]*WebhookResponse, error) {
 | 
			
		||||
	resp, err := a.request("GET", "https://api.igdb.com/v4/webhooks/", "")
 | 
			
		||||
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)
 | 
			
		||||
	}
 | 
			
		||||
@@ -88,8 +89,8 @@ func (a *Webhooks) List() ([]*WebhookResponse, error) {
 | 
			
		||||
	return data, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Webhooks) Get(webhookId uint64) (*WebhookResponse, error) {
 | 
			
		||||
	resp, err := a.request("GET", fmt.Sprintf("https://api.igdb.com/v4/webhooks/%v", webhookId), "")
 | 
			
		||||
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)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type WebsiteTypes struct {
 | 
			
		||||
 | 
			
		||||
func NewWebsiteTypes(request RequestFunc) *WebsiteTypes {
 | 
			
		||||
	a := &WebsiteTypes{
 | 
			
		||||
		BaseEndpoint[pb.WebsiteType]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.WebsiteType]{
 | 
			
		||||
			endpointName: EPWebsiteTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewWebsiteTypes(request RequestFunc) *WebsiteTypes {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *WebsiteTypes) Query(query string) ([]*pb.WebsiteType, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *WebsiteTypes) Query(ctx context.Context, query string) ([]*pb.WebsiteType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *WebsiteTypes) Query(query string) ([]*pb.WebsiteType, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Websitetypes) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Websitetypes, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
@@ -14,7 +15,7 @@ type Websites struct {
 | 
			
		||||
 | 
			
		||||
func NewWebsites(request RequestFunc) *Websites {
 | 
			
		||||
	a := &Websites{
 | 
			
		||||
		BaseEndpoint[pb.Website]{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Website]{
 | 
			
		||||
			endpointName: EPWebsites,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
@@ -23,8 +24,8 @@ func NewWebsites(request RequestFunc) *Websites {
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Websites) Query(query string) ([]*pb.Website, error) {
 | 
			
		||||
	resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
func (a *Websites) Query(ctx context.Context, query string) ([]*pb.Website, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,9 +35,5 @@ func (a *Websites) Query(query string) ([]*pb.Website, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Websites) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Websites, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								go.mod
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
module github.com/bestnite/go-igdb
 | 
			
		||||
module git.nite07.com/nite/go-igdb
 | 
			
		||||
 | 
			
		||||
go 1.24.1
 | 
			
		||||
 | 
			
		||||
@@ -6,6 +6,7 @@ require (
 | 
			
		||||
	github.com/PuerkitoBio/goquery v1.10.2
 | 
			
		||||
	github.com/bestnite/go-flaresolverr v0.0.0-20250404141941-4644c2e66727
 | 
			
		||||
	github.com/go-resty/resty/v2 v2.16.5
 | 
			
		||||
	golang.org/x/time v0.14.0
 | 
			
		||||
	google.golang.org/protobuf v1.36.6
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								go.sum
									
									
									
									
									
								
							@@ -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/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.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
 | 
			
		||||
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
 | 
			
		||||
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
 | 
			
		||||
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-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
			
		||||
golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5845
									
								
								proto/igdbapi.pb.go
									
									
									
									
									
								
							
							
						
						
									
										5845
									
								
								proto/igdbapi.pb.go
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -209,6 +209,19 @@ enum AgeRatingContentDescriptionCategoryEnum {
 | 
			
		||||
    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 {
 | 
			
		||||
    repeated AgeRatingContentDescriptionV2 ageratingcontentdescriptionsv2 = 1;
 | 
			
		||||
}
 | 
			
		||||
@@ -220,6 +233,7 @@ message AgeRatingContentDescriptionV2 {
 | 
			
		||||
    google.protobuf.Timestamp created_at = 4; 
 | 
			
		||||
    google.protobuf.Timestamp updated_at = 5; 
 | 
			
		||||
    string checksum = 6; 
 | 
			
		||||
    AgeRatingContentDescriptionType description_type = 7; 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
message AgeRatingOrganizationResult {
 | 
			
		||||
@@ -260,6 +274,20 @@ message Artwork {
 | 
			
		||||
    string url = 7; 
 | 
			
		||||
    int32 width = 8; 
 | 
			
		||||
    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 {
 | 
			
		||||
@@ -1342,6 +1370,7 @@ message ReleaseDate {
 | 
			
		||||
    ReleaseDateStatus status = 13; 
 | 
			
		||||
    DateFormat date_format = 14; 
 | 
			
		||||
    ReleaseDateRegion release_region = 15; 
 | 
			
		||||
    int32 d = 16; 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
message ReleaseDateRegionResult {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
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
 | 
			
		||||
 
 | 
			
		||||
@@ -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--
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/bestnite/go-igdb/endpoint"
 | 
			
		||||
	"git.nite07.com/nite/go-igdb/endpoint"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func registerAllEndpoints(c *Client) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								request.go
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								request.go
									
									
									
									
									
								
							@@ -7,23 +7,19 @@ import (
 | 
			
		||||
	"github.com/go-resty/resty/v2"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var client *resty.Client
 | 
			
		||||
type SilentLogger struct{}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	client = resty.New()
 | 
			
		||||
	client.SetRetryCount(3).SetRetryWaitTime(3 * time.Second).AddRetryCondition(
 | 
			
		||||
func (s SilentLogger) Errorf(string, ...any) {}
 | 
			
		||||
func (s SilentLogger) Warnf(string, ...any)  {}
 | 
			
		||||
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 {
 | 
			
		||||
			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{}) {}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								token.go
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								token.go
									
									
									
									
									
								
							@@ -1,31 +1,32 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type TwitchToken struct {
 | 
			
		||||
type twitchToken struct {
 | 
			
		||||
	clientID     string
 | 
			
		||||
	clientSecret string
 | 
			
		||||
	token        string
 | 
			
		||||
	expires      time.Time
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewTwitchToken(clientID, clientSecret string) *TwitchToken {
 | 
			
		||||
	return &TwitchToken{
 | 
			
		||||
func newTwitchToken(clientID, clientSecret string) *twitchToken {
 | 
			
		||||
	return &twitchToken{
 | 
			
		||||
		clientID:     clientID,
 | 
			
		||||
		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) {
 | 
			
		||||
		return t.token, nil
 | 
			
		||||
	}
 | 
			
		||||
	token, expires, err := t.loginTwitch()
 | 
			
		||||
	token, expires, err := t.LoginTwitch(ctx)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", fmt.Errorf("failed to login twitch: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -34,7 +35,7 @@ func (t *TwitchToken) getToken() (string, error) {
 | 
			
		||||
	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")
 | 
			
		||||
	params := url.Values{}
 | 
			
		||||
	params.Add("client_id", t.clientID)
 | 
			
		||||
@@ -42,7 +43,7 @@ func (t *TwitchToken) loginTwitch() (string, time.Duration, error) {
 | 
			
		||||
	params.Add("grant_type", "client_credentials")
 | 
			
		||||
	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 {
 | 
			
		||||
		return "", 0, fmt.Errorf("failed to make request: %s: %w", baseURL.String(), err)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user