mirror of
https://github.com/bestnite/go-igdb.git
synced 2025-04-20 05:25:53 +08:00
Compare commits
No commits in common. "f88ba544c28e31e42630a2cd37840d9372356153" and "35c27b28a335248033dee99e3bdd41b9c5855ec1" have entirely different histories.
f88ba544c2
...
35c27b28a3
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,2 @@
|
|||||||
*test.go
|
*test.go
|
||||||
test/
|
test/
|
||||||
.vscode/
|
|
||||||
|
106
README.md
106
README.md
@ -1,15 +1,15 @@
|
|||||||
# go-igdb
|
# go-igdb
|
||||||
|
|
||||||
A Go client library for the IGDB (Internet Game Database) API v4. This library provides a convenient way to interact with IGDB's protobuf-based API endpoints.
|
A Go client library for the IGDB (Internet Game Database) API v4. This library provides a simple and efficient way to interact with IGDB's protobuf-based API.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Full support for IGDB API v4 endpoints
|
- Full support for IGDB API v4
|
||||||
- Protobuf-based communication for efficient data transfer
|
- Protobuf-based communication for better performance
|
||||||
- Rate limiting support
|
|
||||||
- Automatic token management for Twitch authentication
|
- Automatic token management for Twitch authentication
|
||||||
- Retry mechanism for failed requests
|
- Built-in retry mechanism for failed requests
|
||||||
- Optional FlareSolverr integration for handling Cloudflare protection
|
- Optional Cloudflare bypass support via FlareSolverr
|
||||||
|
- All endpoints are supported
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@ -20,93 +20,41 @@ go get github.com/bestnite/go-igdb
|
|||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
// Create a new IGDB client
|
||||||
|
client := igdb.New("your-client-id", "your-client-secret")
|
||||||
|
|
||||||
import (
|
// Get a game by ID
|
||||||
"log"
|
game, err := client.GetGameByID(1942)
|
||||||
|
if err != nil {
|
||||||
"github.com/bestnite/go-igdb"
|
log.Fatal(err)
|
||||||
)
|
|
||||||
|
|
||||||
func Test1(c *igdb.Client) {
|
|
||||||
game, err := igdb.GetItemByID(1942, c.Games.Query)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
log.Printf("Name of game %d: %s\n", 1942, game.Name)
|
|
||||||
}
|
}
|
||||||
|
fmt.Printf("Game: %s\n", game.Name)
|
||||||
|
|
||||||
func Test2(c *igdb.Client) {
|
// Search games with custom query
|
||||||
games, err := igdb.GetItemsByIDs([]uint64{119171, 119133}, c.Games.Query)
|
games, err := client.GetGames("search \"Zelda\"; fields name,rating,release_dates.*;")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
|
||||||
log.Printf("Names of games %d and %d: %s and %s\n", 119171, 119133, games[0].Name, games[1].Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test3(c *igdb.Client) {
|
|
||||||
total, err := igdb.GetItemsLength(c.Games.Query)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
log.Printf("Total number of games: %d\n", total)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test4(c *igdb.Client) {
|
|
||||||
games, err := igdb.GetItemsPagniated(0, 10, c.Games.Query)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
log.Printf("Names of ids 0 to 10 games:\n")
|
|
||||||
for _, game := range games {
|
|
||||||
log.Println(game.Name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test5(c *igdb.Client) {
|
|
||||||
game, err := c.Games.Query("fields name,rating; sort rating desc; limit 1;")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("failed to get game: %s", err)
|
|
||||||
}
|
|
||||||
log.Printf("Name of first game with highest rating: %s\n", game[0].Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test6(c *igdb.Client) {
|
|
||||||
games, err := c.Games.Query("fields *; where rating > 70; limit 10;")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
log.Printf("Names of games with rating > 70 limit 10:\n")
|
|
||||||
for _, game := range games {
|
|
||||||
log.Println(game.Name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
client := igdb.New("your-client-id", "your-client-secret")
|
|
||||||
Test1(client)
|
|
||||||
Test2(client)
|
|
||||||
Test3(client)
|
|
||||||
Test4(client)
|
|
||||||
Test5(client)
|
|
||||||
Test6(client)
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Advanced Usage
|
## Advanced Usage
|
||||||
|
|
||||||
### Using with FlareSolverr
|
### Query Format
|
||||||
|
|
||||||
|
The library uses IGDB's query syntax. For example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
import "github.com/bestnite/go-flaresolverr"
|
// Get games released in 2023
|
||||||
|
games, err := client.GetGames("where release_dates.y = 2023; fields name,rating;")
|
||||||
|
|
||||||
flaresolverr := flaresolverr.New("http://localhost:8191")
|
// Get specific fields for a company
|
||||||
client := igdb.NewWithFlaresolverr("your-client-id", "your-client-secret", flaresolverr)
|
companies, err := client.GetCompanies("where id = 1234; fields name,description,country;")
|
||||||
```
|
```
|
||||||
|
|
||||||
### Rate Limiting
|
## Requirements
|
||||||
|
|
||||||
The client automatically handles rate limiting with a default of 4 requests per second. This helps prevent hitting IGDB's rate limits.
|
- Go 1.24 or higher
|
||||||
|
- IGDB/Twitch API credentials (Client ID and Client Secret)
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
73
age_rating_categories.go
Normal file
73
age_rating_categories.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingCategories(query string) ([]*pb.AgeRatingCategory, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/age_rating_categories.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.AgeRatingCategoryResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingCategoryByID(id uint64) (*pb.AgeRatingCategory, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
ageRatingCategories, err := g.GetAgeRatingCategories(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ageRatingCategories[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingCategoriesByIDs(ids []uint64) ([]*pb.AgeRatingCategory, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetAgeRatingCategories(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingCategoriesByOrganizationID(id uint64) ([]*pb.AgeRatingCategory, error) {
|
||||||
|
query := fmt.Sprintf(`where organization = %d; fields *;`, id)
|
||||||
|
return g.GetAgeRatingCategories(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingCategoriesByOrganizationIDs(ids []uint64) ([]*pb.AgeRatingCategory, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where organization = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetAgeRatingCategories(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingCategoriesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
ageRatingCategories, err := g.GetAgeRatingCategories(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(ageRatingCategories[0].Id), nil
|
||||||
|
}
|
57
age_rating_content_descriptions.go
Normal file
57
age_rating_content_descriptions.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingContentDescriptions(query string) ([]*pb.AgeRatingContentDescription, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/age_rating_content_descriptions.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.AgeRatingContentDescriptionResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingContentDescriptionByID(id uint64) (*pb.AgeRatingContentDescription, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
ageRatingContentDescriptions, err := g.GetAgeRatingContentDescriptions(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ageRatingContentDescriptions[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingContentDescriptionsByIDs(ids []uint64) ([]*pb.AgeRatingContentDescription, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetAgeRatingContentDescriptions(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingContentDescriptionsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
ageRatingContentDescriptions, err := g.GetAgeRatingContentDescriptions(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(ageRatingContentDescriptions[0].Id), nil
|
||||||
|
}
|
73
age_rating_content_descriptions_v2.go
Normal file
73
age_rating_content_descriptions_v2.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingContentDescriptionsV2(query string) ([]*pb.AgeRatingContentDescriptionV2, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/age_rating_content_descriptions_v2.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.AgeRatingContentDescriptionV2Result{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingContentDescriptionV2ByID(id uint64) (*pb.AgeRatingContentDescriptionV2, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
ageRatingContentDescriptions, err := g.GetAgeRatingContentDescriptionsV2(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ageRatingContentDescriptions[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingContentDescriptionsV2ByIDs(ids []uint64) ([]*pb.AgeRatingContentDescriptionV2, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetAgeRatingContentDescriptionsV2(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingContentDescriptionsV2ByOrganizationID(id uint64) ([]*pb.AgeRatingContentDescriptionV2, error) {
|
||||||
|
query := fmt.Sprintf(`where organization = %d; fields *;`, id)
|
||||||
|
return g.GetAgeRatingContentDescriptionsV2(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingContentDescriptionsV2ByOrganizationIDs(ids []uint64) ([]*pb.AgeRatingContentDescriptionV2, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where organization = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetAgeRatingContentDescriptionsV2(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingContentDescriptionsV2Length() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
ageRatingContentDescriptions, err := g.GetAgeRatingContentDescriptionsV2(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(ageRatingContentDescriptions[0].Id), nil
|
||||||
|
}
|
57
age_rating_organizations.go
Normal file
57
age_rating_organizations.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingOrganizations(query string) ([]*pb.AgeRatingOrganization, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/age_rating_organizations.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.AgeRatingOrganizationResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingOrganizationByID(id uint64) (*pb.AgeRatingOrganization, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
ageRatingOrganizations, err := g.GetAgeRatingOrganizations(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ageRatingOrganizations[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingOrganizationsByIDs(ids []uint64) ([]*pb.AgeRatingOrganization, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetAgeRatingOrganizations(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingOrganizationsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
ageRatingOrganizations, err := g.GetAgeRatingOrganizations(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(ageRatingOrganizations[0].Id), nil
|
||||||
|
}
|
89
age_ratings.go
Normal file
89
age_ratings.go
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatings(query string) ([]*pb.AgeRating, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/age_ratings.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.AgeRatingResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingByID(id uint64) (*pb.AgeRating, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
ageRatings, err := g.GetAgeRatings(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ageRatings[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingsByIDs(ids []uint64) ([]*pb.AgeRating, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetAgeRatings(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingsByOrganizationID(id uint64) ([]*pb.AgeRating, error) {
|
||||||
|
query := fmt.Sprintf(`where organization = %d; fields *;`, id)
|
||||||
|
return g.GetAgeRatings(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingsByOrganizationIDs(ids []uint64) ([]*pb.AgeRating, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where organization = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetAgeRatings(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingsByAgeRatingCategoryID(id uint64) ([]*pb.AgeRating, error) {
|
||||||
|
query := fmt.Sprintf(`where rating_category = %d; fields *;`, id)
|
||||||
|
return g.GetAgeRatings(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingsByAgeRatingCategoryIDs(ids []uint64) ([]*pb.AgeRating, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where rating_category = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetAgeRatings(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAgeRatingsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
ageRatings, err := g.GetAgeRatings(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(ageRatings[0].Id), nil
|
||||||
|
}
|
73
alternative_names.go
Normal file
73
alternative_names.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetAlternativeNames(query string) ([]*pb.AlternativeName, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/alternative_names.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.AlternativeNameResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAlternativeNameByID(id uint64) (*pb.AlternativeName, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
alternativeNames, err := g.GetAlternativeNames(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return alternativeNames[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAlternativeNamesByIDs(ids []uint64) ([]*pb.AlternativeName, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetAlternativeNames(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAlternativeNamesByGameID(id uint64) ([]*pb.AlternativeName, error) {
|
||||||
|
query := fmt.Sprintf(`where game = %d; fields *;`, id)
|
||||||
|
return g.GetAlternativeNames(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAlternativeNamesByGameIDs(ids []uint64) ([]*pb.AlternativeName, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where game = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetAlternativeNames(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetAlternativeNamesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
alternativeNames, err := g.GetAlternativeNames(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(alternativeNames[0].Id), nil
|
||||||
|
}
|
73
artworks.go
Normal file
73
artworks.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetArtworks(query string) ([]*pb.Artwork, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/artworks.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.ArtworkResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetArtworkByID(id uint64) (*pb.Artwork, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
artworks, err := g.GetArtworks(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return artworks[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetArtworksByIDs(ids []uint64) ([]*pb.Artwork, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetArtworks(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetArtworksByGameID(id uint64) ([]*pb.Artwork, error) {
|
||||||
|
query := fmt.Sprintf(`where game = %d; fields *;`, id)
|
||||||
|
return g.GetArtworks(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetArtworksByGameIDs(ids []uint64) ([]*pb.Artwork, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where game = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetArtworks(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetArtworksLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
artworks, err := g.GetArtworks(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(artworks[0].Id), nil
|
||||||
|
}
|
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
|
|
||||||
}
|
|
57
character_genders.go
Normal file
57
character_genders.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCharacterGenders(query string) ([]*pb.CharacterGender, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/character_genders.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CharacterGenderResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharacterGenderByID(id uint64) (*pb.CharacterGender, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
characterGenders, err := g.GetCharacterGenders(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return characterGenders[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharacterGendersByIDs(ids []uint64) ([]*pb.CharacterGender, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCharacterGenders(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharacterGendersLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
characterGenders, err := g.GetCharacterGenders(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(characterGenders[0].Id), nil
|
||||||
|
}
|
57
character_mug_shots.go
Normal file
57
character_mug_shots.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCharacterMugShots(query string) ([]*pb.CharacterMugShot, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/character_mug_shots.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CharacterMugShotResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharacterMugShotByID(id uint64) (*pb.CharacterMugShot, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
characterMugShots, err := g.GetCharacterMugShots(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return characterMugShots[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharacterMugShotsByIDs(ids []uint64) ([]*pb.CharacterMugShot, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCharacterMugShots(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharacterMugShotsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
characterMugShots, err := g.GetCharacterMugShots(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(characterMugShots[0].Id), nil
|
||||||
|
}
|
57
character_species.go
Normal file
57
character_species.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCharacterSpecies(query string) ([]*pb.CharacterSpecie, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/character_species.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CharacterSpecieResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharacterSpecieByID(id uint64) (*pb.CharacterSpecie, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
characterSpecies, err := g.GetCharacterSpecies(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return characterSpecies[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharacterSpeciesByIDs(ids []uint64) ([]*pb.CharacterSpecie, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCharacterSpecies(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharacterSpeciesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
characterSpecies, err := g.GetCharacterSpecies(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(characterSpecies[0].Id), nil
|
||||||
|
}
|
105
characters.go
Normal file
105
characters.go
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCharacters(query string) ([]*pb.Character, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/characters.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CharacterResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharacterByID(id uint64) (*pb.Character, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
characters, err := g.GetCharacters(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return characters[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharactersByIDs(ids []uint64) ([]*pb.Character, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCharacters(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharactersByCharacterGenderID(id uint64) ([]*pb.Character, error) {
|
||||||
|
query := fmt.Sprintf(`where character_gender = %d; fields *;`, id)
|
||||||
|
return g.GetCharacters(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharactersByCharacterGenderIDs(ids []uint64) ([]*pb.Character, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where character_gender = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCharacters(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharactersByCharacterSpecieID(id uint64) ([]*pb.Character, error) {
|
||||||
|
query := fmt.Sprintf(`where character_species = %d; fields *;`, id)
|
||||||
|
return g.GetCharacters(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharactersByCharacterSpecieIDs(ids []uint64) ([]*pb.Character, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where character_species = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCharacters(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharactersByMugShotID(id uint64) ([]*pb.Character, error) {
|
||||||
|
query := fmt.Sprintf(`where mug_shot = %d; fields *;`, id)
|
||||||
|
return g.GetCharacters(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharactersByMugShotIDs(ids []uint64) ([]*pb.Character, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where mug_shot = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCharacters(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCharactersLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
characters, err := g.GetCharacters(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(characters[0].Id), nil
|
||||||
|
}
|
197
client.go
197
client.go
@ -1,197 +0,0 @@
|
|||||||
package igdb
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/bestnite/go-flaresolverr"
|
|
||||||
"github.com/bestnite/go-igdb/endpoint"
|
|
||||||
|
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
clientID string
|
|
||||||
token *twitchToken
|
|
||||||
flaresolverr *flaresolverr.Flaresolverr
|
|
||||||
limiter *rateLimiter
|
|
||||||
|
|
||||||
EntityEndpoints map[endpoint.EndpointName]endpoint.EntityEndpoint
|
|
||||||
|
|
||||||
AgeRatingCategories *endpoint.AgeRatingCategories
|
|
||||||
AgeRatingContentDescriptions *endpoint.AgeRatingContentDescriptions
|
|
||||||
AgeRatingContentDescriptionsV2 *endpoint.AgeRatingContentDescriptionsV2
|
|
||||||
AgeRatingOrganizations *endpoint.AgeRatingOrganizations
|
|
||||||
AgeRatings *endpoint.AgeRatings
|
|
||||||
AlternativeNames *endpoint.AlternativeNames
|
|
||||||
Artworks *endpoint.Artworks
|
|
||||||
CharacterGenders *endpoint.CharacterGenders
|
|
||||||
CharacterMugShots *endpoint.CharacterMugShots
|
|
||||||
Characters *endpoint.Characters
|
|
||||||
CharacterSpecies *endpoint.CharacterSpecies
|
|
||||||
CollectionMemberships *endpoint.CollectionMemberships
|
|
||||||
CollectionMembershipTypes *endpoint.CollectionMembershipTypes
|
|
||||||
CollectionRelations *endpoint.CollectionRelations
|
|
||||||
CollectionRelationTypes *endpoint.CollectionRelationTypes
|
|
||||||
Collections *endpoint.Collections
|
|
||||||
CollectionTypes *endpoint.CollectionTypes
|
|
||||||
Companies *endpoint.Companies
|
|
||||||
CompanyLogos *endpoint.CompanyLogos
|
|
||||||
CompanyStatuses *endpoint.CompanyStatuses
|
|
||||||
CompanyWebsites *endpoint.CompanyWebsites
|
|
||||||
Covers *endpoint.Covers
|
|
||||||
DateFormats *endpoint.DateFormats
|
|
||||||
EventLogos *endpoint.EventLogos
|
|
||||||
EventNetworks *endpoint.EventNetworks
|
|
||||||
Events *endpoint.Events
|
|
||||||
ExternalGames *endpoint.ExternalGames
|
|
||||||
ExternalGameSources *endpoint.ExternalGameSources
|
|
||||||
Franchises *endpoint.Franchises
|
|
||||||
GameEngineLogos *endpoint.GameEngineLogos
|
|
||||||
GameEngines *endpoint.GameEngines
|
|
||||||
GameLocalizations *endpoint.GameLocalizations
|
|
||||||
GameModes *endpoint.GameModes
|
|
||||||
GameReleaseFormats *endpoint.GameReleaseFormats
|
|
||||||
Games *endpoint.Games
|
|
||||||
GameStatuses *endpoint.GameStatuses
|
|
||||||
GameTimeToBeats *endpoint.GameTimeToBeats
|
|
||||||
GameTypes *endpoint.GameTypes
|
|
||||||
GameVersionFeatures *endpoint.GameVersionFeatures
|
|
||||||
GameVersionFeatureValues *endpoint.GameVersionFeatureValues
|
|
||||||
GameVersions *endpoint.GameVersions
|
|
||||||
GameVideos *endpoint.GameVideos
|
|
||||||
Genres *endpoint.Genres
|
|
||||||
InvolvedCompanies *endpoint.InvolvedCompanies
|
|
||||||
Keywords *endpoint.Keywords
|
|
||||||
Languages *endpoint.Languages
|
|
||||||
LanguageSupports *endpoint.LanguageSupports
|
|
||||||
LanguageSupportTypes *endpoint.LanguageSupportTypes
|
|
||||||
MultiplayerModes *endpoint.MultiplayerModes
|
|
||||||
NetworkTypes *endpoint.NetworkTypes
|
|
||||||
PlatformFamilies *endpoint.PlatformFamilies
|
|
||||||
PlatformLogos *endpoint.PlatformLogos
|
|
||||||
Platforms *endpoint.Platforms
|
|
||||||
PlatformTypes *endpoint.PlatformTypes
|
|
||||||
PlatformVersionCompanies *endpoint.PlatformVersionCompanies
|
|
||||||
PlatformVersionReleaseDates *endpoint.PlatformVersionReleaseDates
|
|
||||||
PlatformVersions *endpoint.PlatformVersions
|
|
||||||
PlatformWebsites *endpoint.PlatformWebsites
|
|
||||||
PlayerPerspectives *endpoint.PlayerPerspectives
|
|
||||||
PopularityPrimitives *endpoint.PopularityPrimitives
|
|
||||||
PopularityTypes *endpoint.PopularityTypes
|
|
||||||
Regions *endpoint.Regions
|
|
||||||
ReleaseDateRegions *endpoint.ReleaseDateRegions
|
|
||||||
ReleaseDates *endpoint.ReleaseDates
|
|
||||||
ReleaseDateStatuses *endpoint.ReleaseDateStatuses
|
|
||||||
Screenshots *endpoint.Screenshots
|
|
||||||
Search *endpoint.Search
|
|
||||||
Themes *endpoint.Themes
|
|
||||||
Webhooks *endpoint.Webhooks
|
|
||||||
Websites *endpoint.Websites
|
|
||||||
WebsiteTypes *endpoint.WebsiteTypes
|
|
||||||
}
|
|
||||||
|
|
||||||
func New(clientID, clientSecret string) *Client {
|
|
||||||
c := &Client{
|
|
||||||
clientID: clientID,
|
|
||||||
limiter: newRateLimiter(4),
|
|
||||||
token: NewTwitchToken(clientID, clientSecret),
|
|
||||||
flaresolverr: nil,
|
|
||||||
EntityEndpoints: make(map[endpoint.EndpointName]endpoint.EntityEndpoint),
|
|
||||||
}
|
|
||||||
|
|
||||||
registerAllEndpoints(c)
|
|
||||||
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewWithFlaresolverr(clientID, clientSecret string, f *flaresolverr.Flaresolverr) *Client {
|
|
||||||
c := New(clientID, clientSecret)
|
|
||||||
c.flaresolverr = f
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *Client) Request(URL string, dataBody any) (*resty.Response, error) {
|
|
||||||
g.limiter.wait()
|
|
||||||
|
|
||||||
t, err := g.token.getToken()
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to get twitch token: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := request().SetBody(dataBody).SetHeaders(map[string]string{
|
|
||||||
"Client-ID": g.clientID,
|
|
||||||
"Authorization": "Bearer " + t,
|
|
||||||
"User-Agent": "",
|
|
||||||
"Content-Type": "text/plain",
|
|
||||||
}).Post(URL)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %s: %w", URL, err)
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetItemsPagniated[T any](offset, limit int, f func(string) ([]*T, error)) ([]*T, error) {
|
|
||||||
query := fmt.Sprintf("offset %d; limit %d; f *; sort id asc;", offset, limit)
|
|
||||||
items, err := f(query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return items, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetItemsLength[T any](f func(string) ([]*T, error)) (uint64, error) {
|
|
||||||
query := "fields id; sort id desc; limit 1;"
|
|
||||||
items, err := f(query)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(items) == 0 {
|
|
||||||
return 0, fmt.Errorf("no results: %s", query)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Iid interface {
|
|
||||||
GetId() uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
item, ok := any(items[0]).(Iid)
|
|
||||||
|
|
||||||
if !ok {
|
|
||||||
return 0, fmt.Errorf("failed to convert")
|
|
||||||
}
|
|
||||||
|
|
||||||
return item.GetId(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetItemByID[T any](id uint64, f func(string) ([]*T, error)) (*T, error) {
|
|
||||||
query := fmt.Sprintf("where id = %d; fields *;", id)
|
|
||||||
items, err := f(query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(items) == 0 {
|
|
||||||
return nil, fmt.Errorf("no results: %s", query)
|
|
||||||
}
|
|
||||||
|
|
||||||
return items[0], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetItemsByIDs[T any](ids []uint64, f func(string) ([]*T, error)) ([]*T, error) {
|
|
||||||
idStrSlice := make([]string, len(ids))
|
|
||||||
for i, id := range ids {
|
|
||||||
idStrSlice[i] = fmt.Sprintf("%d", id)
|
|
||||||
}
|
|
||||||
|
|
||||||
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
|
||||||
|
|
||||||
items, err := f(idStr)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return items, nil
|
|
||||||
}
|
|
73
collection_membership_types.go
Normal file
73
collection_membership_types.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipTypes(query string) ([]*pb.CollectionMembershipType, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/collection_membership_types.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CollectionMembershipTypeResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipTypeByID(id uint64) (*pb.CollectionMembershipType, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
collectionMembershipTypes, err := g.GetCollectionMembershipTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return collectionMembershipTypes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipTypesByIDs(ids []uint64) ([]*pb.CollectionMembershipType, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollectionMembershipTypes(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipTypesByAllowedCollectionTypeID(id uint64) ([]*pb.CollectionMembershipType, error) {
|
||||||
|
query := fmt.Sprintf(`where allowed_collection_type = %d; fields *;`, id)
|
||||||
|
return g.GetCollectionMembershipTypes(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipTypesByAllowedCollectionTypeIDs(ids []uint64) ([]*pb.CollectionMembershipType, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where allowed_collection_type = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollectionMembershipTypes(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipTypesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
collectionMembershipTypes, err := g.GetCollectionMembershipTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(collectionMembershipTypes[0].Id), nil
|
||||||
|
}
|
94
collection_memberships.go
Normal file
94
collection_memberships.go
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMemberships(query string) ([]*pb.CollectionMembership, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/collection_memberships.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CollectionMembershipResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipByID(id uint64) (*pb.CollectionMembership, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
collectionMemberships, err := g.GetCollectionMemberships(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return collectionMemberships[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipsByIDs(ids []uint64) ([]*pb.CollectionMembership, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollectionMemberships(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipsByGameID(id uint64) ([]*pb.CollectionMembership, error) {
|
||||||
|
query := fmt.Sprintf(`where game = %d; fields *;`, id)
|
||||||
|
return g.GetCollectionMemberships(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipsByGameIDs(ids []uint64) ([]*pb.CollectionMembership, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where game = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollectionMemberships(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipsByCollectionID(id uint64) ([]*pb.CollectionMembership, error) {
|
||||||
|
query := fmt.Sprintf(`where collection = %d; fields *;`, id)
|
||||||
|
return g.GetCollectionMemberships(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipsByCollectionMembershipTypeID(id uint64) ([]*pb.CollectionMembership, error) {
|
||||||
|
query := fmt.Sprintf(`where type = %d; fields *;`, id)
|
||||||
|
return g.GetCollectionMemberships(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipsByCollectionMembershipTypeIDs(ids []uint64) ([]*pb.CollectionMembership, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where type = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollectionMemberships(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionMembershipsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
collectionMemberships, err := g.GetCollectionMemberships(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(collectionMemberships[0].Id), nil
|
||||||
|
}
|
89
collection_relation_types.go
Normal file
89
collection_relation_types.go
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationTypes(query string) ([]*pb.CollectionRelationType, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/collection_relation_types.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CollectionRelationTypeResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationTypeByID(id uint64) (*pb.CollectionRelationType, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
collectionRelationTypes, err := g.GetCollectionRelationTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return collectionRelationTypes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationTypesByIDs(ids []uint64) ([]*pb.CollectionRelationType, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollectionRelationTypes(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationTypesByAllowedChildTypeID(id uint64) ([]*pb.CollectionRelationType, error) {
|
||||||
|
query := fmt.Sprintf(`where allowed_child_type = %d; fields *;`, id)
|
||||||
|
return g.GetCollectionRelationTypes(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationTypesByAllowedChildTypeIDs(ids []uint64) ([]*pb.CollectionRelationType, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where allowed_child_type = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollectionRelationTypes(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationTypesByAllowedParentTypeID(id uint64) ([]*pb.CollectionRelationType, error) {
|
||||||
|
query := fmt.Sprintf(`where allowed_parent_type = %d; fields *;`, id)
|
||||||
|
return g.GetCollectionRelationTypes(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationTypesByAllowedParentTypeIDs(ids []uint64) ([]*pb.CollectionRelationType, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where allowed_parent_type = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollectionRelationTypes(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationTypesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
collectionRelationTypes, err := g.GetCollectionRelationTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(collectionRelationTypes[0].Id), nil
|
||||||
|
}
|
105
collection_relations.go
Normal file
105
collection_relations.go
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelations(query string) ([]*pb.CollectionRelation, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/collection_relations.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CollectionRelationResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationByID(id uint64) (*pb.CollectionRelation, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
collectionRelations, err := g.GetCollectionRelations(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return collectionRelations[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationsByIDs(ids []uint64) ([]*pb.CollectionRelation, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollectionRelations(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationsByChildCollectionID(id uint64) ([]*pb.CollectionRelation, error) {
|
||||||
|
query := fmt.Sprintf(`where child_collection = %d; fields *;`, id)
|
||||||
|
return g.GetCollectionRelations(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationsByChildCollectionIDs(ids []uint64) ([]*pb.CollectionRelation, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where child_collection = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollectionRelations(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationsByParentCollectionID(id uint64) ([]*pb.CollectionRelation, error) {
|
||||||
|
query := fmt.Sprintf(`where parent_collection = %d; fields *;`, id)
|
||||||
|
return g.GetCollectionRelations(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationsByParentCollectionIDs(ids []uint64) ([]*pb.CollectionRelation, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where parent_collection = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollectionRelations(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationsByCollectionRelationTypeID(id uint64) ([]*pb.CollectionRelation, error) {
|
||||||
|
query := fmt.Sprintf(`where type = %d; fields *;`, id)
|
||||||
|
return g.GetCollectionRelations(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationsByCollectionRelationTypeIDs(ids []uint64) ([]*pb.CollectionRelation, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where type = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollectionRelations(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionRelationsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
collectionRelations, err := g.GetCollectionRelations(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(collectionRelations[0].Id), nil
|
||||||
|
}
|
57
collection_types.go
Normal file
57
collection_types.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionTypes(query string) ([]*pb.CollectionType, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/collection_types.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CollectionTypeResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionTypeByID(id uint64) (*pb.CollectionType, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
collectionTypes, err := g.GetCollectionTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return collectionTypes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionTypesByIDs(ids []uint64) ([]*pb.CollectionType, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollectionTypes(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionTypesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
collectionTypes, err := g.GetCollectionTypes(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(collectionTypes[0].Id), nil
|
||||||
|
}
|
73
collections.go
Normal file
73
collections.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCollections(query string) ([]*pb.Collection, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/collections.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CollectionResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionByID(id uint64) (*pb.Collection, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
collections, err := g.GetCollections(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return collections[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionsByIDs(ids []uint64) ([]*pb.Collection, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollections(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionsByCollectionTypeID(id uint64) ([]*pb.Collection, error) {
|
||||||
|
query := fmt.Sprintf(`where collection_type = %d; fields *;`, id)
|
||||||
|
return g.GetCollections(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionsByCollectionTypeIDs(ids []uint64) ([]*pb.Collection, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where collection_type = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCollections(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCollectionsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
collections, err := g.GetCollections(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(collections[0].Id), nil
|
||||||
|
}
|
154
companies.go
Normal file
154
companies.go
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCompanies(query string) ([]*pb.Company, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/companies.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CompanyResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to unmarshal: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(data.Companies) == 0 {
|
||||||
|
return nil, errors.New("no results")
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.Companies, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByID(id uint64) (*pb.Company, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
companys, err := g.GetCompanies(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return companys[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByIDs(ids []uint64) ([]*pb.Company, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCompanies(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByChangeDateFormatID(id uint64) ([]*pb.Company, error) {
|
||||||
|
query := fmt.Sprintf(`where change_date_format = %d; fields *;`, id)
|
||||||
|
return g.GetCompanies(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByChangeDateFormatsIDs(ids []uint64) ([]*pb.Company, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where change_date_format = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCompanies(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByChangedCompanyID(id uint64) ([]*pb.Company, error) {
|
||||||
|
query := fmt.Sprintf(`where changed_company_id = %d; fields *;`, id)
|
||||||
|
return g.GetCompanies(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByChangedCompanyIDs(ids []uint64) ([]*pb.Company, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where changed_company_id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCompanies(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByLogoID(id uint64) ([]*pb.Company, error) {
|
||||||
|
query := fmt.Sprintf(`where logo = %d; fields *;`, id)
|
||||||
|
return g.GetCompanies(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByLogoIDs(ids []uint64) ([]*pb.Company, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where logo = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCompanies(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByParentID(id uint64) ([]*pb.Company, error) {
|
||||||
|
query := fmt.Sprintf(`where parent = %d; fields *;`, id)
|
||||||
|
return g.GetCompanies(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByParentIDs(ids []uint64) ([]*pb.Company, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where parent = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCompanies(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByStartDateFormatID(id uint64) ([]*pb.Company, error) {
|
||||||
|
query := fmt.Sprintf(`where start_date_format = %d; fields *;`, id)
|
||||||
|
return g.GetCompanies(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByStartDateFormatsIDs(ids []uint64) ([]*pb.Company, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where start_date_format = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCompanies(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByStatusID(id uint64) ([]*pb.Company, error) {
|
||||||
|
query := fmt.Sprintf(`where status = %d; fields *;`, id)
|
||||||
|
return g.GetCompanies(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyByStatusIDs(ids []uint64) ([]*pb.Company, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where status = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCompanies(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompaniesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
companies, err := g.GetCompanies(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(companies[0].Id), nil
|
||||||
|
}
|
57
company_logos.go
Normal file
57
company_logos.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyLogos(query string) ([]*pb.CompanyLogo, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/company_logos.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CompanyLogoResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyLogoByID(id uint64) (*pb.CompanyLogo, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
companyLogos, err := g.GetCompanyLogos(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return companyLogos[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyLogosByIDs(ids []uint64) ([]*pb.CompanyLogo, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCompanyLogos(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyLogosLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
companyLogos, err := g.GetCompanyLogos(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(companyLogos[0].Id), nil
|
||||||
|
}
|
57
company_statuses.go
Normal file
57
company_statuses.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyStatuses(query string) ([]*pb.CompanyStatus, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/company_statuses.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CompanyStatusResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyStatusByID(id uint64) (*pb.CompanyStatus, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
companyStatuses, err := g.GetCompanyStatuses(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return companyStatuses[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyStatusesByIDs(ids []uint64) ([]*pb.CompanyStatus, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCompanyStatuses(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyStatusesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
companyStatuses, err := g.GetCompanyStatuses(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(companyStatuses[0].Id), nil
|
||||||
|
}
|
73
company_websites.go
Normal file
73
company_websites.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyWebsites(query string) ([]*pb.CompanyWebsite, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/company_websites.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CompanyWebsiteResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyWebsiteByID(id uint64) (*pb.CompanyWebsite, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
companyWebsites, err := g.GetCompanyWebsites(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return companyWebsites[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyWebsitesByIDs(ids []uint64) ([]*pb.CompanyWebsite, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCompanyWebsites(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyWebsitesByTypeID(id uint64) ([]*pb.CompanyWebsite, error) {
|
||||||
|
query := fmt.Sprintf(`where type = %d; fields *;`, id)
|
||||||
|
return g.GetCompanyWebsites(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyWebsitesByTypeIDs(ids []uint64) ([]*pb.CompanyWebsite, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where type = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCompanyWebsites(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCompanyWebsitesLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
companyWebsites, err := g.GetCompanyWebsites(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(companyWebsites[0].Id), nil
|
||||||
|
}
|
89
covers.go
Normal file
89
covers.go
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetCovers(query string) ([]*pb.Cover, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/covers.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.CoverResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCoverByID(id uint64) (*pb.Cover, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
covers, err := g.GetCovers(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return covers[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCoversByIDs(ids []uint64) ([]*pb.Cover, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCovers(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCoversByGameID(id uint64) ([]*pb.Cover, error) {
|
||||||
|
query := fmt.Sprintf(`where game = %d; fields *;`, id)
|
||||||
|
return g.GetCovers(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCoversByGameIDs(ids []uint64) ([]*pb.Cover, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where game = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCovers(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCoversByGameLocalizationID(id uint64) ([]*pb.Cover, error) {
|
||||||
|
query := fmt.Sprintf(`where game_localization = %d; fields *;`, id)
|
||||||
|
return g.GetCovers(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCoversByGameLocalizationIDs(ids []uint64) ([]*pb.Cover, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where game_localization = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetCovers(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetCoversLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
covers, err := g.GetCovers(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(covers[0].Id), nil
|
||||||
|
}
|
57
date_formats.go
Normal file
57
date_formats.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetDateFormats(query string) ([]*pb.DateFormat, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/date_formats.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.DateFormatResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetDateFormatByID(id uint64) (*pb.DateFormat, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
dateFormats, err := g.GetDateFormats(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return dateFormats[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetDateFormatsByIDs(ids []uint64) ([]*pb.DateFormat, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetDateFormats(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetDateFormatsLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
dateFormats, err := g.GetDateFormats(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(dateFormats[0].Id), nil
|
||||||
|
}
|
@ -1,31 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AgeRatingCategories struct {
|
|
||||||
BaseEndpoint
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *AgeRatingCategories) Query(query string) ([]*pb.AgeRatingCategory, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/age_rating_categories.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.AgeRatingCategoryResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,31 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AgeRatingContentDescriptions struct {
|
|
||||||
BaseEndpoint
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *AgeRatingContentDescriptions) Query(query string) ([]*pb.AgeRatingContentDescription, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/age_rating_content_descriptions.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.AgeRatingContentDescriptionResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,31 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AgeRatingContentDescriptionsV2 struct {
|
|
||||||
BaseEndpoint
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.AgeRatingContentDescriptionV2Result{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AgeRatingOrganizations struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *AgeRatingOrganizations) Query(query string) ([]*pb.AgeRatingOrganization, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/age_rating_organizations.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.AgeRatingOrganizationResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AgeRatings struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *AgeRatings) Query(query string) ([]*pb.AgeRating, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/age_ratings.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.AgeRatingResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AlternativeNames struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *AlternativeNames) Query(query string) ([]*pb.AlternativeName, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/alternative_names.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.AlternativeNameResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Artworks struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Artworks) Query(query string) ([]*pb.Artwork, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/artworks.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.ArtworkResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,38 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/go-resty/resty/v2"
|
|
||||||
)
|
|
||||||
|
|
||||||
type BaseEndpoint struct {
|
|
||||||
request func(URL string, dataBody any) (*resty.Response, error)
|
|
||||||
endpointName EndpointName
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewBaseEndpoint(request func(URL string, dataBody any) (*resty.Response, error), endpointName EndpointName) *BaseEndpoint {
|
|
||||||
return &BaseEndpoint{
|
|
||||||
request: request,
|
|
||||||
endpointName: endpointName,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *BaseEndpoint) GetEndpointName() EndpointName {
|
|
||||||
return b.endpointName
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *BaseEndpoint) Query(query string) (any, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *BaseEndpoint) QueryAny(query string) (any, error) {
|
|
||||||
return b.Query(query)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Endpoint interface {
|
|
||||||
GetEndpointName() EndpointName
|
|
||||||
}
|
|
||||||
|
|
||||||
type EntityEndpoint interface {
|
|
||||||
QueryAny(query string) (any, error)
|
|
||||||
GetEndpointName() EndpointName
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CharacterGenders struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *CharacterGenders) Query(query string) ([]*pb.CharacterGender, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/character_genders.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CharacterGenderResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CharacterMugShots struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *CharacterMugShots) Query(query string) ([]*pb.CharacterMugShot, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/character_mug_shots.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CharacterMugShotResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CharacterSpecies struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *CharacterSpecies) Query(query string) ([]*pb.CharacterSpecie, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/character_species.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CharacterSpecieResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Characters struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Characters) Query(query string) ([]*pb.Character, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/characters.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CharacterResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CollectionMembershipTypes struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *CollectionMembershipTypes) Query(query string) ([]*pb.CollectionMembershipType, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/collection_membership_types.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CollectionMembershipTypeResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CollectionMemberships struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *CollectionMemberships) Query(query string) ([]*pb.CollectionMembership, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/collection_memberships.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CollectionMembershipResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CollectionRelationTypes struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *CollectionRelationTypes) Query(query string) ([]*pb.CollectionRelationType, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/collection_relation_types.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CollectionRelationTypeResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CollectionRelations struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *CollectionRelations) Query(query string) ([]*pb.CollectionRelation, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/collection_relations.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CollectionRelationResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CollectionTypes struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *CollectionTypes) Query(query string) ([]*pb.CollectionType, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/collection_types.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CollectionTypeResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Collections struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Collections) Query(query string) ([]*pb.Collection, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/collections.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CollectionResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,30 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Companies struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Companies) Query(query string) ([]*pb.Company, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/companies.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CompanyResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CompanyLogos struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *CompanyLogos) Query(query string) ([]*pb.CompanyLogo, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/company_logos.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CompanyLogoResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CompanyStatuses struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *CompanyStatuses) Query(query string) ([]*pb.CompanyStatus, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/company_statuses.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CompanyStatusResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CompanyWebsites struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *CompanyWebsites) Query(query string) ([]*pb.CompanyWebsite, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/company_websites.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CompanyWebsiteResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Covers struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Covers) Query(query string) ([]*pb.Cover, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/covers.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.CoverResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DateFormats struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *DateFormats) Query(query string) ([]*pb.DateFormat, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/date_formats.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.DateFormatResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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
|
|
||||||
}
|
|
151
endpoint/endpoint.go
Normal file
151
endpoint/endpoint.go
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
package endpoint
|
||||||
|
|
||||||
|
type Endpoint string
|
||||||
|
|
||||||
|
var (
|
||||||
|
AgeRatingCategories Endpoint = "age_rating_categories"
|
||||||
|
AgeRatingContentDescriptions Endpoint = "age_rating_content_descriptions"
|
||||||
|
AgeRatingContentDescriptionsV2 Endpoint = "age_rating_content_descriptions_v2"
|
||||||
|
AgeRatingOrganizations Endpoint = "age_rating_organizations"
|
||||||
|
AgeRatings Endpoint = "age_ratings"
|
||||||
|
AlternativeNames Endpoint = "alternative_names"
|
||||||
|
Artworks Endpoint = "artworks"
|
||||||
|
CharacterGenders Endpoint = "character_genders"
|
||||||
|
CharacterMugShots Endpoint = "character_mug_shots"
|
||||||
|
Characters Endpoint = "characters"
|
||||||
|
CharacterSpecies Endpoint = "character_species"
|
||||||
|
CollectionMemberships Endpoint = "collection_memberships"
|
||||||
|
CollectionMembershipTypes Endpoint = "collection_membership_types"
|
||||||
|
CollectionRelations Endpoint = "collection_relations"
|
||||||
|
CollectionRelationTypes Endpoint = "collection_relation_types"
|
||||||
|
Collections Endpoint = "collections"
|
||||||
|
CollectionTypes Endpoint = "collection_types"
|
||||||
|
Companies Endpoint = "companies"
|
||||||
|
CompanyLogos Endpoint = "company_logos"
|
||||||
|
CompanyStatuses Endpoint = "company_statuses"
|
||||||
|
CompanyWebsites Endpoint = "company_websites"
|
||||||
|
Covers Endpoint = "covers"
|
||||||
|
DateFormats Endpoint = "date_formats"
|
||||||
|
EventLogos Endpoint = "event_logos"
|
||||||
|
EventNetworks Endpoint = "event_networks"
|
||||||
|
Events Endpoint = "events"
|
||||||
|
ExternalGames Endpoint = "external_games"
|
||||||
|
ExternalGameSources Endpoint = "external_game_sources"
|
||||||
|
Franchises Endpoint = "franchises"
|
||||||
|
GameEngineLogos Endpoint = "game_engine_logos"
|
||||||
|
GameEngines Endpoint = "game_engines"
|
||||||
|
GameLocalizations Endpoint = "game_localizations"
|
||||||
|
GameModes Endpoint = "game_modes"
|
||||||
|
GameReleaseFormats Endpoint = "game_release_formats"
|
||||||
|
Games Endpoint = "games"
|
||||||
|
GameStatuses Endpoint = "game_statuses"
|
||||||
|
GameTimeToBeats Endpoint = "game_time_to_beats"
|
||||||
|
GameTypes Endpoint = "game_types"
|
||||||
|
GameVersionFeatures Endpoint = "game_version_features"
|
||||||
|
GameVersionFeatureValues Endpoint = "game_version_feature_values"
|
||||||
|
GameVersions Endpoint = "game_versions"
|
||||||
|
GameVideos Endpoint = "game_videos"
|
||||||
|
Genres Endpoint = "genres"
|
||||||
|
InvolvedCompanies Endpoint = "involved_companies"
|
||||||
|
Keywords Endpoint = "keywords"
|
||||||
|
Languages Endpoint = "languages"
|
||||||
|
LanguageSupports Endpoint = "language_supports"
|
||||||
|
LanguageSupportTypes Endpoint = "language_support_types"
|
||||||
|
MultiplayerModes Endpoint = "multiplayer_modes"
|
||||||
|
NetworkTypes Endpoint = "network_types"
|
||||||
|
PlatformFamilies Endpoint = "platform_families"
|
||||||
|
PlatformLogos Endpoint = "platform_logos"
|
||||||
|
Platforms Endpoint = "platforms"
|
||||||
|
PlatformTypes Endpoint = "platform_types"
|
||||||
|
PlatformVersionCompanies Endpoint = "platform_version_companies"
|
||||||
|
PlatformVersionReleaseDates Endpoint = "platform_version_release_dates"
|
||||||
|
PlatformVersions Endpoint = "platform_versions"
|
||||||
|
PlatformWebsites Endpoint = "platform_websites"
|
||||||
|
PlayerPerspectives Endpoint = "player_perspectives"
|
||||||
|
PopularityPrimitives Endpoint = "popularity_primitives"
|
||||||
|
PopularityTypes Endpoint = "popularity_types"
|
||||||
|
Regions Endpoint = "regions"
|
||||||
|
ReleaseDateRegions Endpoint = "release_date_regions"
|
||||||
|
ReleaseDates Endpoint = "release_dates"
|
||||||
|
ReleaseDateStatuses Endpoint = "release_date_statuses"
|
||||||
|
Screenshots Endpoint = "screenshots"
|
||||||
|
Search Endpoint = "search"
|
||||||
|
Themes Endpoint = "themes"
|
||||||
|
Webhooks Endpoint = "webhooks"
|
||||||
|
Websites Endpoint = "websites"
|
||||||
|
WebsiteTypes Endpoint = "website_types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var AllEndpoints = []Endpoint{
|
||||||
|
AgeRatingCategories,
|
||||||
|
AgeRatingContentDescriptions,
|
||||||
|
AgeRatingContentDescriptionsV2,
|
||||||
|
AgeRatingOrganizations,
|
||||||
|
AgeRatings,
|
||||||
|
AlternativeNames,
|
||||||
|
Artworks,
|
||||||
|
CharacterGenders,
|
||||||
|
CharacterMugShots,
|
||||||
|
Characters,
|
||||||
|
CharacterSpecies,
|
||||||
|
CollectionMemberships,
|
||||||
|
CollectionMembershipTypes,
|
||||||
|
CollectionRelations,
|
||||||
|
CollectionRelationTypes,
|
||||||
|
Collections,
|
||||||
|
CollectionTypes,
|
||||||
|
Companies,
|
||||||
|
CompanyLogos,
|
||||||
|
CompanyStatuses,
|
||||||
|
CompanyWebsites,
|
||||||
|
Covers,
|
||||||
|
DateFormats,
|
||||||
|
EventLogos,
|
||||||
|
EventNetworks,
|
||||||
|
Events,
|
||||||
|
ExternalGames,
|
||||||
|
ExternalGameSources,
|
||||||
|
Franchises,
|
||||||
|
GameEngineLogos,
|
||||||
|
GameEngines,
|
||||||
|
GameLocalizations,
|
||||||
|
GameModes,
|
||||||
|
GameReleaseFormats,
|
||||||
|
Games,
|
||||||
|
GameStatuses,
|
||||||
|
GameTimeToBeats,
|
||||||
|
GameTypes,
|
||||||
|
GameVersionFeatures,
|
||||||
|
GameVersionFeatureValues,
|
||||||
|
GameVersions,
|
||||||
|
GameVideos,
|
||||||
|
Genres,
|
||||||
|
InvolvedCompanies,
|
||||||
|
Keywords,
|
||||||
|
Languages,
|
||||||
|
LanguageSupports,
|
||||||
|
LanguageSupportTypes,
|
||||||
|
MultiplayerModes,
|
||||||
|
NetworkTypes,
|
||||||
|
PlatformFamilies,
|
||||||
|
PlatformLogos,
|
||||||
|
Platforms,
|
||||||
|
PlatformTypes,
|
||||||
|
PlatformVersionCompanies,
|
||||||
|
PlatformVersionReleaseDates,
|
||||||
|
PlatformVersions,
|
||||||
|
PlatformWebsites,
|
||||||
|
PlayerPerspectives,
|
||||||
|
PopularityPrimitives,
|
||||||
|
PopularityTypes,
|
||||||
|
Regions,
|
||||||
|
ReleaseDateRegions,
|
||||||
|
ReleaseDates,
|
||||||
|
ReleaseDateStatuses,
|
||||||
|
Screenshots,
|
||||||
|
Search,
|
||||||
|
Themes,
|
||||||
|
Webhooks,
|
||||||
|
Websites,
|
||||||
|
WebsiteTypes,
|
||||||
|
}
|
@ -1,151 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
type EndpointName 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"
|
|
||||||
)
|
|
||||||
|
|
||||||
var AllEndpoints = []EndpointName{
|
|
||||||
EPAgeRatingCategories,
|
|
||||||
EPAgeRatingContentDescriptions,
|
|
||||||
EPAgeRatingContentDescriptionsV2,
|
|
||||||
EPAgeRatingOrganizations,
|
|
||||||
EPAgeRatings,
|
|
||||||
EPAlternativeNames,
|
|
||||||
EPArtworks,
|
|
||||||
EPCharacterGenders,
|
|
||||||
EPCharacterMugShots,
|
|
||||||
EPCharacters,
|
|
||||||
EPCharacterSpecies,
|
|
||||||
EPCollectionMemberships,
|
|
||||||
EPCollectionMembershipTypes,
|
|
||||||
EPCollectionRelations,
|
|
||||||
EPCollectionRelationTypes,
|
|
||||||
EPCollections,
|
|
||||||
EPCollectionTypes,
|
|
||||||
EPCompanies,
|
|
||||||
EPCompanyLogos,
|
|
||||||
EPCompanyStatuses,
|
|
||||||
EPCompanyWebsites,
|
|
||||||
EPCovers,
|
|
||||||
EPDateFormats,
|
|
||||||
EPEventLogos,
|
|
||||||
EPEventNetworks,
|
|
||||||
EPEvents,
|
|
||||||
EPExternalGames,
|
|
||||||
EPExternalGameSources,
|
|
||||||
EPFranchises,
|
|
||||||
EPGameEngineLogos,
|
|
||||||
EPGameEngines,
|
|
||||||
EPGameLocalizations,
|
|
||||||
EPGameModes,
|
|
||||||
EPGameReleaseFormats,
|
|
||||||
EPGames,
|
|
||||||
EPGameStatuses,
|
|
||||||
EPGameTimeToBeats,
|
|
||||||
EPGameTypes,
|
|
||||||
EPGameVersionFeatures,
|
|
||||||
EPGameVersionFeatureValues,
|
|
||||||
EPGameVersions,
|
|
||||||
EPGameVideos,
|
|
||||||
EPGenres,
|
|
||||||
EPInvolvedCompanies,
|
|
||||||
EPKeywords,
|
|
||||||
EPLanguages,
|
|
||||||
EPLanguageSupports,
|
|
||||||
EPLanguageSupportTypes,
|
|
||||||
EPMultiplayerModes,
|
|
||||||
EPNetworkTypes,
|
|
||||||
EPPlatformFamilies,
|
|
||||||
EPPlatformLogos,
|
|
||||||
EPPlatforms,
|
|
||||||
EPPlatformTypes,
|
|
||||||
EPPlatformVersionCompanies,
|
|
||||||
EPPlatformVersionReleaseDates,
|
|
||||||
EPPlatformVersions,
|
|
||||||
EPPlatformWebsites,
|
|
||||||
EPPlayerPerspectives,
|
|
||||||
EPPopularityPrimitives,
|
|
||||||
EPPopularityTypes,
|
|
||||||
EPRegions,
|
|
||||||
EPReleaseDateRegions,
|
|
||||||
EPReleaseDates,
|
|
||||||
EPReleaseDateStatuses,
|
|
||||||
EPScreenshots,
|
|
||||||
EPSearch,
|
|
||||||
EPThemes,
|
|
||||||
EPWebhooks,
|
|
||||||
EPWebsites,
|
|
||||||
EPWebsiteTypes,
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type EventLogos struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *EventLogos) Query(query string) ([]*pb.EventLogo, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/event_logos.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.EventLogoResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type EventNetworks struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *EventNetworks) Query(query string) ([]*pb.EventNetwork, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/event_networks.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.EventNetworkResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Events struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Events) Query(query string) ([]*pb.Event, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/events.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.EventResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ExternalGameSources struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *ExternalGameSources) Query(query string) ([]*pb.ExternalGameSource, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/external_game_sources.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.ExternalGameSourceResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ExternalGames struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *ExternalGames) Query(query string) ([]*pb.ExternalGame, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/external_games.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.ExternalGameResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Franchises struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Franchises) Query(query string) ([]*pb.Franchise, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/franchises.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.FranchiseResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GameEngineLogos struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *GameEngineLogos) Query(query string) ([]*pb.GameEngineLogo, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/game_engine_logos.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GameEngineLogoResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GameEngines struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *GameEngines) Query(query string) ([]*pb.GameEngine, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/game_engines.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GameEngineResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GameLocalizations struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *GameLocalizations) Query(query string) ([]*pb.GameLocalization, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/game_localizations.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GameLocalizationResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GameModes struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *GameModes) Query(query string) ([]*pb.GameMode, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/game_modes.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GameModeResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GameReleaseFormats struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *GameReleaseFormats) Query(query string) ([]*pb.GameReleaseFormat, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/game_release_formats.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GameReleaseFormatResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GameStatuses struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *GameStatuses) Query(query string) ([]*pb.GameStatus, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/game_statuses.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GameStatusResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GameTimeToBeats struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *GameTimeToBeats) Query(query string) ([]*pb.GameTimeToBeat, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/game_time_to_beats.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GameTimeToBeatResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GameTypes struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *GameTypes) Query(query string) ([]*pb.GameType, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/game_types.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GameTypeResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GameVersionFeatureValues struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *GameVersionFeatureValues) Query(query string) ([]*pb.GameVersionFeatureValue, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/game_version_feature_values.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GameVersionFeatureValueResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GameVersionFeatures struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *GameVersionFeatures) Query(query string) ([]*pb.GameVersionFeature, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/game_version_features.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GameVersionFeatureResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GameVersions struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *GameVersions) Query(query string) ([]*pb.GameVersion, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/game_versions.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GameVersionResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GameVideos struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *GameVideos) Query(query string) ([]*pb.GameVideo, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/game_videos.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GameVideoResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Games struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Games) Query(query string) ([]*pb.Game, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/games.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GameResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Genres struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Genres) Query(query string) ([]*pb.Genre, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/genres.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.GenreResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type InvolvedCompanies struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *InvolvedCompanies) Query(query string) ([]*pb.InvolvedCompany, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/involved_companies.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.InvolvedCompanyResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Keywords struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Keywords) Query(query string) ([]*pb.Keyword, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/keywords.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.KeywordResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type LanguageSupportTypes struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *LanguageSupportTypes) Query(query string) ([]*pb.LanguageSupportType, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/language_support_types.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.LanguageSupportTypeResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type LanguageSupports struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *LanguageSupports) Query(query string) ([]*pb.LanguageSupport, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/language_supports.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.LanguageSupportResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Languages struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Languages) Query(query string) ([]*pb.Language, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/languages.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.LanguageResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type MultiplayerModes struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *MultiplayerModes) Query(query string) ([]*pb.MultiplayerMode, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/multiplayer_modes.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.MultiplayerModeResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type NetworkTypes struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *NetworkTypes) Query(query string) ([]*pb.NetworkType, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/network_types.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.NetworkTypeResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlatformFamilies struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *PlatformFamilies) Query(query string) ([]*pb.PlatformFamily, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/platform_families.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.PlatformFamilyResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlatformLogos struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *PlatformLogos) Query(query string) ([]*pb.PlatformLogo, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/platform_logos.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.PlatformLogoResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlatformTypes struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *PlatformTypes) Query(query string) ([]*pb.PlatformType, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/platform_types.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.PlatformTypeResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlatformVersionCompanies struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *PlatformVersionCompanies) Query(query string) ([]*pb.PlatformVersionCompany, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/platform_version_companies.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.PlatformVersionCompanyResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlatformVersionReleaseDates struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *PlatformVersionReleaseDates) Query(query string) ([]*pb.PlatformVersionReleaseDate, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/platform_version_release_dates.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.PlatformVersionReleaseDateResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlatformVersions struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *PlatformVersions) Query(query string) ([]*pb.PlatformVersion, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/platform_versions.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.PlatformVersionResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlatformWebsites struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *PlatformWebsites) Query(query string) ([]*pb.PlatformWebsite, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/platform_websites.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.PlatformWebsiteResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,28 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Platforms struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Platforms) Query(query string) ([]*pb.Platform, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/platforms.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.PlatformResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlayerPerspectives struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *PlayerPerspectives) Query(query string) ([]*pb.PlayerPerspective, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/player_perspectives.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.PlayerPerspectiveResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PopularityPrimitives struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *PopularityPrimitives) Query(query string) ([]*pb.PopularityPrimitive, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/popularity_primitives.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.PopularityPrimitiveResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PopularityTypes struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *PopularityTypes) Query(query string) ([]*pb.PopularityType, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/popularity_types.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.PopularityTypeResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Regions struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Regions) Query(query string) ([]*pb.Region, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/regions.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.RegionResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ReleaseDateRegions struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *ReleaseDateRegions) Query(query string) ([]*pb.ReleaseDateRegion, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/release_date_regions.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.ReleaseDateRegionResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ReleaseDateStatuses struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *ReleaseDateStatuses) Query(query string) ([]*pb.ReleaseDateStatus, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/release_date_statuses.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.ReleaseDateStatusResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ReleaseDates struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *ReleaseDates) Query(query string) ([]*pb.ReleaseDate, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/release_dates.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.ReleaseDateResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Screenshots struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Screenshots) Query(query string) ([]*pb.Screenshot, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/screenshots.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.ScreenshotResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Themes struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Themes) Query(query string) ([]*pb.Theme, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/themes.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.ThemeResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type WebsiteTypes struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *WebsiteTypes) Query(query string) ([]*pb.WebsiteType, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/website_types.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.WebsiteTypeResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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,29 +0,0 @@
|
|||||||
package endpoint
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
pb "github.com/bestnite/go-igdb/proto"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Websites struct{ BaseEndpoint }
|
|
||||||
|
|
||||||
func (a *Websites) Query(query string) ([]*pb.Website, error) {
|
|
||||||
resp, err := a.request("https://api.igdb.com/v4/websites.pb", query)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to request: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
data := pb.WebsiteResult{}
|
|
||||||
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
|
||||||
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
|
|
||||||
}
|
|
73
event_logos.go
Normal file
73
event_logos.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package igdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
pb "github.com/bestnite/go-igdb/proto"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (g *Client) GetEventLogos(query string) ([]*pb.EventLogo, error) {
|
||||||
|
resp, err := g.Request("https://api.igdb.com/v4/event_logos.pb", query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to request: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data := pb.EventLogoResult{}
|
||||||
|
if err = proto.Unmarshal(resp.Body(), &data); err != nil {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetEventLogoByID(id uint64) (*pb.EventLogo, error) {
|
||||||
|
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||||
|
eventLogos, err := g.GetEventLogos(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return eventLogos[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetEventLogosByIDs(ids []uint64) ([]*pb.EventLogo, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetEventLogos(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetEventLogosByEventID(id uint64) ([]*pb.EventLogo, error) {
|
||||||
|
query := fmt.Sprintf(`where event = %d; fields *;`, id)
|
||||||
|
return g.GetEventLogos(query)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetEventLogosByEventIDs(ids []uint64) ([]*pb.EventLogo, error) {
|
||||||
|
idStrSlice := make([]string, len(ids))
|
||||||
|
for i, id := range ids {
|
||||||
|
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
idStr := fmt.Sprintf(`where event = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||||
|
|
||||||
|
return g.GetEventLogos(idStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Client) GetEventLogosLength() (int, error) {
|
||||||
|
query := `fields *; sort id desc; limit 1;`
|
||||||
|
eventLogos, err := g.GetEventLogos(query)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(eventLogos[0].Id), nil
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user