Compare commits
	
		
			16 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						aaf697a005
	
				 | 
					
					
						|||
| 
						
						
							
						
						7ef9cb37e6
	
				 | 
					
					
						|||
| 
						
						
							
						
						87afdc63b8
	
				 | 
					
					
						|||
| 
						
						
							
						
						b99d06a2de
	
				 | 
					
					
						|||
| 
						
						
							
						
						4b6f488f59
	
				 | 
					
					
						|||
| 3df648929d | |||
| 5cb4ab4c61 | |||
| ecf81bcf79 | |||
| cf1f68c2d8 | |||
| fb58744928 | |||
| 3d28910178 | |||
| a583940e21 | |||
| 194e84c258 | |||
| a8e650e4d7 | |||
| f88ba544c2 | |||
| d550f859a7 | 
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,2 +1,4 @@
 | 
			
		||||
*test.go
 | 
			
		||||
test/
 | 
			
		||||
.vscode/
 | 
			
		||||
.idea/
 | 
			
		||||
							
								
								
									
										21
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
MIT License
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2025 Nite
 | 
			
		||||
 | 
			
		||||
Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
in the Software without restriction, including without limitation the rights
 | 
			
		||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
furnished to do so, subject to the following conditions:
 | 
			
		||||
 | 
			
		||||
The above copyright notice and this permission notice shall be included in all
 | 
			
		||||
copies or substantial portions of the Software.
 | 
			
		||||
 | 
			
		||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
			
		||||
SOFTWARE.
 | 
			
		||||
							
								
								
									
										114
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										114
									
								
								README.md
									
									
									
									
									
								
							@@ -1,61 +1,113 @@
 | 
			
		||||
# go-igdb
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
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.
 | 
			
		||||
 | 
			
		||||
## Features
 | 
			
		||||
 | 
			
		||||
- Full support for IGDB API v4
 | 
			
		||||
- Protobuf-based communication for better performance
 | 
			
		||||
- Full support for IGDB API v4 endpoints
 | 
			
		||||
- Protobuf-based communication for efficient data transfer
 | 
			
		||||
- Rate limiting support
 | 
			
		||||
- Automatic token management for Twitch authentication
 | 
			
		||||
- Built-in retry mechanism for failed requests
 | 
			
		||||
- Optional Cloudflare bypass support via FlareSolverr
 | 
			
		||||
- All endpoints are supported
 | 
			
		||||
- Retry mechanism for failed requests
 | 
			
		||||
- Optional FlareSolverr integration for handling Cloudflare protection
 | 
			
		||||
 | 
			
		||||
## Installation
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
go get github.com/bestnite/go-igdb
 | 
			
		||||
go get git.nite07.com/nite/go-igdb
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Quick Start
 | 
			
		||||
 | 
			
		||||
```go
 | 
			
		||||
// Create a new IGDB client
 | 
			
		||||
client := igdb.New("your-client-id", "your-client-secret")
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
// Get a game by ID
 | 
			
		||||
game, err := client.GetGameByID(1942)
 | 
			
		||||
if err != nil {
 | 
			
		||||
import (
 | 
			
		||||
	"log"
 | 
			
		||||
 | 
			
		||||
	"git.nite07.com/nite/go-igdb"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func Test1(c *igdb.Client) {
 | 
			
		||||
	game, err := c.Games.GetByID(1942)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
	log.Printf("Name of game %d: %s\n", 1942, game.Name)
 | 
			
		||||
}
 | 
			
		||||
fmt.Printf("Game: %s\n", game.Name)
 | 
			
		||||
 | 
			
		||||
// Search games with custom query
 | 
			
		||||
games, err := client.GetGames("search \"Zelda\"; fields name,rating,release_dates.*;")
 | 
			
		||||
if err != nil {
 | 
			
		||||
func Test2(c *igdb.Client) {
 | 
			
		||||
	games, err := c.Games.GetByIDs([]uint64{119171, 119133})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		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 := c.Games.Count()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
	log.Printf("Total number of games: %d\n", total)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test4(c *igdb.Client) {
 | 
			
		||||
	games, err := c.Games.Paginated(0, 10)
 | 
			
		||||
	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
 | 
			
		||||
## Example Projects
 | 
			
		||||
 | 
			
		||||
### Query Format
 | 
			
		||||
- [igdb-database](https://github.com/bestnite/igdb-database)
 | 
			
		||||
 | 
			
		||||
The library uses IGDB's query syntax. For example:
 | 
			
		||||
## Dependencies
 | 
			
		||||
 | 
			
		||||
```go
 | 
			
		||||
// Get games released in 2023
 | 
			
		||||
games, err := client.GetGames("where release_dates.y = 2023; fields name,rating;")
 | 
			
		||||
 | 
			
		||||
// Get specific fields for a company
 | 
			
		||||
companies, err := client.GetCompanies("where id = 1234; fields name,description,country;")
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Requirements
 | 
			
		||||
 | 
			
		||||
- Go 1.24 or higher
 | 
			
		||||
- IGDB/Twitch API credentials (Client ID and Client Secret)
 | 
			
		||||
