mirror of
https://github.com/bestnite/go-igdb.git
synced 2025-04-19 23:35:54 +08:00
u
This commit is contained in:
parent
3d28910178
commit
fb58744928
@ -45,7 +45,7 @@ func Test2(c *igdb.Client) {
|
||||
}
|
||||
|
||||
func Test3(c *igdb.Client) {
|
||||
total, err := c.Games.GetLastOneId()
|
||||
total, err := c.Games.Count()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
41
assert.go
41
assert.go
@ -1,41 +0,0 @@
|
||||
package igdb
|
||||
|
||||
import "fmt"
|
||||
|
||||
func AssertSingle[T any](data any, err error) (*T, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return nil, fmt.Errorf("data is nil")
|
||||
}
|
||||
|
||||
datas, ok := data.([]*T)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to convert to []*T")
|
||||
}
|
||||
|
||||
if len(datas) == 0 {
|
||||
return nil, fmt.Errorf("no results")
|
||||
}
|
||||
|
||||
return datas[0], nil
|
||||
}
|
||||
|
||||
func AssertSlice[T any](data any, err error) ([]*T, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return nil, fmt.Errorf("data is nil")
|
||||
}
|
||||
|
||||
datas, ok := data.([]*T)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to convert to []*T")
|
||||
}
|
||||
|
||||
return datas, nil
|
||||
}
|
@ -11,7 +11,7 @@ import (
|
||||
|
||||
type Client struct {
|
||||
clientID string
|
||||
token *twitchToken
|
||||
token *TwitchToken
|
||||
flaresolverr *flaresolverr.Flaresolverr
|
||||
limiter *rateLimiter
|
||||
|
||||
|
@ -25,7 +25,7 @@ func NewAgeRatingCategories(request func(URL string, dataBody any) (*resty.Respo
|
||||
}
|
||||
|
||||
func (a *AgeRatingCategories) Query(query string) ([]*pb.AgeRatingCategory, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/age_rating_categories.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewAgeRatingContentDescriptions(request func(URL string, dataBody any) (*re
|
||||
}
|
||||
|
||||
func (a *AgeRatingContentDescriptions) Query(query string) ([]*pb.AgeRatingContentDescription, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/age_rating_content_descriptions.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewAgeRatingContentDescriptionsV2(request func(URL string, dataBody any) (*
|
||||
}
|
||||
|
||||
func (a *AgeRatingContentDescriptionsV2) Query(query string) ([]*pb.AgeRatingContentDescriptionV2, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/age_rating_content_descriptions_v2.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewAgeRatingOrganizations(request func(URL string, dataBody any) (*resty.Re
|
||||
}
|
||||
|
||||
func (a *AgeRatingOrganizations) Query(query string) ([]*pb.AgeRatingOrganization, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/age_rating_organizations.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewAgeRatings(request func(URL string, dataBody any) (*resty.Response, erro
|
||||
}
|
||||
|
||||
func (a *AgeRatings) Query(query string) ([]*pb.AgeRating, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/age_ratings.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewAlternativeNames(request func(URL string, dataBody any) (*resty.Response
|
||||
}
|
||||
|
||||
func (a *AlternativeNames) Query(query string) ([]*pb.AlternativeName, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/alternative_names.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewArtworks(request func(URL string, dataBody any) (*resty.Response, error)
|
||||
}
|
||||
|
||||
func (a *Artworks) Query(query string) ([]*pb.Artwork, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/artworks.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package endpoint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
pb "github.com/bestnite/go-igdb/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@ -10,17 +12,17 @@ import (
|
||||
|
||||
type BaseEndpoint[T any] struct {
|
||||
request func(URL string, dataBody any) (*resty.Response, error)
|
||||
endpointName EndpointName
|
||||
endpointName Name
|
||||
queryFunc func(string) ([]*T, error)
|
||||
}
|
||||
|
||||
func (b *BaseEndpoint[T]) GetEndpointName() EndpointName {
|
||||
func (b *BaseEndpoint[T]) GetEndpointName() Name {
|
||||
return b.endpointName
|
||||
}
|
||||
|
||||
func (b *BaseEndpoint[T]) Query(query string) ([]*T, error) {
|
||||
if b.queryFunc == nil {
|
||||
return nil, fmt.Errorf("Query method must be implemented by specific endpoint")
|
||||
return nil, fmt.Errorf("query method must be implemented by specific endpoint")
|
||||
}
|
||||
return b.queryFunc(query)
|
||||
}
|
||||
@ -47,22 +49,18 @@ func (b *BaseEndpoint[T]) GetByIDs(ids []uint64) ([]*T, error) {
|
||||
return b.Query(fmt.Sprintf("where id = (%s); fields *;", builder.String()))
|
||||
}
|
||||
|
||||
func (b *BaseEndpoint[T]) GetLastOneId() (uint64, error) {
|
||||
res, err := b.Query("fields *; sort id desc; limit 1;")
|
||||
func (b *BaseEndpoint[T]) Count() (uint64, error) {
|
||||
resp, err := b.request(fmt.Sprintf("https://api.igdb.com/v4/%s/count.pb", b.endpointName), "")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return 0, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
if len(res) == 0 {
|
||||
return 0, fmt.Errorf("no results")
|
||||
|
||||
var res pb.Count
|
||||
if err = proto.Unmarshal(resp.Body(), &res); err != nil {
|
||||
return 0, fmt.Errorf("failed to unmarshal: %w", err)
|
||||
}
|
||||
type IdGetter interface {
|
||||
GetId() uint64
|
||||
}
|
||||
item, ok := any(res[0]).(IdGetter)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("invalid type")
|
||||
}
|
||||
return item.GetId(), nil
|
||||
|
||||
return uint64(res.Count), nil
|
||||
}
|
||||
|
||||
func (b *BaseEndpoint[T]) Paginated(offset, limit uint64) ([]*T, error) {
|
||||
@ -70,7 +68,7 @@ func (b *BaseEndpoint[T]) Paginated(offset, limit uint64) ([]*T, error) {
|
||||
}
|
||||
|
||||
type EntityEndpoint[T any] interface {
|
||||
GetEndpointName() EndpointName
|
||||
GetEndpointName() Name
|
||||
Query(string) ([]*T, error)
|
||||
GetByID(uint64) (*T, error)
|
||||
GetByIDs([]uint64) ([]*T, error)
|
||||
|
@ -25,7 +25,7 @@ func NewCharacterGenders(request func(URL string, dataBody any) (*resty.Response
|
||||
}
|
||||
|
||||
func (a *CharacterGenders) Query(query string) ([]*pb.CharacterGender, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/character_genders.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewCharacterMugShots(request func(URL string, dataBody any) (*resty.Respons
|
||||
}
|
||||
|
||||
func (a *CharacterMugShots) Query(query string) ([]*pb.CharacterMugShot, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/character_mug_shots.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewCharacterSpecies(request func(URL string, dataBody any) (*resty.Response
|
||||
}
|
||||
|
||||
func (a *CharacterSpecies) Query(query string) ([]*pb.CharacterSpecie, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/character_species.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewCharacters(request func(URL string, dataBody any) (*resty.Response, erro
|
||||
}
|
||||
|
||||
func (a *Characters) Query(query string) ([]*pb.Character, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/characters.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewCollectionMembershipTypes(request func(URL string, dataBody any) (*resty
|
||||
}
|
||||
|
||||
func (a *CollectionMembershipTypes) Query(query string) ([]*pb.CollectionMembershipType, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/collection_membership_types.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewCollectionMemberships(request func(URL string, dataBody any) (*resty.Res
|
||||
}
|
||||
|
||||
func (a *CollectionMemberships) Query(query string) ([]*pb.CollectionMembership, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/collection_memberships.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewCollectionRelationTypes(request func(URL string, dataBody any) (*resty.R
|
||||
}
|
||||
|
||||
func (a *CollectionRelationTypes) Query(query string) ([]*pb.CollectionRelationType, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/collection_relation_types.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewCollectionRelations(request func(URL string, dataBody any) (*resty.Respo
|
||||
}
|
||||
|
||||
func (a *CollectionRelations) Query(query string) ([]*pb.CollectionRelation, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/collection_relations.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewCollectionTypes(request func(URL string, dataBody any) (*resty.Response,
|
||||
}
|
||||
|
||||
func (a *CollectionTypes) Query(query string) ([]*pb.CollectionType, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/collection_types.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewCollections(request func(URL string, dataBody any) (*resty.Response, err
|
||||
}
|
||||
|
||||
func (a *Collections) Query(query string) ([]*pb.Collection, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/collections.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ func NewCompanies(request func(URL string, dataBody any) (*resty.Response, error
|
||||
}
|
||||
|
||||
func (a *Companies) Query(query string) ([]*pb.Company, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/companies.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewCompanyLogos(request func(URL string, dataBody any) (*resty.Response, er
|
||||
}
|
||||
|
||||
func (a *CompanyLogos) Query(query string) ([]*pb.CompanyLogo, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/company_logos.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewCompanyStatuses(request func(URL string, dataBody any) (*resty.Response,
|
||||
}
|
||||
|
||||
func (a *CompanyStatuses) Query(query string) ([]*pb.CompanyStatus, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/company_statuses.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewCompanyWebsites(request func(URL string, dataBody any) (*resty.Response,
|
||||
}
|
||||
|
||||
func (a *CompanyWebsites) Query(query string) ([]*pb.CompanyWebsite, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/company_websites.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewCovers(request func(URL string, dataBody any) (*resty.Response, error))
|
||||
}
|
||||
|
||||
func (a *Covers) Query(query string) ([]*pb.Cover, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/covers.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewDateFormats(request func(URL string, dataBody any) (*resty.Response, err
|
||||
}
|
||||
|
||||
func (a *DateFormats) Query(query string) ([]*pb.DateFormat, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/date_formats.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -1,82 +1,82 @@
|
||||
package endpoint
|
||||
|
||||
type EndpointName string
|
||||
type Name string
|
||||
|
||||
var (
|
||||
EPAgeRatingCategories EndpointName = "age_rating_categories"
|
||||
EPAgeRatingContentDescriptions EndpointName = "age_rating_content_descriptions"
|
||||
EPAgeRatingContentDescriptionsV2 EndpointName = "age_rating_content_descriptions_v2"
|
||||
EPAgeRatingOrganizations EndpointName = "age_rating_organizations"
|
||||
EPAgeRatings EndpointName = "age_ratings"
|
||||
EPAlternativeNames EndpointName = "alternative_names"
|
||||
EPArtworks EndpointName = "artworks"
|
||||
EPCharacterGenders EndpointName = "character_genders"
|
||||
EPCharacterMugShots EndpointName = "character_mug_shots"
|
||||
EPCharacters EndpointName = "characters"
|
||||
EPCharacterSpecies EndpointName = "character_species"
|
||||
EPCollectionMemberships EndpointName = "collection_memberships"
|
||||
EPCollectionMembershipTypes EndpointName = "collection_membership_types"
|
||||
EPCollectionRelations EndpointName = "collection_relations"
|
||||
EPCollectionRelationTypes EndpointName = "collection_relation_types"
|
||||
EPCollections EndpointName = "collections"
|
||||
EPCollectionTypes EndpointName = "collection_types"
|
||||
EPCompanies EndpointName = "companies"
|
||||
EPCompanyLogos EndpointName = "company_logos"
|
||||
EPCompanyStatuses EndpointName = "company_statuses"
|
||||
EPCompanyWebsites EndpointName = "company_websites"
|
||||
EPCovers EndpointName = "covers"
|
||||
EPDateFormats EndpointName = "date_formats"
|
||||
EPEventLogos EndpointName = "event_logos"
|
||||
EPEventNetworks EndpointName = "event_networks"
|
||||
EPEvents EndpointName = "events"
|
||||
EPExternalGames EndpointName = "external_games"
|
||||
EPExternalGameSources EndpointName = "external_game_sources"
|
||||
EPFranchises EndpointName = "franchises"
|
||||
EPGameEngineLogos EndpointName = "game_engine_logos"
|
||||
EPGameEngines EndpointName = "game_engines"
|
||||
EPGameLocalizations EndpointName = "game_localizations"
|
||||
EPGameModes EndpointName = "game_modes"
|
||||
EPGameReleaseFormats EndpointName = "game_release_formats"
|
||||
EPGames EndpointName = "games"
|
||||
EPGameStatuses EndpointName = "game_statuses"
|
||||
EPGameTimeToBeats EndpointName = "game_time_to_beats"
|
||||
EPGameTypes EndpointName = "game_types"
|
||||
EPGameVersionFeatures EndpointName = "game_version_features"
|
||||
EPGameVersionFeatureValues EndpointName = "game_version_feature_values"
|
||||
EPGameVersions EndpointName = "game_versions"
|
||||
EPGameVideos EndpointName = "game_videos"
|
||||
EPGenres EndpointName = "genres"
|
||||
EPInvolvedCompanies EndpointName = "involved_companies"
|
||||
EPKeywords EndpointName = "keywords"
|
||||
EPLanguages EndpointName = "languages"
|
||||
EPLanguageSupports EndpointName = "language_supports"
|
||||
EPLanguageSupportTypes EndpointName = "language_support_types"
|
||||
EPMultiplayerModes EndpointName = "multiplayer_modes"
|
||||
EPNetworkTypes EndpointName = "network_types"
|
||||
EPPlatformFamilies EndpointName = "platform_families"
|
||||
EPPlatformLogos EndpointName = "platform_logos"
|
||||
EPPlatforms EndpointName = "platforms"
|
||||
EPPlatformTypes EndpointName = "platform_types"
|
||||
EPPlatformVersionCompanies EndpointName = "platform_version_companies"
|
||||
EPPlatformVersionReleaseDates EndpointName = "platform_version_release_dates"
|
||||
EPPlatformVersions EndpointName = "platform_versions"
|
||||
EPPlatformWebsites EndpointName = "platform_websites"
|
||||
EPPlayerPerspectives EndpointName = "player_perspectives"
|
||||
EPPopularityPrimitives EndpointName = "popularity_primitives"
|
||||
EPPopularityTypes EndpointName = "popularity_types"
|
||||
EPRegions EndpointName = "regions"
|
||||
EPReleaseDateRegions EndpointName = "release_date_regions"
|
||||
EPReleaseDates EndpointName = "release_dates"
|
||||
EPReleaseDateStatuses EndpointName = "release_date_statuses"
|
||||
EPScreenshots EndpointName = "screenshots"
|
||||
EPSearch EndpointName = "search"
|
||||
EPThemes EndpointName = "themes"
|
||||
EPWebhooks EndpointName = "webhooks"
|
||||
EPWebsites EndpointName = "websites"
|
||||
EPWebsiteTypes EndpointName = "website_types"
|
||||
EPAgeRatingCategories Name = "age_rating_categories"
|
||||
EPAgeRatingContentDescriptions Name = "age_rating_content_descriptions"
|
||||
EPAgeRatingContentDescriptionsV2 Name = "age_rating_content_descriptions_v2"
|
||||
EPAgeRatingOrganizations Name = "age_rating_organizations"
|
||||
EPAgeRatings Name = "age_ratings"
|
||||
EPAlternativeNames Name = "alternative_names"
|
||||
EPArtworks Name = "artworks"
|
||||
EPCharacterGenders Name = "character_genders"
|
||||
EPCharacterMugShots Name = "character_mug_shots"
|
||||
EPCharacters Name = "characters"
|
||||
EPCharacterSpecies Name = "character_species"
|
||||
EPCollectionMemberships Name = "collection_memberships"
|
||||
EPCollectionMembershipTypes Name = "collection_membership_types"
|
||||
EPCollectionRelations Name = "collection_relations"
|
||||
EPCollectionRelationTypes Name = "collection_relation_types"
|
||||
EPCollections Name = "collections"
|
||||
EPCollectionTypes Name = "collection_types"
|
||||
EPCompanies Name = "companies"
|
||||
EPCompanyLogos Name = "company_logos"
|
||||
EPCompanyStatuses Name = "company_statuses"
|
||||
EPCompanyWebsites Name = "company_websites"
|
||||
EPCovers Name = "covers"
|
||||
EPDateFormats Name = "date_formats"
|
||||
EPEventLogos Name = "event_logos"
|
||||
EPEventNetworks Name = "event_networks"
|
||||
EPEvents Name = "events"
|
||||
EPExternalGames Name = "external_games"
|
||||
EPExternalGameSources Name = "external_game_sources"
|
||||
EPFranchises Name = "franchises"
|
||||
EPGameEngineLogos Name = "game_engine_logos"
|
||||
EPGameEngines Name = "game_engines"
|
||||
EPGameLocalizations Name = "game_localizations"
|
||||
EPGameModes Name = "game_modes"
|
||||
EPGameReleaseFormats Name = "game_release_formats"
|
||||
EPGames Name = "games"
|
||||
EPGameStatuses Name = "game_statuses"
|
||||
EPGameTimeToBeats Name = "game_time_to_beats"
|
||||
EPGameTypes Name = "game_types"
|
||||
EPGameVersionFeatures Name = "game_version_features"
|
||||
EPGameVersionFeatureValues Name = "game_version_feature_values"
|
||||
EPGameVersions Name = "game_versions"
|
||||
EPGameVideos Name = "game_videos"
|
||||
EPGenres Name = "genres"
|
||||
EPInvolvedCompanies Name = "involved_companies"
|
||||
EPKeywords Name = "keywords"
|
||||
EPLanguages Name = "languages"
|
||||
EPLanguageSupports Name = "language_supports"
|
||||
EPLanguageSupportTypes Name = "language_support_types"
|
||||
EPMultiplayerModes Name = "multiplayer_modes"
|
||||
EPNetworkTypes Name = "network_types"
|
||||
EPPlatformFamilies Name = "platform_families"
|
||||
EPPlatformLogos Name = "platform_logos"
|
||||
EPPlatforms Name = "platforms"
|
||||
EPPlatformTypes Name = "platform_types"
|
||||
EPPlatformVersionCompanies Name = "platform_version_companies"
|
||||
EPPlatformVersionReleaseDates Name = "platform_version_release_dates"
|
||||
EPPlatformVersions Name = "platform_versions"
|
||||
EPPlatformWebsites Name = "platform_websites"
|
||||
EPPlayerPerspectives Name = "player_perspectives"
|
||||
EPPopularityPrimitives Name = "popularity_primitives"
|
||||
EPPopularityTypes Name = "popularity_types"
|
||||
EPRegions Name = "regions"
|
||||
EPReleaseDateRegions Name = "release_date_regions"
|
||||
EPReleaseDates Name = "release_dates"
|
||||
EPReleaseDateStatuses Name = "release_date_statuses"
|
||||
EPScreenshots Name = "screenshots"
|
||||
EPSearch Name = "search"
|
||||
EPThemes Name = "themes"
|
||||
EPWebhooks Name = "webhooks"
|
||||
EPWebsites Name = "websites"
|
||||
EPWebsiteTypes Name = "website_types"
|
||||
)
|
||||
|
||||
var AllEndpoints = []EndpointName{
|
||||
var AllNames = []Name{
|
||||
EPAgeRatingCategories,
|
||||
EPAgeRatingContentDescriptions,
|
||||
EPAgeRatingContentDescriptionsV2,
|
||||
|
@ -25,7 +25,7 @@ func NewEventLogos(request func(URL string, dataBody any) (*resty.Response, erro
|
||||
}
|
||||
|
||||
func (a *EventLogos) Query(query string) ([]*pb.EventLogo, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/event_logos.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewEventNetworks(request func(URL string, dataBody any) (*resty.Response, e
|
||||
}
|
||||
|
||||
func (a *EventNetworks) Query(query string) ([]*pb.EventNetwork, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/event_networks.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewEvents(request func(URL string, dataBody any) (*resty.Response, error))
|
||||
}
|
||||
|
||||
func (a *Events) Query(query string) ([]*pb.Event, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/events.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewExternalGameSources(request func(URL string, dataBody any) (*resty.Respo
|
||||
}
|
||||
|
||||
func (a *ExternalGameSources) Query(query string) ([]*pb.ExternalGameSource, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/external_game_sources.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewExternalGames(request func(URL string, dataBody any) (*resty.Response, e
|
||||
}
|
||||
|
||||
func (a *ExternalGames) Query(query string) ([]*pb.ExternalGame, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/external_games.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewFranchises(request func(URL string, dataBody any) (*resty.Response, erro
|
||||
}
|
||||
|
||||
func (a *Franchises) Query(query string) ([]*pb.Franchise, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/franchises.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGameEngineLogos(request func(URL string, dataBody any) (*resty.Response,
|
||||
}
|
||||
|
||||
func (a *GameEngineLogos) Query(query string) ([]*pb.GameEngineLogo, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_engine_logos.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGameEngines(request func(URL string, dataBody any) (*resty.Response, err
|
||||
}
|
||||
|
||||
func (a *GameEngines) Query(query string) ([]*pb.GameEngine, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_engines.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGameLocalizations(request func(URL string, dataBody any) (*resty.Respons
|
||||
}
|
||||
|
||||
func (a *GameLocalizations) Query(query string) ([]*pb.GameLocalization, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_localizations.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGameModes(request func(URL string, dataBody any) (*resty.Response, error
|
||||
}
|
||||
|
||||
func (a *GameModes) Query(query string) ([]*pb.GameMode, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_modes.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGameReleaseFormats(request func(URL string, dataBody any) (*resty.Respon
|
||||
}
|
||||
|
||||
func (a *GameReleaseFormats) Query(query string) ([]*pb.GameReleaseFormat, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_release_formats.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGameStatuses(request func(URL string, dataBody any) (*resty.Response, er
|
||||
}
|
||||
|
||||
func (a *GameStatuses) Query(query string) ([]*pb.GameStatus, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_statuses.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGameTimeToBeats(request func(URL string, dataBody any) (*resty.Response,
|
||||
}
|
||||
|
||||
func (a *GameTimeToBeats) Query(query string) ([]*pb.GameTimeToBeat, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_time_to_beats.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGameTypes(request func(URL string, dataBody any) (*resty.Response, error
|
||||
}
|
||||
|
||||
func (a *GameTypes) Query(query string) ([]*pb.GameType, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_types.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGameVersionFeatureValues(request func(URL string, dataBody any) (*resty.
|
||||
}
|
||||
|
||||
func (a *GameVersionFeatureValues) Query(query string) ([]*pb.GameVersionFeatureValue, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_version_feature_values.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGameVersionFeatures(request func(URL string, dataBody any) (*resty.Respo
|
||||
}
|
||||
|
||||
func (a *GameVersionFeatures) Query(query string) ([]*pb.GameVersionFeature, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_version_features.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGameVersions(request func(URL string, dataBody any) (*resty.Response, er
|
||||
}
|
||||
|
||||
func (a *GameVersions) Query(query string) ([]*pb.GameVersion, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_versions.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGameVideos(request func(URL string, dataBody any) (*resty.Response, erro
|
||||
}
|
||||
|
||||
func (a *GameVideos) Query(query string) ([]*pb.GameVideo, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_videos.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGames(request func(URL string, dataBody any) (*resty.Response, error)) *
|
||||
}
|
||||
|
||||
func (a *Games) Query(query string) ([]*pb.Game, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/games.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewGenres(request func(URL string, dataBody any) (*resty.Response, error))
|
||||
}
|
||||
|
||||
func (a *Genres) Query(query string) ([]*pb.Genre, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/genres.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewInvolvedCompanies(request func(URL string, dataBody any) (*resty.Respons
|
||||
}
|
||||
|
||||
func (a *InvolvedCompanies) Query(query string) ([]*pb.InvolvedCompany, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/involved_companies.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewKeywords(request func(URL string, dataBody any) (*resty.Response, error)
|
||||
}
|
||||
|
||||
func (a *Keywords) Query(query string) ([]*pb.Keyword, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/keywords.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewLanguageSupportTypes(request func(URL string, dataBody any) (*resty.Resp
|
||||
}
|
||||
|
||||
func (a *LanguageSupportTypes) Query(query string) ([]*pb.LanguageSupportType, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/language_support_types.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewLanguageSupports(request func(URL string, dataBody any) (*resty.Response
|
||||
}
|
||||
|
||||
func (a *LanguageSupports) Query(query string) ([]*pb.LanguageSupport, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/language_supports.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewLanguages(request func(URL string, dataBody any) (*resty.Response, error
|
||||
}
|
||||
|
||||
func (a *Languages) Query(query string) ([]*pb.Language, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/languages.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewMultiplayerModes(request func(URL string, dataBody any) (*resty.Response
|
||||
}
|
||||
|
||||
func (a *MultiplayerModes) Query(query string) ([]*pb.MultiplayerMode, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/multiplayer_modes.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewNetworkTypes(request func(URL string, dataBody any) (*resty.Response, er
|
||||
}
|
||||
|
||||
func (a *NetworkTypes) Query(query string) ([]*pb.NetworkType, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/network_types.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewPlatformFamilies(request func(URL string, dataBody any) (*resty.Response
|
||||
}
|
||||
|
||||
func (a *PlatformFamilies) Query(query string) ([]*pb.PlatformFamily, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_families.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewPlatformLogos(request func(URL string, dataBody any) (*resty.Response, e
|
||||
}
|
||||
|
||||
func (a *PlatformLogos) Query(query string) ([]*pb.PlatformLogo, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_logos.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewPlatformTypes(request func(URL string, dataBody any) (*resty.Response, e
|
||||
}
|
||||
|
||||
func (a *PlatformTypes) Query(query string) ([]*pb.PlatformType, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_types.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewPlatformVersionCompanies(request func(URL string, dataBody any) (*resty.
|
||||
}
|
||||
|
||||
func (a *PlatformVersionCompanies) Query(query string) ([]*pb.PlatformVersionCompany, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_version_companies.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewPlatformVersionReleaseDates(request func(URL string, dataBody any) (*res
|
||||
}
|
||||
|
||||
func (a *PlatformVersionReleaseDates) Query(query string) ([]*pb.PlatformVersionReleaseDate, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_version_release_dates.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewPlatformVersions(request func(URL string, dataBody any) (*resty.Response
|
||||
}
|
||||
|
||||
func (a *PlatformVersions) Query(query string) ([]*pb.PlatformVersion, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_versions.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewPlatformWebsites(request func(URL string, dataBody any) (*resty.Response
|
||||
}
|
||||
|
||||
func (a *PlatformWebsites) Query(query string) ([]*pb.PlatformWebsite, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_websites.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewPlatforms(request func(URL string, dataBody any) (*resty.Response, error
|
||||
}
|
||||
|
||||
func (a *Platforms) Query(query string) ([]*pb.Platform, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/platforms.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewPlayerPerspectives(request func(URL string, dataBody any) (*resty.Respon
|
||||
}
|
||||
|
||||
func (a *PlayerPerspectives) Query(query string) ([]*pb.PlayerPerspective, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/player_perspectives.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewPopularityPrimitives(request func(URL string, dataBody any) (*resty.Resp
|
||||
}
|
||||
|
||||
func (a *PopularityPrimitives) Query(query string) ([]*pb.PopularityPrimitive, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/popularity_primitives.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewPopularityTypes(request func(URL string, dataBody any) (*resty.Response,
|
||||
}
|
||||
|
||||
func (a *PopularityTypes) Query(query string) ([]*pb.PopularityType, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/popularity_types.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewRegions(request func(URL string, dataBody any) (*resty.Response, error))
|
||||
}
|
||||
|
||||
func (a *Regions) Query(query string) ([]*pb.Region, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/regions.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewReleaseDateRegions(request func(URL string, dataBody any) (*resty.Respon
|
||||
}
|
||||
|
||||
func (a *ReleaseDateRegions) Query(query string) ([]*pb.ReleaseDateRegion, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/release_date_regions.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewReleaseDateStatuses(request func(URL string, dataBody any) (*resty.Respo
|
||||
}
|
||||
|
||||
func (a *ReleaseDateStatuses) Query(query string) ([]*pb.ReleaseDateStatus, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/release_date_statuses.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewReleaseDates(request func(URL string, dataBody any) (*resty.Response, er
|
||||
}
|
||||
|
||||
func (a *ReleaseDates) Query(query string) ([]*pb.ReleaseDate, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/release_dates.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewScreenshots(request func(URL string, dataBody any) (*resty.Response, err
|
||||
}
|
||||
|
||||
func (a *Screenshots) Query(query string) ([]*pb.Screenshot, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/screenshots.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -23,18 +23,20 @@ var webSearchCFCookies struct {
|
||||
}
|
||||
|
||||
type Search struct {
|
||||
endpointName Name
|
||||
request func(URL string, dataBody any) (*resty.Response, error)
|
||||
flaresolverr *flaresolverr.Flaresolverr
|
||||
}
|
||||
|
||||
func NewSearch(request func(URL string, dataBody any) (*resty.Response, error)) *Search {
|
||||
return &Search{
|
||||
endpointName: EPSearch,
|
||||
request: request,
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Search) Search(query string) ([]*pb.Search, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/search.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewThemes(request func(URL string, dataBody any) (*resty.Response, error))
|
||||
}
|
||||
|
||||
func (a *Themes) Query(query string) ([]*pb.Theme, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/themes.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ func NewWebhooks(request func(URL string, dataBody any) (*resty.Response, error)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Webhooks) Register(endpoint EndpointName, secret, callbackUrl string) error {
|
||||
func (a *Webhooks) Register(endpoint Name, secret, callbackUrl string) error {
|
||||
dataBody := url.Values{}
|
||||
dataBody.Set("url", callbackUrl)
|
||||
dataBody.Set("secret", secret)
|
||||
|
@ -25,7 +25,7 @@ func NewWebsiteTypes(request func(URL string, dataBody any) (*resty.Response, er
|
||||
}
|
||||
|
||||
func (a *WebsiteTypes) Query(query string) ([]*pb.WebsiteType, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/website_types.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func NewWebsites(request func(URL string, dataBody any) (*resty.Response, error)
|
||||
}
|
||||
|
||||
func (a *Websites) Query(query string) ([]*pb.Website, error) {
|
||||
resp, err := a.request("https://api.igdb.com/v4/websites.pb", query)
|
||||
resp, err := a.request(fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -24,6 +24,6 @@ func request() *resty.Request {
|
||||
|
||||
type disableLogger struct{}
|
||||
|
||||
func (d disableLogger) Errorf(format string, v ...interface{}) {}
|
||||
func (d disableLogger) Warnf(format string, v ...interface{}) {}
|
||||
func (d disableLogger) Debugf(format string, v ...interface{}) {}
|
||||
func (d disableLogger) Errorf(string, ...interface{}) {}
|
||||
func (d disableLogger) Warnf(string, ...interface{}) {}
|
||||
func (d disableLogger) Debugf(string, ...interface{}) {}
|
||||
|
10
token.go
10
token.go
@ -7,21 +7,21 @@ import (
|
||||
"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() (string, error) {
|
||||
if t.token != "" && time.Now().Before(t.expires) {
|
||||
return t.token, nil
|
||||
}
|
||||
@ -34,7 +34,7 @@ func (t *twitchToken) getToken() (string, error) {
|
||||
return token, nil
|
||||
}
|
||||
|
||||
func (t *twitchToken) loginTwitch() (string, time.Duration, error) {
|
||||
func (t *TwitchToken) loginTwitch() (string, time.Duration, error) {
|
||||
baseURL, _ := url.Parse("https://id.twitch.tv/oauth2/token")
|
||||
params := url.Values{}
|
||||
params.Add("client_id", t.clientID)
|
||||
|
Loading…
x
Reference in New Issue
Block a user