- [go-resty/resty](https://github.com/go-resty/resty)
 | 
			
		||||
- [google/protobuf](https://github.com/google/protobuf)
 | 
			
		||||
- [bestnite/go-flaresolverr](https://github.com/bestnite/go-flaresolverr)
 | 
			
		||||
- [PuerkitoBio/goquery](https://github.com/PuerkitoBio/goquery)
 | 
			
		||||
 | 
			
		||||
## Contributing
 | 
			
		||||
 | 
			
		||||
Contributions are welcome! Please feel free to submit a Pull Request.
 | 
			
		||||
 | 
			
		||||
## License
 | 
			
		||||
 | 
			
		||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
 | 
			
		||||
 
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										27
									
								
								artworks.go
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								artworks.go
									
									
									
									
									
								
							@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										142
									
								
								client.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										142
									
								
								client.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,142 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"git.nite07.com/nite/go-igdb/endpoint"
 | 
			
		||||
	"github.com/bestnite/go-flaresolverr"
 | 
			
		||||
	"golang.org/x/time/rate"
 | 
			
		||||
 | 
			
		||||
	"github.com/go-resty/resty/v2"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Client struct {
 | 
			
		||||
	clientID     string
 | 
			
		||||
	token        *twitchToken
 | 
			
		||||
	flaresolverr *flaresolverr.Flaresolverr
 | 
			
		||||
	restyClient  *resty.Client
 | 
			
		||||
	limiter      *rate.Limiter
 | 
			
		||||
 | 
			
		||||
	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,
 | 
			
		||||
		restyClient:  NewRestyClient(),
 | 
			
		||||
		token:        newTwitchToken(clientID, clientSecret),
 | 
			
		||||
		flaresolverr: nil,
 | 
			
		||||
		limiter:      rate.NewLimiter(rate.Limit(4), 4),
 | 
			
		||||
	}
 | 
			
		||||
	registerAllEndpoints(c)
 | 
			
		||||
 | 
			
		||||
	return c
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type RequestFunc func(method string, URL string, dataBody any) (*resty.Response, error)
 | 
			
		||||
 | 
			
		||||
func NewWithFlaresolverr(clientID, clientSecret string, f *flaresolverr.Flaresolverr) *Client {
 | 
			
		||||
	c := New(clientID, clientSecret)
 | 
			
		||||
	c.flaresolverr = f
 | 
			
		||||
	return c
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (g *Client) Request(ctx context.Context, method string, requestURL string, dataBody any) (*resty.Response, error) {
 | 
			
		||||
	err := g.limiter.Wait(ctx)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to get rate limiter token: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	t, err := g.token.GetToken(ctx)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to get twitch token: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	resp, err := g.restyClient.R().SetContext(ctx).SetBody(dataBody).SetHeaders(map[string]string{
 | 
			
		||||
		"Client-ID":     g.clientID,
 | 
			
		||||
		"Authorization": "Bearer " + t,
 | 
			
		||||
		"User-Agent":    "",
 | 
			
		||||
		"Content-Type":  "text/plain",
 | 
			
		||||
	}).Execute(strings.ToUpper(method), requestURL)
 | 
			
		||||
 | 
			
		||||
	if resp.StatusCode() != 200 {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request, expected 200 but got: %v", resp.StatusCode())
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %s: %w", requestURL, err)
 | 
			
		||||
	}
 | 
			
		||||
	return resp, nil
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										28
									
								
								companies.go
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								companies.go
									
									
									
									
									
								
							@@ -1,28 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										27
									
								
								covers.go
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								covers.go
									
									
									
									
									
								
							@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +0,0 @@
 | 
			
		||||
package igdb
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	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
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/age_rating_categories.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/age_rating_categories.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type AgeRatingCategories struct {
 | 
			
		||||
	BaseEndpoint[pb.AgeRatingCategory]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewAgeRatingCategories(request RequestFunc) *AgeRatingCategories {
 | 
			
		||||
	a := &AgeRatingCategories{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.AgeRatingCategory]{
 | 
			
		||||
			endpointName: EPAgeRatingCategories,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AgeRatingCategories) Query(ctx context.Context, query string) ([]*pb.AgeRatingCategory, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.AgeRatingCategoryResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Ageratingcategories, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/age_rating_content_descriptions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/age_rating_content_descriptions.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type AgeRatingContentDescriptions struct {
 | 
			
		||||
	BaseEndpoint[pb.AgeRatingContentDescription]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewAgeRatingContentDescriptions(request RequestFunc) *AgeRatingContentDescriptions {
 | 
			
		||||
	a := &AgeRatingContentDescriptions{
 | 
			
		||||
		BaseEndpoint[pb.AgeRatingContentDescription]{
 | 
			
		||||
			endpointName: EPAgeRatingContentDescriptions,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AgeRatingContentDescriptions) Query(ctx context.Context, query string) ([]*pb.AgeRatingContentDescription, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.AgeRatingContentDescriptionResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Ageratingcontentdescriptions, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/age_rating_content_descriptions_v2.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/age_rating_content_descriptions_v2.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type AgeRatingContentDescriptionsV2 struct {
 | 
			
		||||
	BaseEndpoint[pb.AgeRatingContentDescriptionV2]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewAgeRatingContentDescriptionsV2(request RequestFunc) *AgeRatingContentDescriptionsV2 {
 | 
			
		||||
	a := &AgeRatingContentDescriptionsV2{
 | 
			
		||||
		BaseEndpoint[pb.AgeRatingContentDescriptionV2]{
 | 
			
		||||
			endpointName: EPAgeRatingContentDescriptionsV2,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AgeRatingContentDescriptionsV2) Query(ctx context.Context, query string) ([]*pb.AgeRatingContentDescriptionV2, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.AgeRatingContentDescriptionV2Result{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Ageratingcontentdescriptionsv2, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/age_rating_organizations.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/age_rating_organizations.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type AgeRatingOrganizations struct {
 | 
			
		||||
	BaseEndpoint[pb.AgeRatingOrganization]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewAgeRatingOrganizations(request RequestFunc) *AgeRatingOrganizations {
 | 
			
		||||
	a := &AgeRatingOrganizations{
 | 
			
		||||
		BaseEndpoint[pb.AgeRatingOrganization]{
 | 
			
		||||
			endpointName: EPAgeRatingOrganizations,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AgeRatingOrganizations) Query(ctx context.Context, query string) ([]*pb.AgeRatingOrganization, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.AgeRatingOrganizationResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Ageratingorganizations, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/age_ratings.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/age_ratings.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type AgeRatings struct {
 | 
			
		||||
	BaseEndpoint[pb.AgeRating]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewAgeRatings(request RequestFunc) *AgeRatings {
 | 
			
		||||
	a := &AgeRatings{
 | 
			
		||||
		BaseEndpoint[pb.AgeRating]{
 | 
			
		||||
			endpointName: EPAgeRatings,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AgeRatings) Query(ctx context.Context, query string) ([]*pb.AgeRating, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.AgeRatingResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Ageratings, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/alternative_names.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/alternative_names.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type AlternativeNames struct {
 | 
			
		||||
	BaseEndpoint[pb.AlternativeName]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewAlternativeNames(request RequestFunc) *AlternativeNames {
 | 
			
		||||
	a := &AlternativeNames{
 | 
			
		||||
		BaseEndpoint[pb.AlternativeName]{
 | 
			
		||||
			endpointName: EPAlternativeNames,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AlternativeNames) Query(ctx context.Context, query string) ([]*pb.AlternativeName, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.AlternativeNameResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Alternativenames, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/artworks.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/artworks.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Artworks struct {
 | 
			
		||||
	BaseEndpoint[pb.Artwork]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewArtworks(request RequestFunc) *Artworks {
 | 
			
		||||
	a := &Artworks{
 | 
			
		||||
		BaseEndpoint[pb.Artwork]{
 | 
			
		||||
			endpointName: EPArtworks,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Artworks) Query(ctx context.Context, query string) ([]*pb.Artwork, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.ArtworkResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Artworks, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										105
									
								
								endpoint/base.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								endpoint/base.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,105 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
 | 
			
		||||
	"github.com/go-resty/resty/v2"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type RequestFunc func(ctx context.Context, method string, URL string, dataBody any) (*resty.Response, error)
 | 
			
		||||
 | 
			
		||||
type BaseEndpoint[T any] struct {
 | 
			
		||||
	request      RequestFunc
 | 
			
		||||
	endpointName Name
 | 
			
		||||
	queryFunc    func(context.Context, string) ([]*T, error)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *BaseEndpoint[T]) GetEndpointName() Name {
 | 
			
		||||
	return b.endpointName
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *BaseEndpoint[T]) Query(ctx context.Context, query string) ([]*T, error) {
 | 
			
		||||
	if b.queryFunc == nil {
 | 
			
		||||
		return nil, fmt.Errorf("query method must be implemented by specific endpoint")
 | 
			
		||||
	}
 | 
			
		||||
	return b.queryFunc(ctx, query)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *BaseEndpoint[T]) GetByID(ctx context.Context, id uint64) (*T, error) {
 | 
			
		||||
	if id == 0 {
 | 
			
		||||
		return nil, errors.New("id cant be 0")
 | 
			
		||||
	}
 | 
			
		||||
	res, err := b.Query(ctx, fmt.Sprintf("where id = %d; fields *;", id))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	if len(res) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results")
 | 
			
		||||
	}
 | 
			
		||||
	return res[0], nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *BaseEndpoint[T]) GetByIDs(ctx context.Context, ids []uint64) ([]*T, error) {
 | 
			
		||||
	if len(ids) == 0 {
 | 
			
		||||
		return []*T{}, nil
 | 
			
		||||
	}
 | 
			
		||||
	batches := make([][]uint64, 0)
 | 
			
		||||
	for i := 0; i < len(ids); i += 500 {
 | 
			
		||||
		end := min(i+500, len(ids))
 | 
			
		||||
		batches = append(batches, ids[i:end])
 | 
			
		||||
	}
 | 
			
		||||
	res := []*T{}
 | 
			
		||||
	for _, batch := range batches {
 | 
			
		||||
		builder := strings.Builder{}
 | 
			
		||||
		for i, v := range batch {
 | 
			
		||||
			if i > 0 {
 | 
			
		||||
				builder.WriteByte(',')
 | 
			
		||||
			}
 | 
			
		||||
			builder.WriteString(strconv.FormatUint(v, 10))
 | 
			
		||||
		}
 | 
			
		||||
		batchRes, err := b.Query(ctx, fmt.Sprintf("where id = (%s); fields *; limit 500;", builder.String()))
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		res = append(res, batchRes...)
 | 
			
		||||
	}
 | 
			
		||||
	return res, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *BaseEndpoint[T]) Count(ctx context.Context) (uint64, error) {
 | 
			
		||||
	resp, err := b.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s/count.pb", b.endpointName), "")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var res pb.Count
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &res); err != nil {
 | 
			
		||||
		return 0, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if res.Count > 0 {
 | 
			
		||||
		return uint64(res.Count), nil
 | 
			
		||||
	} else {
 | 
			
		||||
		return 0, fmt.Errorf("failed to count, count should larger than 0, but got %v", res.Count)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *BaseEndpoint[T]) Paginated(ctx context.Context, offset, limit uint64) ([]*T, error) {
 | 
			
		||||
	return b.Query(ctx, fmt.Sprintf("offset %d; limit %d; fields *; sort id asc;", offset, limit))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type EntityEndpoint[T any] interface {
 | 
			
		||||
	GetEndpointName() Name
 | 
			
		||||
	Query(context.Context, string) ([]*T, error)
 | 
			
		||||
	GetByID(context.Context, uint64) (*T, error)
 | 
			
		||||
	GetByIDs(context.Context, []uint64) ([]*T, error)
 | 
			
		||||
	Count(context.Context) (uint64, error)
 | 
			
		||||
	Paginated(context.Context, uint64, uint64) ([]*T, error)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/character_genders.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/character_genders.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CharacterGenders struct {
 | 
			
		||||
	BaseEndpoint[pb.CharacterGender]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCharacterGenders(request RequestFunc) *CharacterGenders {
 | 
			
		||||
	a := &CharacterGenders{
 | 
			
		||||
		BaseEndpoint[pb.CharacterGender]{
 | 
			
		||||
			endpointName: EPCharacterGenders,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CharacterGenders) Query(ctx context.Context, query string) ([]*pb.CharacterGender, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CharacterGenderResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Charactergenders, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/character_mug_shots.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/character_mug_shots.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CharacterMugShots struct {
 | 
			
		||||
	BaseEndpoint[pb.CharacterMugShot]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCharacterMugShots(request RequestFunc) *CharacterMugShots {
 | 
			
		||||
	a := &CharacterMugShots{
 | 
			
		||||
		BaseEndpoint[pb.CharacterMugShot]{
 | 
			
		||||
			endpointName: EPCharacterMugShots,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CharacterMugShots) Query(ctx context.Context, query string) ([]*pb.CharacterMugShot, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CharacterMugShotResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Charactermugshots, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/character_species.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/character_species.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CharacterSpecies struct {
 | 
			
		||||
	BaseEndpoint[pb.CharacterSpecie]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCharacterSpecies(request RequestFunc) *CharacterSpecies {
 | 
			
		||||
	a := &CharacterSpecies{
 | 
			
		||||
		BaseEndpoint[pb.CharacterSpecie]{
 | 
			
		||||
			endpointName: EPCharacterSpecies,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CharacterSpecies) Query(ctx context.Context, query string) ([]*pb.CharacterSpecie, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CharacterSpecieResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Characterspecies, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/characters.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/characters.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Characters struct {
 | 
			
		||||
	BaseEndpoint[pb.Character]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCharacters(request RequestFunc) *Characters {
 | 
			
		||||
	a := &Characters{
 | 
			
		||||
		BaseEndpoint[pb.Character]{
 | 
			
		||||
			endpointName: EPCharacters,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Characters) Query(ctx context.Context, query string) ([]*pb.Character, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CharacterResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Characters, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/collection_membership_types.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/collection_membership_types.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CollectionMembershipTypes struct {
 | 
			
		||||
	BaseEndpoint[pb.CollectionMembershipType]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCollectionMembershipTypes(request RequestFunc) *CollectionMembershipTypes {
 | 
			
		||||
	a := &CollectionMembershipTypes{
 | 
			
		||||
		BaseEndpoint[pb.CollectionMembershipType]{
 | 
			
		||||
			endpointName: EPCollectionMembershipTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CollectionMembershipTypes) Query(ctx context.Context, query string) ([]*pb.CollectionMembershipType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CollectionMembershipTypeResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Collectionmembershiptypes, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/collection_memberships.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/collection_memberships.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CollectionMemberships struct {
 | 
			
		||||
	BaseEndpoint[pb.CollectionMembership]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCollectionMemberships(request RequestFunc) *CollectionMemberships {
 | 
			
		||||
	a := &CollectionMemberships{
 | 
			
		||||
		BaseEndpoint[pb.CollectionMembership]{
 | 
			
		||||
			endpointName: EPCollectionMemberships,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CollectionMemberships) Query(ctx context.Context, query string) ([]*pb.CollectionMembership, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CollectionMembershipResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Collectionmemberships, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/collection_relation_types.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/collection_relation_types.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CollectionRelationTypes struct {
 | 
			
		||||
	BaseEndpoint[pb.CollectionRelationType]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCollectionRelationTypes(request RequestFunc) *CollectionRelationTypes {
 | 
			
		||||
	a := &CollectionRelationTypes{
 | 
			
		||||
		BaseEndpoint[pb.CollectionRelationType]{
 | 
			
		||||
			endpointName: EPCollectionRelationTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CollectionRelationTypes) Query(ctx context.Context, query string) ([]*pb.CollectionRelationType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CollectionRelationTypeResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Collectionrelationtypes, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/collection_relations.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/collection_relations.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CollectionRelations struct {
 | 
			
		||||
	BaseEndpoint[pb.CollectionRelation]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCollectionRelations(request RequestFunc) *CollectionRelations {
 | 
			
		||||
	a := &CollectionRelations{
 | 
			
		||||
		BaseEndpoint[pb.CollectionRelation]{
 | 
			
		||||
			endpointName: EPCollectionRelations,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CollectionRelations) Query(ctx context.Context, query string) ([]*pb.CollectionRelation, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CollectionRelationResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Collectionrelations, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/collection_types.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/collection_types.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CollectionTypes struct {
 | 
			
		||||
	BaseEndpoint[pb.CollectionType]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCollectionTypes(request RequestFunc) *CollectionTypes {
 | 
			
		||||
	a := &CollectionTypes{
 | 
			
		||||
		BaseEndpoint[pb.CollectionType]{
 | 
			
		||||
			endpointName: EPCollectionTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CollectionTypes) Query(ctx context.Context, query string) ([]*pb.CollectionType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CollectionTypeResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Collectiontypes, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/collections.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/collections.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Collections struct {
 | 
			
		||||
	BaseEndpoint[pb.Collection]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCollections(request RequestFunc) *Collections {
 | 
			
		||||
	a := &Collections{
 | 
			
		||||
		BaseEndpoint[pb.Collection]{
 | 
			
		||||
			endpointName: EPCollections,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Collections) Query(ctx context.Context, query string) ([]*pb.Collection, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CollectionResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Collections, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/companies.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/companies.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Companies struct {
 | 
			
		||||
	BaseEndpoint[pb.Company]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCompanies(request RequestFunc) *Companies {
 | 
			
		||||
	a := &Companies{
 | 
			
		||||
		BaseEndpoint[pb.Company]{
 | 
			
		||||
			endpointName: EPCompanies,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Companies) Query(ctx context.Context, query string) ([]*pb.Company, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CompanyResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Companies, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/company_logos.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/company_logos.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CompanyLogos struct {
 | 
			
		||||
	BaseEndpoint[pb.CompanyLogo]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCompanyLogos(request RequestFunc) *CompanyLogos {
 | 
			
		||||
	a := &CompanyLogos{
 | 
			
		||||
		BaseEndpoint[pb.CompanyLogo]{
 | 
			
		||||
			endpointName: EPCompanyLogos,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CompanyLogos) Query(ctx context.Context, query string) ([]*pb.CompanyLogo, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CompanyLogoResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Companylogos, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/company_statuses.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/company_statuses.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CompanyStatuses struct {
 | 
			
		||||
	BaseEndpoint[pb.CompanyStatus]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCompanyStatuses(request RequestFunc) *CompanyStatuses {
 | 
			
		||||
	a := &CompanyStatuses{
 | 
			
		||||
		BaseEndpoint[pb.CompanyStatus]{
 | 
			
		||||
			endpointName: EPCompanyStatuses,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CompanyStatuses) Query(ctx context.Context, query string) ([]*pb.CompanyStatus, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CompanyStatusResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Companystatuses, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/company_websites.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/company_websites.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type CompanyWebsites struct {
 | 
			
		||||
	BaseEndpoint[pb.CompanyWebsite]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCompanyWebsites(request RequestFunc) *CompanyWebsites {
 | 
			
		||||
	a := &CompanyWebsites{
 | 
			
		||||
		BaseEndpoint[pb.CompanyWebsite]{
 | 
			
		||||
			endpointName: EPCompanyWebsites,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *CompanyWebsites) Query(ctx context.Context, query string) ([]*pb.CompanyWebsite, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CompanyWebsiteResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Companywebsites, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/covers.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/covers.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Covers struct {
 | 
			
		||||
	BaseEndpoint[pb.Cover]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewCovers(request RequestFunc) *Covers {
 | 
			
		||||
	a := &Covers{
 | 
			
		||||
		BaseEndpoint[pb.Cover]{
 | 
			
		||||
			endpointName: EPCovers,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Covers) Query(ctx context.Context, query string) ([]*pb.Cover, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.CoverResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Covers, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/date_formats.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/date_formats.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type DateFormats struct {
 | 
			
		||||
	BaseEndpoint[pb.DateFormat]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewDateFormats(request RequestFunc) *DateFormats {
 | 
			
		||||
	a := &DateFormats{
 | 
			
		||||
		BaseEndpoint[pb.DateFormat]{
 | 
			
		||||
			endpointName: EPDateFormats,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *DateFormats) Query(ctx context.Context, query string) ([]*pb.DateFormat, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.DateFormatResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Dateformats, nil
 | 
			
		||||
}
 | 
			
		||||
@@ -1,151 +0,0 @@
 | 
			
		||||
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,
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										151
									
								
								endpoint/endpoint_name.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										151
									
								
								endpoint/endpoint_name.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,151 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
type Name string
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	EPAgeRatingCategories            Name = "age_rating_categories"
 | 
			
		||||
	EPAgeRatingContentDescriptions   Name = "age_rating_content_descriptions"
 | 
			
		||||
	EPAgeRatingContentDescriptionsV2 Name = "age_rating_content_descriptions_v2"
 | 
			
		||||
	EPAgeRatingOrganizations         Name = "age_rating_organizations"
 | 
			
		||||
	EPAgeRatings                     Name = "age_ratings"
 | 
			
		||||
	EPAlternativeNames               Name = "alternative_names"
 | 
			
		||||
	EPArtworks                       Name = "artworks"
 | 
			
		||||
	EPCharacterGenders               Name = "character_genders"
 | 
			
		||||
	EPCharacterMugShots              Name = "character_mug_shots"
 | 
			
		||||
	EPCharacters                     Name = "characters"
 | 
			
		||||
	EPCharacterSpecies               Name = "character_species"
 | 
			
		||||
	EPCollectionMemberships          Name = "collection_memberships"
 | 
			
		||||
	EPCollectionMembershipTypes      Name = "collection_membership_types"
 | 
			
		||||
	EPCollectionRelations            Name = "collection_relations"
 | 
			
		||||
	EPCollectionRelationTypes        Name = "collection_relation_types"
 | 
			
		||||
	EPCollections                    Name = "collections"
 | 
			
		||||
	EPCollectionTypes                Name = "collection_types"
 | 
			
		||||
	EPCompanies                      Name = "companies"
 | 
			
		||||
	EPCompanyLogos                   Name = "company_logos"
 | 
			
		||||
	EPCompanyStatuses                Name = "company_statuses"
 | 
			
		||||
	EPCompanyWebsites                Name = "company_websites"
 | 
			
		||||
	EPCovers                         Name = "covers"
 | 
			
		||||
	EPDateFormats                    Name = "date_formats"
 | 
			
		||||
	EPEventLogos                     Name = "event_logos"
 | 
			
		||||
	EPEventNetworks                  Name = "event_networks"
 | 
			
		||||
	EPEvents                         Name = "events"
 | 
			
		||||
	EPExternalGames                  Name = "external_games"
 | 
			
		||||
	EPExternalGameSources            Name = "external_game_sources"
 | 
			
		||||
	EPFranchises                     Name = "franchises"
 | 
			
		||||
	EPGameEngineLogos                Name = "game_engine_logos"
 | 
			
		||||
	EPGameEngines                    Name = "game_engines"
 | 
			
		||||
	EPGameLocalizations              Name = "game_localizations"
 | 
			
		||||
	EPGameModes                      Name = "game_modes"
 | 
			
		||||
	EPGameReleaseFormats             Name = "game_release_formats"
 | 
			
		||||
	EPGames                          Name = "games"
 | 
			
		||||
	EPGameStatuses                   Name = "game_statuses"
 | 
			
		||||
	EPGameTimeToBeats                Name = "game_time_to_beats"
 | 
			
		||||
	EPGameTypes                      Name = "game_types"
 | 
			
		||||
	EPGameVersionFeatures            Name = "game_version_features"
 | 
			
		||||
	EPGameVersionFeatureValues       Name = "game_version_feature_values"
 | 
			
		||||
	EPGameVersions                   Name = "game_versions"
 | 
			
		||||
	EPGameVideos                     Name = "game_videos"
 | 
			
		||||
	EPGenres                         Name = "genres"
 | 
			
		||||
	EPInvolvedCompanies              Name = "involved_companies"
 | 
			
		||||
	EPKeywords                       Name = "keywords"
 | 
			
		||||
	EPLanguages                      Name = "languages"
 | 
			
		||||
	EPLanguageSupports               Name = "language_supports"
 | 
			
		||||
	EPLanguageSupportTypes           Name = "language_support_types"
 | 
			
		||||
	EPMultiplayerModes               Name = "multiplayer_modes"
 | 
			
		||||
	EPNetworkTypes                   Name = "network_types"
 | 
			
		||||
	EPPlatformFamilies               Name = "platform_families"
 | 
			
		||||
	EPPlatformLogos                  Name = "platform_logos"
 | 
			
		||||
	EPPlatforms                      Name = "platforms"
 | 
			
		||||
	EPPlatformTypes                  Name = "platform_types"
 | 
			
		||||
	EPPlatformVersionCompanies       Name = "platform_version_companies"
 | 
			
		||||
	EPPlatformVersionReleaseDates    Name = "platform_version_release_dates"
 | 
			
		||||
	EPPlatformVersions               Name = "platform_versions"
 | 
			
		||||
	EPPlatformWebsites               Name = "platform_websites"
 | 
			
		||||
	EPPlayerPerspectives             Name = "player_perspectives"
 | 
			
		||||
	EPPopularityPrimitives           Name = "popularity_primitives"
 | 
			
		||||
	EPPopularityTypes                Name = "popularity_types"
 | 
			
		||||
	EPRegions                        Name = "regions"
 | 
			
		||||
	EPReleaseDateRegions             Name = "release_date_regions"
 | 
			
		||||
	EPReleaseDates                   Name = "release_dates"
 | 
			
		||||
	EPReleaseDateStatuses            Name = "release_date_statuses"
 | 
			
		||||
	EPScreenshots                    Name = "screenshots"
 | 
			
		||||
	EPSearch                         Name = "search"
 | 
			
		||||
	EPThemes                         Name = "themes"
 | 
			
		||||
	EPWebhooks                       Name = "webhooks"
 | 
			
		||||
	EPWebsites                       Name = "websites"
 | 
			
		||||
	EPWebsiteTypes                   Name = "website_types"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var AllNames = []Name{
 | 
			
		||||
	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,
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/event_logos.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/event_logos.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type EventLogos struct {
 | 
			
		||||
	BaseEndpoint[pb.EventLogo]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewEventLogos(request RequestFunc) *EventLogos {
 | 
			
		||||
	a := &EventLogos{
 | 
			
		||||
		BaseEndpoint[pb.EventLogo]{
 | 
			
		||||
			endpointName: EPEventLogos,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *EventLogos) Query(ctx context.Context, query string) ([]*pb.EventLogo, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.EventLogoResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Eventlogos, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/event_networks.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/event_networks.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type EventNetworks struct {
 | 
			
		||||
	BaseEndpoint[pb.EventNetwork]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewEventNetworks(request RequestFunc) *EventNetworks {
 | 
			
		||||
	a := &EventNetworks{
 | 
			
		||||
		BaseEndpoint[pb.EventNetwork]{
 | 
			
		||||
			endpointName: EPEventNetworks,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *EventNetworks) Query(ctx context.Context, query string) ([]*pb.EventNetwork, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.EventNetworkResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Eventnetworks, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/events.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/events.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Events struct {
 | 
			
		||||
	BaseEndpoint[pb.Event]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewEvents(request RequestFunc) *Events {
 | 
			
		||||
	a := &Events{
 | 
			
		||||
		BaseEndpoint[pb.Event]{
 | 
			
		||||
			endpointName: EPEvents,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Events) Query(ctx context.Context, query string) ([]*pb.Event, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.EventResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Events, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/external_game_sources.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/external_game_sources.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type ExternalGameSources struct {
 | 
			
		||||
	BaseEndpoint[pb.ExternalGameSource]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewExternalGameSources(request RequestFunc) *ExternalGameSources {
 | 
			
		||||
	a := &ExternalGameSources{
 | 
			
		||||
		BaseEndpoint[pb.ExternalGameSource]{
 | 
			
		||||
			endpointName: EPExternalGameSources,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *ExternalGameSources) Query(ctx context.Context, query string) ([]*pb.ExternalGameSource, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.ExternalGameSourceResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Externalgamesources, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/external_games.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/external_games.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type ExternalGames struct {
 | 
			
		||||
	BaseEndpoint[pb.ExternalGame]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewExternalGames(request RequestFunc) *ExternalGames {
 | 
			
		||||
	a := &ExternalGames{
 | 
			
		||||
		BaseEndpoint[pb.ExternalGame]{
 | 
			
		||||
			endpointName: EPExternalGames,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *ExternalGames) Query(ctx context.Context, query string) ([]*pb.ExternalGame, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.ExternalGameResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Externalgames, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/franchises.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/franchises.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Franchises struct {
 | 
			
		||||
	BaseEndpoint[pb.Franchise]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewFranchises(request RequestFunc) *Franchises {
 | 
			
		||||
	a := &Franchises{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Franchise]{
 | 
			
		||||
			endpointName: EPFranchises,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Franchises) Query(ctx context.Context, query string) ([]*pb.Franchise, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.FranchiseResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Franchises, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/game_engine_logos.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/game_engine_logos.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GameEngineLogos struct {
 | 
			
		||||
	BaseEndpoint[pb.GameEngineLogo]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGameEngineLogos(request RequestFunc) *GameEngineLogos {
 | 
			
		||||
	a := &GameEngineLogos{
 | 
			
		||||
		BaseEndpoint[pb.GameEngineLogo]{
 | 
			
		||||
			endpointName: EPGameEngineLogos,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameEngineLogos) Query(ctx context.Context, query string) ([]*pb.GameEngineLogo, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GameEngineLogoResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gameenginelogos, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/game_engines.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/game_engines.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GameEngines struct {
 | 
			
		||||
	BaseEndpoint[pb.GameEngine]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGameEngines(request RequestFunc) *GameEngines {
 | 
			
		||||
	a := &GameEngines{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameEngine]{
 | 
			
		||||
			endpointName: EPGameEngines,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameEngines) Query(ctx context.Context, query string) ([]*pb.GameEngine, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GameEngineResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gameengines, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/game_localizations.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/game_localizations.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GameLocalizations struct {
 | 
			
		||||
	BaseEndpoint[pb.GameLocalization]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGameLocalizations(request RequestFunc) *GameLocalizations {
 | 
			
		||||
	a := &GameLocalizations{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameLocalization]{
 | 
			
		||||
			endpointName: EPGameLocalizations,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameLocalizations) Query(ctx context.Context, query string) ([]*pb.GameLocalization, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GameLocalizationResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gamelocalizations, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/game_modes.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/game_modes.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GameModes struct {
 | 
			
		||||
	BaseEndpoint[pb.GameMode]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGameModes(request RequestFunc) *GameModes {
 | 
			
		||||
	a := &GameModes{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameMode]{
 | 
			
		||||
			endpointName: EPGameModes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameModes) Query(ctx context.Context, query string) ([]*pb.GameMode, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GameModeResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gamemodes, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/game_release_formats.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/game_release_formats.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GameReleaseFormats struct {
 | 
			
		||||
	BaseEndpoint[pb.GameReleaseFormat]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGameReleaseFormats(request RequestFunc) *GameReleaseFormats {
 | 
			
		||||
	a := &GameReleaseFormats{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameReleaseFormat]{
 | 
			
		||||
			endpointName: EPGameReleaseFormats,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameReleaseFormats) Query(ctx context.Context, query string) ([]*pb.GameReleaseFormat, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GameReleaseFormatResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gamereleaseformats, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/game_statuses.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/game_statuses.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GameStatuses struct {
 | 
			
		||||
	BaseEndpoint[pb.GameStatus]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGameStatuses(request RequestFunc) *GameStatuses {
 | 
			
		||||
	a := &GameStatuses{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameStatus]{
 | 
			
		||||
			endpointName: EPGameStatuses,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameStatuses) Query(ctx context.Context, query string) ([]*pb.GameStatus, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GameStatusResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gamestatuses, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/game_time_to_beats.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/game_time_to_beats.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GameTimeToBeats struct {
 | 
			
		||||
	BaseEndpoint[pb.GameTimeToBeat]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGameTimeToBeats(request RequestFunc) *GameTimeToBeats {
 | 
			
		||||
	a := &GameTimeToBeats{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameTimeToBeat]{
 | 
			
		||||
			endpointName: EPGameTimeToBeats,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameTimeToBeats) Query(ctx context.Context, query string) ([]*pb.GameTimeToBeat, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GameTimeToBeatResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gametimetobeats, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/game_types.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/game_types.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GameTypes struct {
 | 
			
		||||
	BaseEndpoint[pb.GameType]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGameTypes(request RequestFunc) *GameTypes {
 | 
			
		||||
	a := &GameTypes{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameType]{
 | 
			
		||||
			endpointName: EPGameTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameTypes) Query(ctx context.Context, query string) ([]*pb.GameType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GameTypeResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gametypes, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/game_version_feature_values.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/game_version_feature_values.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GameVersionFeatureValues struct {
 | 
			
		||||
	BaseEndpoint[pb.GameVersionFeatureValue]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGameVersionFeatureValues(request RequestFunc) *GameVersionFeatureValues {
 | 
			
		||||
	a := &GameVersionFeatureValues{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameVersionFeatureValue]{
 | 
			
		||||
			endpointName: EPGameVersionFeatureValues,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameVersionFeatureValues) Query(ctx context.Context, query string) ([]*pb.GameVersionFeatureValue, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GameVersionFeatureValueResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gameversionfeaturevalues, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/game_version_features.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/game_version_features.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GameVersionFeatures struct {
 | 
			
		||||
	BaseEndpoint[pb.GameVersionFeature]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGameVersionFeatures(request RequestFunc) *GameVersionFeatures {
 | 
			
		||||
	a := &GameVersionFeatures{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameVersionFeature]{
 | 
			
		||||
			endpointName: EPGameVersionFeatures,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameVersionFeatures) Query(ctx context.Context, query string) ([]*pb.GameVersionFeature, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GameVersionFeatureResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gameversionfeatures, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/game_versions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/game_versions.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GameVersions struct {
 | 
			
		||||
	BaseEndpoint[pb.GameVersion]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGameVersions(request RequestFunc) *GameVersions {
 | 
			
		||||
	a := &GameVersions{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameVersion]{
 | 
			
		||||
			endpointName: EPGameVersions,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameVersions) Query(ctx context.Context, query string) ([]*pb.GameVersion, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GameVersionResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gameversions, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/game_videos.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/game_videos.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type GameVideos struct {
 | 
			
		||||
	BaseEndpoint[pb.GameVideo]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGameVideos(request RequestFunc) *GameVideos {
 | 
			
		||||
	a := &GameVideos{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.GameVideo]{
 | 
			
		||||
			endpointName: EPGameVideos,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *GameVideos) Query(ctx context.Context, query string) ([]*pb.GameVideo, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GameVideoResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Gamevideos, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/games.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/games.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Games struct {
 | 
			
		||||
	BaseEndpoint[pb.Game]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGames(request RequestFunc) *Games {
 | 
			
		||||
	a := &Games{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Game]{
 | 
			
		||||
			endpointName: EPGames,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Games) Query(ctx context.Context, query string) ([]*pb.Game, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GameResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Games, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/genres.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/genres.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Genres struct {
 | 
			
		||||
	BaseEndpoint[pb.Genre]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewGenres(request RequestFunc) *Genres {
 | 
			
		||||
	a := &Genres{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Genre]{
 | 
			
		||||
			endpointName: EPGenres,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Genres) Query(ctx context.Context, query string) ([]*pb.Genre, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.GenreResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Genres, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/involved_companies.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/involved_companies.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type InvolvedCompanies struct {
 | 
			
		||||
	BaseEndpoint[pb.InvolvedCompany]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewInvolvedCompanies(request RequestFunc) *InvolvedCompanies {
 | 
			
		||||
	a := &InvolvedCompanies{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.InvolvedCompany]{
 | 
			
		||||
			endpointName: EPInvolvedCompanies,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *InvolvedCompanies) Query(ctx context.Context, query string) ([]*pb.InvolvedCompany, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.InvolvedCompanyResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Involvedcompanies, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/keywords.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/keywords.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Keywords struct {
 | 
			
		||||
	BaseEndpoint[pb.Keyword]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewKeywords(request RequestFunc) *Keywords {
 | 
			
		||||
	a := &Keywords{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Keyword]{
 | 
			
		||||
			endpointName: EPKeywords,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Keywords) Query(ctx context.Context, query string) ([]*pb.Keyword, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.KeywordResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Keywords, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/language_support_types.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/language_support_types.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type LanguageSupportTypes struct {
 | 
			
		||||
	BaseEndpoint[pb.LanguageSupportType]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewLanguageSupportTypes(request RequestFunc) *LanguageSupportTypes {
 | 
			
		||||
	a := &LanguageSupportTypes{
 | 
			
		||||
		BaseEndpoint[pb.LanguageSupportType]{
 | 
			
		||||
			endpointName: EPLanguageSupportTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *LanguageSupportTypes) Query(ctx context.Context, query string) ([]*pb.LanguageSupportType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.LanguageSupportTypeResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Languagesupporttypes, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/language_supports.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/language_supports.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type LanguageSupports struct {
 | 
			
		||||
	BaseEndpoint[pb.LanguageSupport]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewLanguageSupports(request RequestFunc) *LanguageSupports {
 | 
			
		||||
	a := &LanguageSupports{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.LanguageSupport]{
 | 
			
		||||
			endpointName: EPLanguageSupports,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *LanguageSupports) Query(ctx context.Context, query string) ([]*pb.LanguageSupport, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.LanguageSupportResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Languagesupports, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/languages.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/languages.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Languages struct {
 | 
			
		||||
	BaseEndpoint[pb.Language]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewLanguages(request RequestFunc) *Languages {
 | 
			
		||||
	a := &Languages{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Language]{
 | 
			
		||||
			endpointName: EPLanguages,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Languages) Query(ctx context.Context, query string) ([]*pb.Language, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.LanguageResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Languages, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/multiplayer_modes.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/multiplayer_modes.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type MultiplayerModes struct {
 | 
			
		||||
	BaseEndpoint[pb.MultiplayerMode]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewMultiplayerModes(request RequestFunc) *MultiplayerModes {
 | 
			
		||||
	a := &MultiplayerModes{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.MultiplayerMode]{
 | 
			
		||||
			endpointName: EPMultiplayerModes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *MultiplayerModes) Query(ctx context.Context, query string) ([]*pb.MultiplayerMode, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.MultiplayerModeResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Multiplayermodes, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/network_types.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/network_types.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type NetworkTypes struct {
 | 
			
		||||
	BaseEndpoint[pb.NetworkType]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewNetworkTypes(request RequestFunc) *NetworkTypes {
 | 
			
		||||
	a := &NetworkTypes{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.NetworkType]{
 | 
			
		||||
			endpointName: EPNetworkTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *NetworkTypes) Query(ctx context.Context, query string) ([]*pb.NetworkType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.NetworkTypeResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Networktypes, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/platform_families.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/platform_families.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type PlatformFamilies struct {
 | 
			
		||||
	BaseEndpoint[pb.PlatformFamily]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewPlatformFamilies(request RequestFunc) *PlatformFamilies {
 | 
			
		||||
	a := &PlatformFamilies{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformFamily]{
 | 
			
		||||
			endpointName: EPPlatformFamilies,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformFamilies) Query(ctx context.Context, query string) ([]*pb.PlatformFamily, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.PlatformFamilyResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformfamilies, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/platform_logos.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/platform_logos.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type PlatformLogos struct {
 | 
			
		||||
	BaseEndpoint[pb.PlatformLogo]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewPlatformLogos(request RequestFunc) *PlatformLogos {
 | 
			
		||||
	a := &PlatformLogos{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformLogo]{
 | 
			
		||||
			endpointName: EPPlatformLogos,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformLogos) Query(ctx context.Context, query string) ([]*pb.PlatformLogo, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.PlatformLogoResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformlogos, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/platform_types.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/platform_types.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type PlatformTypes struct {
 | 
			
		||||
	BaseEndpoint[pb.PlatformType]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewPlatformTypes(request RequestFunc) *PlatformTypes {
 | 
			
		||||
	a := &PlatformTypes{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformType]{
 | 
			
		||||
			endpointName: EPPlatformTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformTypes) Query(ctx context.Context, query string) ([]*pb.PlatformType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.PlatformTypeResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformtypes, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/platform_version_companies.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/platform_version_companies.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type PlatformVersionCompanies struct {
 | 
			
		||||
	BaseEndpoint[pb.PlatformVersionCompany]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewPlatformVersionCompanies(request RequestFunc) *PlatformVersionCompanies {
 | 
			
		||||
	a := &PlatformVersionCompanies{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformVersionCompany]{
 | 
			
		||||
			endpointName: EPPlatformVersionCompanies,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformVersionCompanies) Query(ctx context.Context, query string) ([]*pb.PlatformVersionCompany, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.PlatformVersionCompanyResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformversioncompanies, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/platform_version_release_dates.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/platform_version_release_dates.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type PlatformVersionReleaseDates struct {
 | 
			
		||||
	BaseEndpoint[pb.PlatformVersionReleaseDate]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewPlatformVersionReleaseDates(request RequestFunc) *PlatformVersionReleaseDates {
 | 
			
		||||
	a := &PlatformVersionReleaseDates{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformVersionReleaseDate]{
 | 
			
		||||
			endpointName: EPPlatformVersionReleaseDates,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformVersionReleaseDates) Query(ctx context.Context, query string) ([]*pb.PlatformVersionReleaseDate, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.PlatformVersionReleaseDateResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformversionreleasedates, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/platform_versions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/platform_versions.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type PlatformVersions struct {
 | 
			
		||||
	BaseEndpoint[pb.PlatformVersion]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewPlatformVersions(request RequestFunc) *PlatformVersions {
 | 
			
		||||
	a := &PlatformVersions{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformVersion]{
 | 
			
		||||
			endpointName: EPPlatformVersions,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformVersions) Query(ctx context.Context, query string) ([]*pb.PlatformVersion, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.PlatformVersionResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformversions, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/platform_websites.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/platform_websites.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type PlatformWebsites struct {
 | 
			
		||||
	BaseEndpoint[pb.PlatformWebsite]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewPlatformWebsites(request RequestFunc) *PlatformWebsites {
 | 
			
		||||
	a := &PlatformWebsites{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlatformWebsite]{
 | 
			
		||||
			endpointName: EPPlatformWebsites,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlatformWebsites) Query(ctx context.Context, query string) ([]*pb.PlatformWebsite, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.PlatformWebsiteResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platformwebsites, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/platforms.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/platforms.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Platforms struct {
 | 
			
		||||
	BaseEndpoint[pb.Platform]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewPlatforms(request RequestFunc) *Platforms {
 | 
			
		||||
	a := &Platforms{
 | 
			
		||||
		BaseEndpoint[pb.Platform]{
 | 
			
		||||
			endpointName: EPPlatforms,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Platforms) Query(ctx context.Context, query string) ([]*pb.Platform, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.PlatformResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Platforms, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/player_perspectives.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/player_perspectives.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type PlayerPerspectives struct {
 | 
			
		||||
	BaseEndpoint[pb.PlayerPerspective]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewPlayerPerspectives(request RequestFunc) *PlayerPerspectives {
 | 
			
		||||
	a := &PlayerPerspectives{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PlayerPerspective]{
 | 
			
		||||
			endpointName: EPPlayerPerspectives,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PlayerPerspectives) Query(ctx context.Context, query string) ([]*pb.PlayerPerspective, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.PlayerPerspectiveResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Playerperspectives, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/popularity_primitives.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/popularity_primitives.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type PopularityPrimitives struct {
 | 
			
		||||
	BaseEndpoint[pb.PopularityPrimitive]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewPopularityPrimitives(request RequestFunc) *PopularityPrimitives {
 | 
			
		||||
	a := &PopularityPrimitives{
 | 
			
		||||
		BaseEndpoint[pb.PopularityPrimitive]{
 | 
			
		||||
			endpointName: EPPopularityPrimitives,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PopularityPrimitives) Query(ctx context.Context, query string) ([]*pb.PopularityPrimitive, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.PopularityPrimitiveResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Popularityprimitives, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/popularity_types.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/popularity_types.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type PopularityTypes struct {
 | 
			
		||||
	BaseEndpoint[pb.PopularityType]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewPopularityTypes(request RequestFunc) *PopularityTypes {
 | 
			
		||||
	a := &PopularityTypes{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.PopularityType]{
 | 
			
		||||
			endpointName: EPPopularityTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *PopularityTypes) Query(ctx context.Context, query string) ([]*pb.PopularityType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.PopularityTypeResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Popularitytypes, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/regions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/regions.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Regions struct {
 | 
			
		||||
	BaseEndpoint[pb.Region]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewRegions(request RequestFunc) *Regions {
 | 
			
		||||
	a := &Regions{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Region]{
 | 
			
		||||
			endpointName: EPRegions,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Regions) Query(ctx context.Context, query string) ([]*pb.Region, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.RegionResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Regions, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/release_date_regions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/release_date_regions.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type ReleaseDateRegions struct {
 | 
			
		||||
	BaseEndpoint[pb.ReleaseDateRegion]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewReleaseDateRegions(request RequestFunc) *ReleaseDateRegions {
 | 
			
		||||
	a := &ReleaseDateRegions{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.ReleaseDateRegion]{
 | 
			
		||||
			endpointName: EPReleaseDateRegions,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *ReleaseDateRegions) Query(ctx context.Context, query string) ([]*pb.ReleaseDateRegion, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.ReleaseDateRegionResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Releasedateregions, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/release_date_statuses.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/release_date_statuses.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type ReleaseDateStatuses struct {
 | 
			
		||||
	BaseEndpoint[pb.ReleaseDateStatus]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewReleaseDateStatuses(request RequestFunc) *ReleaseDateStatuses {
 | 
			
		||||
	a := &ReleaseDateStatuses{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.ReleaseDateStatus]{
 | 
			
		||||
			endpointName: EPReleaseDateStatuses,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *ReleaseDateStatuses) Query(ctx context.Context, query string) ([]*pb.ReleaseDateStatus, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.ReleaseDateStatusResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Releasedatestatuses, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/release_dates.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/release_dates.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type ReleaseDates struct {
 | 
			
		||||
	BaseEndpoint[pb.ReleaseDate]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewReleaseDates(request RequestFunc) *ReleaseDates {
 | 
			
		||||
	a := &ReleaseDates{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.ReleaseDate]{
 | 
			
		||||
			endpointName: EPReleaseDates,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *ReleaseDates) Query(ctx context.Context, query string) ([]*pb.ReleaseDate, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.ReleaseDateResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Releasedates, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/screenshots.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/screenshots.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Screenshots struct {
 | 
			
		||||
	BaseEndpoint[pb.Screenshot]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewScreenshots(request RequestFunc) *Screenshots {
 | 
			
		||||
	a := &Screenshots{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Screenshot]{
 | 
			
		||||
			endpointName: EPScreenshots,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Screenshots) Query(ctx context.Context, query string) ([]*pb.Screenshot, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.ScreenshotResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Screenshots, nil
 | 
			
		||||
}
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
package igdb
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
@@ -9,7 +10,7 @@ import (
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	pb "github.com/bestnite/go-igdb/proto"
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"github.com/PuerkitoBio/goquery"
 | 
			
		||||
	"github.com/bestnite/go-flaresolverr"
 | 
			
		||||
@@ -21,8 +22,21 @@ var webSearchCFCookies struct {
 | 
			
		||||
	expires time.Time
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (g *Client) Search(query string) ([]*pb.Search, error) {
 | 
			
		||||
	resp, err := g.Request("https://api.igdb.com/v4/search.pb", query)
 | 
			
		||||
type Search struct {
 | 
			
		||||
	endpointName Name
 | 
			
		||||
	request      RequestFunc
 | 
			
		||||
	flaresolverr *flaresolverr.Flaresolverr
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewSearch(request RequestFunc) *Search {
 | 
			
		||||
	return &Search{
 | 
			
		||||
		endpointName: EPSearch,
 | 
			
		||||
		request:      request,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Search) Search(ctx context.Context, query string) ([]*pb.Search, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -32,20 +46,23 @@ func (g *Client) Search(query string) ([]*pb.Search, error) {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(data.Searches) == 0 {
 | 
			
		||||
		return nil, fmt.Errorf("no results: %s", query)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Searches, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (g *Client) WebSearchGames(name string) ([]*pb.Game, error) {
 | 
			
		||||
func (a *Search) getFlaresolverr() (*flaresolverr.Flaresolverr, error) {
 | 
			
		||||
	if a.flaresolverr == nil {
 | 
			
		||||
		return nil, fmt.Errorf("flaresolverr is not initialized")
 | 
			
		||||
	}
 | 
			
		||||
	return a.flaresolverr, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Search) WebSearchGameIDs(name string) ([]uint64, error) {
 | 
			
		||||
	params := url.Values{}
 | 
			
		||||
	params.Add("q", name)
 | 
			
		||||
	params.Add("utf8", "✓")
 | 
			
		||||
	Url := fmt.Sprintf("%s?%s", "https://www.igdb.com/search", params.Encode())
 | 
			
		||||
 | 
			
		||||
	f, err := g.getFlaresolverr()
 | 
			
		||||
	f, err := a.getFlaresolverr()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to get flaresolverr: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -93,5 +110,5 @@ func (g *Client) WebSearchGames(name string) ([]*pb.Game, error) {
 | 
			
		||||
		ids[i] = game.Id
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return GetItemsByIDs(ids, g.GetGames)
 | 
			
		||||
	return ids, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/themes.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/themes.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Themes struct {
 | 
			
		||||
	BaseEndpoint[pb.Theme]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewThemes(request RequestFunc) *Themes {
 | 
			
		||||
	a := &Themes{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.Theme]{
 | 
			
		||||
			endpointName: EPThemes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Themes) Query(ctx context.Context, query string) ([]*pb.Theme, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.ThemeResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Themes, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										104
									
								
								endpoint/webhooks.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								endpoint/webhooks.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,104 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Webhooks struct {
 | 
			
		||||
	request RequestFunc
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewWebhooks(request RequestFunc) *Webhooks {
 | 
			
		||||
	return &Webhooks{
 | 
			
		||||
		request: request,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type WebhookMethod string
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	WebhookMethodUpdate WebhookMethod = "update"
 | 
			
		||||
	WebhookMethodDelete WebhookMethod = "delete"
 | 
			
		||||
	WebhookMethodCreate WebhookMethod = "create"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type WebhookResponse struct {
 | 
			
		||||
	Id          uint64 `json:"id"`
 | 
			
		||||
	Url         string `json:"url"`
 | 
			
		||||
	Category    uint64 `json:"category"`
 | 
			
		||||
	SubCategory uint64 `json:"sub_category"`
 | 
			
		||||
	Active      bool   `json:"active"`
 | 
			
		||||
	ApiKey      string `json:"api_key"`
 | 
			
		||||
	Secret      string `json:"secret"`
 | 
			
		||||
	CreatedAt   string `json:"created_at"`
 | 
			
		||||
	UpdatedAt   string `json:"updated_at"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Webhooks) Register(ctx context.Context, endpoint Name, secret, callbackUrl string, method WebhookMethod) (*WebhookResponse, error) {
 | 
			
		||||
	dataBody := url.Values{}
 | 
			
		||||
	dataBody.Set("url", callbackUrl)
 | 
			
		||||
	dataBody.Set("secret", secret)
 | 
			
		||||
	dataBody.Set("method", string(method))
 | 
			
		||||
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s/webhooks/", endpoint), dataBody.Encode())
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to make request: %s: %w", callbackUrl, err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if resp.StatusCode() == http.StatusOK {
 | 
			
		||||
		return nil, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var data WebhookResponse
 | 
			
		||||
	if err = json.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &data, fmt.Errorf("failed to activate webhook: %s: %s", callbackUrl, resp.String())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Webhooks) Unregister(ctx context.Context, webhookId uint64) error {
 | 
			
		||||
	resp, err := a.request(ctx, "DELETE", fmt.Sprintf("https://api.igdb.com/v4/webhooks/%v", webhookId), "")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("failed to make request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if resp.StatusCode() == http.StatusOK {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return fmt.Errorf("failed to unregister webhook: %s", resp.String())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Webhooks) List(ctx context.Context) ([]*WebhookResponse, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "GET", "https://api.igdb.com/v4/webhooks/", "")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to make request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var data []*WebhookResponse
 | 
			
		||||
	if err = json.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Webhooks) Get(ctx context.Context, webhookId uint64) (*WebhookResponse, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "GET", fmt.Sprintf("https://api.igdb.com/v4/webhooks/%v", webhookId), "")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to make request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var data WebhookResponse
 | 
			
		||||
	if err = json.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &data, nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										39
									
								
								endpoint/website_types.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								endpoint/website_types.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
package endpoint
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	pb "git.nite07.com/nite/go-igdb/proto"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type WebsiteTypes struct {
 | 
			
		||||
	BaseEndpoint[pb.WebsiteType]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewWebsiteTypes(request RequestFunc) *WebsiteTypes {
 | 
			
		||||
	a := &WebsiteTypes{
 | 
			
		||||
		BaseEndpoint: BaseEndpoint[pb.WebsiteType]{
 | 
			
		||||
			endpointName: EPWebsiteTypes,
 | 
			
		||||
			request:      request,
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	a.queryFunc = a.Query
 | 
			
		||||
	return a
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *WebsiteTypes) Query(ctx context.Context, query string) ([]*pb.WebsiteType, error) {
 | 
			
		||||
	resp, err := a.request(ctx, "POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to request: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	data := pb.WebsiteTypeResult{}
 | 
			
		||||
	if err = proto.Unmarshal(resp.Body(), &data); err != nil {
 | 
			
		||||
		return nil, fmt.Errorf("failed to unmarshal: %w", err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return data.Websitetypes, nil
 | 
			
		||||
}
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user