mirror of
https://github.com/bestnite/go-igdb.git
synced 2025-04-20 05:25:53 +08:00
Compare commits
No commits in common. "main" and "v0.0.7" have entirely different histories.
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,3 @@
|
||||
*test.go
|
||||
test/
|
||||
.vscode/
|
||||
.idea/
|
21
LICENSE
21
LICENSE
@ -1,21 +0,0 @@
|
||||
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.
|
37
README.md
37
README.md
@ -26,10 +26,11 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/bestnite/go-igdb"
|
||||
pb "github.com/bestnite/go-igdb/proto"
|
||||
)
|
||||
|
||||
func Test1(c *igdb.Client) {
|
||||
game, err := c.Games.GetByID(1942)
|
||||
game, err := igdb.GetItemByID[pb.Game](1942, c.Games.Query)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -37,7 +38,7 @@ func Test1(c *igdb.Client) {
|
||||
}
|
||||
|
||||
func Test2(c *igdb.Client) {
|
||||
games, err := c.Games.GetByIDs([]uint64{119171, 119133})
|
||||
games, err := igdb.GetItemsByIDs[pb.Game]([]uint64{119171, 119133}, c.Games.Query)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -45,7 +46,7 @@ func Test2(c *igdb.Client) {
|
||||
}
|
||||
|
||||
func Test3(c *igdb.Client) {
|
||||
total, err := c.Games.Count()
|
||||
total, err := igdb.GetItemsLength[pb.Game](c.Games.Query)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -53,7 +54,7 @@ func Test3(c *igdb.Client) {
|
||||
}
|
||||
|
||||
func Test4(c *igdb.Client) {
|
||||
games, err := c.Games.Paginated(0, 10)
|
||||
games, err := igdb.GetItemsPagniated[pb.Game](0, 10, c.Games.Query)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -64,15 +65,15 @@ func Test4(c *igdb.Client) {
|
||||
}
|
||||
|
||||
func Test5(c *igdb.Client) {
|
||||
game, err := c.Games.Query("fields name,rating; sort rating desc; limit 1;")
|
||||
game, err := igdb.AssertSingle[pb.Game](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)
|
||||
log.Printf("Name of first game with highest rating: %s\n", game.Name)
|
||||
}
|
||||
|
||||
func Test6(c *igdb.Client) {
|
||||
games, err := c.Games.Query("fields *; where rating > 70; limit 10;")
|
||||
games, err := igdb.AssertSlice[pb.Game](c.Games.Query("fields *; where rating > 70; limit 10;"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -93,21 +94,21 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
## Example Projects
|
||||
## Advanced Usage
|
||||
|
||||
- [igdb-database](https://github.com/bestnite/igdb-database)
|
||||
### Using with FlareSolverr
|
||||
|
||||
## Dependencies
|
||||
```go
|
||||
import "github.com/bestnite/go-flaresolverr"
|
||||
|
||||
- [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)
|
||||
flaresolverr := flaresolverr.New("http://localhost:8191")
|
||||
client := igdb.NewWithFlaresolverr("your-client-id", "your-client-secret", flaresolverr)
|
||||
```
|
||||
|
||||
### Rate Limiting
|
||||
|
||||
The client automatically handles rate limiting with a default of 4 requests per second. This helps prevent hitting IGDB's rate limits.
|
||||
|
||||
## 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.
|
||||
|
41
assert.go
Normal file
41
assert.go
Normal file
@ -0,0 +1,41 @@
|
||||
package igdb
|
||||
|
||||
import "fmt"
|
||||
|
||||
func AssertSingle[T any](data any, err error) (*T, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return nil, fmt.Errorf("data is nil")
|
||||
}
|
||||
|
||||
datas, ok := data.([]*T)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to convert to []*T")
|
||||
}
|
||||
|
||||
if len(datas) == 0 {
|
||||
return nil, fmt.Errorf("no results")
|
||||
}
|
||||
|
||||
return datas[0], nil
|
||||
}
|
||||
|
||||
func AssertSlice[T any](data any, err error) ([]*T, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
return nil, fmt.Errorf("data is nil")
|
||||
}
|
||||
|
||||
datas, ok := data.([]*T)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to convert to []*T")
|
||||
}
|
||||
|
||||
return datas, nil
|
||||
}
|
83
client.go
83
client.go
@ -12,10 +12,12 @@ import (
|
||||
|
||||
type Client struct {
|
||||
clientID string
|
||||
token *TwitchToken
|
||||
token *twitchToken
|
||||
flaresolverr *flaresolverr.Flaresolverr
|
||||
limiter *rateLimiter
|
||||
|
||||
EntityEndpoints map[endpoint.EndpointName]endpoint.EntityEndpoint
|
||||
|
||||
AgeRatingCategories *endpoint.AgeRatingCategories
|
||||
AgeRatingContentDescriptions *endpoint.AgeRatingContentDescriptions
|
||||
AgeRatingContentDescriptionsV2 *endpoint.AgeRatingContentDescriptionsV2
|
||||
@ -91,10 +93,11 @@ type Client struct {
|
||||
|
||||
func New(clientID, clientSecret string) *Client {
|
||||
c := &Client{
|
||||
clientID: clientID,
|
||||
limiter: newRateLimiter(4),
|
||||
token: NewTwitchToken(clientID, clientSecret),
|
||||
flaresolverr: nil,
|
||||
clientID: clientID,
|
||||
limiter: newRateLimiter(4),
|
||||
token: NewTwitchToken(clientID, clientSecret),
|
||||
flaresolverr: nil,
|
||||
EntityEndpoints: make(map[endpoint.EndpointName]endpoint.EntityEndpoint),
|
||||
}
|
||||
|
||||
registerAllEndpoints(c)
|
||||
@ -102,15 +105,13 @@ func New(clientID, clientSecret string) *Client {
|
||||
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(method string, URL string, dataBody any) (*resty.Response, error) {
|
||||
func (g *Client) Request(URL string, dataBody any) (*resty.Response, error) {
|
||||
g.limiter.wait()
|
||||
|
||||
t, err := g.token.getToken()
|
||||
@ -123,10 +124,74 @@ func (g *Client) Request(method string, URL string, dataBody any) (*resty.Respon
|
||||
"Authorization": "Bearer " + t,
|
||||
"User-Agent": "",
|
||||
"Content-Type": "text/plain",
|
||||
}).Execute(strings.ToUpper(method), URL)
|
||||
}).Post(URL)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %s: %w", URL, err)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func GetItemsPagniated[T any](offset, limit int, f func(string) ([]*T, error)) ([]*T, error) {
|
||||
query := fmt.Sprintf("offset %d; limit %d; f *; sort id asc;", offset, limit)
|
||||
items, err := f(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return items, nil
|
||||
}
|
||||
|
||||
func GetItemsLength[T any](f func(string) ([]*T, error)) (uint64, error) {
|
||||
query := "fields id; sort id desc; limit 1;"
|
||||
items, err := f(query)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if len(items) == 0 {
|
||||
return 0, fmt.Errorf("no results: %s", query)
|
||||
}
|
||||
|
||||
type Iid interface {
|
||||
GetId() uint64
|
||||
}
|
||||
|
||||
item, ok := any(items[0]).(Iid)
|
||||
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("failed to convert")
|
||||
}
|
||||
|
||||
return item.GetId(), nil
|
||||
}
|
||||
|
||||
func GetItemByID[T any](id uint64, f func(string) ([]*T, error)) (*T, error) {
|
||||
query := fmt.Sprintf("where id = %d; fields *;", id)
|
||||
items, err := f(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(items) == 0 {
|
||||
return nil, fmt.Errorf("no results: %s", query)
|
||||
}
|
||||
|
||||
return items[0], nil
|
||||
}
|
||||
|
||||
func GetItemsByIDs[T any](ids []uint64, f func(string) ([]*T, error)) ([]*T, error) {
|
||||
idStrSlice := make([]string, len(ids))
|
||||
for i, id := range ids {
|
||||
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||
}
|
||||
|
||||
idStr := fmt.Sprintf(`where id = (%s); fields *;`, strings.Join(idStrSlice, ","))
|
||||
|
||||
items, err := f(idStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return items, nil
|
||||
}
|
||||
|
@ -9,22 +9,11 @@ import (
|
||||
)
|
||||
|
||||
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
|
||||
BaseEndpoint
|
||||
}
|
||||
|
||||
func (a *AgeRatingCategories) Query(query string) ([]*pb.AgeRatingCategory, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/age_rating_categories.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -9,22 +9,11 @@ import (
|
||||
)
|
||||
|
||||
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
|
||||
BaseEndpoint
|
||||
}
|
||||
|
||||
func (a *AgeRatingContentDescriptions) Query(query string) ([]*pb.AgeRatingContentDescription, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/age_rating_content_descriptions.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -9,22 +9,11 @@ import (
|
||||
)
|
||||
|
||||
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
|
||||
BaseEndpoint
|
||||
}
|
||||
|
||||
func (a *AgeRatingContentDescriptionsV2) Query(query string) ([]*pb.AgeRatingContentDescriptionV2, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/age_rating_content_descriptions_v2.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type AgeRatingOrganizations struct{ BaseEndpoint }
|
||||
|
||||
func (a *AgeRatingOrganizations) Query(query string) ([]*pb.AgeRatingOrganization, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/age_rating_organizations.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type AgeRatings struct{ BaseEndpoint }
|
||||
|
||||
func (a *AgeRatings) Query(query string) ([]*pb.AgeRating, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/age_ratings.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type AlternativeNames struct{ BaseEndpoint }
|
||||
|
||||
func (a *AlternativeNames) Query(query string) ([]*pb.AlternativeName, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/alternative_names.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type Artworks struct{ BaseEndpoint }
|
||||
|
||||
func (a *Artworks) Query(query string) ([]*pb.Artwork, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/artworks.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -1,80 +1,38 @@
|
||||
package endpoint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
pb "github.com/bestnite/go-igdb/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/go-resty/resty/v2"
|
||||
)
|
||||
|
||||
type RequestFunc func(method string, URL string, dataBody any) (*resty.Response, error)
|
||||
|
||||
type BaseEndpoint[T any] struct {
|
||||
request RequestFunc
|
||||
endpointName Name
|
||||
queryFunc func(string) ([]*T, error)
|
||||
type BaseEndpoint struct {
|
||||
request func(URL string, dataBody any) (*resty.Response, error)
|
||||
endpointName EndpointName
|
||||
}
|
||||
|
||||
func (b *BaseEndpoint[T]) GetEndpointName() Name {
|
||||
func NewBaseEndpoint(request func(URL string, dataBody any) (*resty.Response, error), endpointName EndpointName) *BaseEndpoint {
|
||||
return &BaseEndpoint{
|
||||
request: request,
|
||||
endpointName: endpointName,
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BaseEndpoint) GetEndpointName() EndpointName {
|
||||
return b.endpointName
|
||||
}
|
||||
|
||||
func (b *BaseEndpoint[T]) Query(query string) ([]*T, error) {
|
||||
if b.queryFunc == nil {
|
||||
return nil, fmt.Errorf("query method must be implemented by specific endpoint")
|
||||
}
|
||||
return b.queryFunc(query)
|
||||
func (b *BaseEndpoint) Query(query string) (any, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (b *BaseEndpoint[T]) GetByID(id uint64) (*T, error) {
|
||||
res, err := b.Query(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) QueryAny(query string) (any, error) {
|
||||
return b.Query(query)
|
||||
}
|
||||
|
||||
func (b *BaseEndpoint[T]) GetByIDs(ids []uint64) ([]*T, error) {
|
||||
builder := strings.Builder{}
|
||||
for i, v := range ids {
|
||||
if i > 0 {
|
||||
builder.WriteByte(',')
|
||||
}
|
||||
builder.WriteString(strconv.FormatUint(v, 10))
|
||||
}
|
||||
return b.Query(fmt.Sprintf("where id = (%s); fields *;", builder.String()))
|
||||
type Endpoint interface {
|
||||
GetEndpointName() EndpointName
|
||||
}
|
||||
|
||||
func (b *BaseEndpoint[T]) Count() (uint64, error) {
|
||||
resp, err := b.request("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)
|
||||
}
|
||||
|
||||
return uint64(res.Count), nil
|
||||
}
|
||||
|
||||
func (b *BaseEndpoint[T]) Paginated(offset, limit uint64) ([]*T, error) {
|
||||
return b.Query(fmt.Sprintf("offset %d; limit %d; fields *; sort id asc;", offset, limit))
|
||||
}
|
||||
|
||||
type EntityEndpoint[T any] interface {
|
||||
GetEndpointName() Name
|
||||
Query(string) ([]*T, error)
|
||||
GetByID(uint64) (*T, error)
|
||||
GetByIDs([]uint64) ([]*T, error)
|
||||
Count() (uint64, error)
|
||||
Paginated(uint64, uint64) ([]*T, error)
|
||||
type EntityEndpoint interface {
|
||||
QueryAny(query string) (any, error)
|
||||
GetEndpointName() EndpointName
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type CharacterGenders struct{ BaseEndpoint }
|
||||
|
||||
func (a *CharacterGenders) Query(query string) ([]*pb.CharacterGender, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/character_genders.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type CharacterMugShots struct{ BaseEndpoint }
|
||||
|
||||
func (a *CharacterMugShots) Query(query string) ([]*pb.CharacterMugShot, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/character_mug_shots.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type CharacterSpecies struct{ BaseEndpoint }
|
||||
|
||||
func (a *CharacterSpecies) Query(query string) ([]*pb.CharacterSpecie, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/character_species.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type Characters struct{ BaseEndpoint }
|
||||
|
||||
func (a *Characters) Query(query string) ([]*pb.Character, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/characters.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type CollectionMembershipTypes struct{ BaseEndpoint }
|
||||
|
||||
func (a *CollectionMembershipTypes) Query(query string) ([]*pb.CollectionMembershipType, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/collection_membership_types.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type CollectionMemberships struct{ BaseEndpoint }
|
||||
|
||||
func (a *CollectionMemberships) Query(query string) ([]*pb.CollectionMembership, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/collection_memberships.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type CollectionRelationTypes struct{ BaseEndpoint }
|
||||
|
||||
func (a *CollectionRelationTypes) Query(query string) ([]*pb.CollectionRelationType, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/collection_relation_types.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type CollectionRelations struct{ BaseEndpoint }
|
||||
|
||||
func (a *CollectionRelations) Query(query string) ([]*pb.CollectionRelation, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/collection_relations.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type CollectionTypes struct{ BaseEndpoint }
|
||||
|
||||
func (a *CollectionTypes) Query(query string) ([]*pb.CollectionType, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/collection_types.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type Collections struct{ BaseEndpoint }
|
||||
|
||||
func (a *Collections) Query(query string) ([]*pb.Collection, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/collections.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -9,23 +9,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type Companies struct{ BaseEndpoint }
|
||||
|
||||
func (a *Companies) Query(query string) ([]*pb.Company, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/companies.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type CompanyLogos struct{ BaseEndpoint }
|
||||
|
||||
func (a *CompanyLogos) Query(query string) ([]*pb.CompanyLogo, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/company_logos.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type CompanyStatuses struct{ BaseEndpoint }
|
||||
|
||||
func (a *CompanyStatuses) Query(query string) ([]*pb.CompanyStatus, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/company_statuses.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type CompanyWebsites struct{ BaseEndpoint }
|
||||
|
||||
func (a *CompanyWebsites) Query(query string) ([]*pb.CompanyWebsite, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/company_websites.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type Covers struct{ BaseEndpoint }
|
||||
|
||||
func (a *Covers) Query(query string) ([]*pb.Cover, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/covers.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type DateFormats struct{ BaseEndpoint }
|
||||
|
||||
func (a *DateFormats) Query(query string) ([]*pb.DateFormat, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/date_formats.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -1,82 +1,82 @@
|
||||
package endpoint
|
||||
|
||||
type Name string
|
||||
type EndpointName 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"
|
||||
EPAgeRatingCategories EndpointName = "age_rating_categories"
|
||||
EPAgeRatingContentDescriptions EndpointName = "age_rating_content_descriptions"
|
||||
EPAgeRatingContentDescriptionsV2 EndpointName = "age_rating_content_descriptions_v2"
|
||||
EPAgeRatingOrganizations EndpointName = "age_rating_organizations"
|
||||
EPAgeRatings EndpointName = "age_ratings"
|
||||
EPAlternativeNames EndpointName = "alternative_names"
|
||||
EPArtworks EndpointName = "artworks"
|
||||
EPCharacterGenders EndpointName = "character_genders"
|
||||
EPCharacterMugShots EndpointName = "character_mug_shots"
|
||||
EPCharacters EndpointName = "characters"
|
||||
EPCharacterSpecies EndpointName = "character_species"
|
||||
EPCollectionMemberships EndpointName = "collection_memberships"
|
||||
EPCollectionMembershipTypes EndpointName = "collection_membership_types"
|
||||
EPCollectionRelations EndpointName = "collection_relations"
|
||||
EPCollectionRelationTypes EndpointName = "collection_relation_types"
|
||||
EPCollections EndpointName = "collections"
|
||||
EPCollectionTypes EndpointName = "collection_types"
|
||||
EPCompanies EndpointName = "companies"
|
||||
EPCompanyLogos EndpointName = "company_logos"
|
||||
EPCompanyStatuses EndpointName = "company_statuses"
|
||||
EPCompanyWebsites EndpointName = "company_websites"
|
||||
EPCovers EndpointName = "covers"
|
||||
EPDateFormats EndpointName = "date_formats"
|
||||
EPEventLogos EndpointName = "event_logos"
|
||||
EPEventNetworks EndpointName = "event_networks"
|
||||
EPEvents EndpointName = "events"
|
||||
EPExternalGames EndpointName = "external_games"
|
||||
EPExternalGameSources EndpointName = "external_game_sources"
|
||||
EPFranchises EndpointName = "franchises"
|
||||
EPGameEngineLogos EndpointName = "game_engine_logos"
|
||||
EPGameEngines EndpointName = "game_engines"
|
||||
EPGameLocalizations EndpointName = "game_localizations"
|
||||
EPGameModes EndpointName = "game_modes"
|
||||
EPGameReleaseFormats EndpointName = "game_release_formats"
|
||||
EPGames EndpointName = "games"
|
||||
EPGameStatuses EndpointName = "game_statuses"
|
||||
EPGameTimeToBeats EndpointName = "game_time_to_beats"
|
||||
EPGameTypes EndpointName = "game_types"
|
||||
EPGameVersionFeatures EndpointName = "game_version_features"
|
||||
EPGameVersionFeatureValues EndpointName = "game_version_feature_values"
|
||||
EPGameVersions EndpointName = "game_versions"
|
||||
EPGameVideos EndpointName = "game_videos"
|
||||
EPGenres EndpointName = "genres"
|
||||
EPInvolvedCompanies EndpointName = "involved_companies"
|
||||
EPKeywords EndpointName = "keywords"
|
||||
EPLanguages EndpointName = "languages"
|
||||
EPLanguageSupports EndpointName = "language_supports"
|
||||
EPLanguageSupportTypes EndpointName = "language_support_types"
|
||||
EPMultiplayerModes EndpointName = "multiplayer_modes"
|
||||
EPNetworkTypes EndpointName = "network_types"
|
||||
EPPlatformFamilies EndpointName = "platform_families"
|
||||
EPPlatformLogos EndpointName = "platform_logos"
|
||||
EPPlatforms EndpointName = "platforms"
|
||||
EPPlatformTypes EndpointName = "platform_types"
|
||||
EPPlatformVersionCompanies EndpointName = "platform_version_companies"
|
||||
EPPlatformVersionReleaseDates EndpointName = "platform_version_release_dates"
|
||||
EPPlatformVersions EndpointName = "platform_versions"
|
||||
EPPlatformWebsites EndpointName = "platform_websites"
|
||||
EPPlayerPerspectives EndpointName = "player_perspectives"
|
||||
EPPopularityPrimitives EndpointName = "popularity_primitives"
|
||||
EPPopularityTypes EndpointName = "popularity_types"
|
||||
EPRegions EndpointName = "regions"
|
||||
EPReleaseDateRegions EndpointName = "release_date_regions"
|
||||
EPReleaseDates EndpointName = "release_dates"
|
||||
EPReleaseDateStatuses EndpointName = "release_date_statuses"
|
||||
EPScreenshots EndpointName = "screenshots"
|
||||
EPSearch EndpointName = "search"
|
||||
EPThemes EndpointName = "themes"
|
||||
EPWebhooks EndpointName = "webhooks"
|
||||
EPWebsites EndpointName = "websites"
|
||||
EPWebsiteTypes EndpointName = "website_types"
|
||||
)
|
||||
|
||||
var AllNames = []Name{
|
||||
var AllEndpoints = []EndpointName{
|
||||
EPAgeRatingCategories,
|
||||
EPAgeRatingContentDescriptions,
|
||||
EPAgeRatingContentDescriptionsV2,
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type EventLogos struct{ BaseEndpoint }
|
||||
|
||||
func (a *EventLogos) Query(query string) ([]*pb.EventLogo, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/event_logos.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type EventNetworks struct{ BaseEndpoint }
|
||||
|
||||
func (a *EventNetworks) Query(query string) ([]*pb.EventNetwork, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/event_networks.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type Events struct{ BaseEndpoint }
|
||||
|
||||
func (a *Events) Query(query string) ([]*pb.Event, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/events.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type ExternalGameSources struct{ BaseEndpoint }
|
||||
|
||||
func (a *ExternalGameSources) Query(query string) ([]*pb.ExternalGameSource, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/external_game_sources.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type ExternalGames struct{ BaseEndpoint }
|
||||
|
||||
func (a *ExternalGames) Query(query string) ([]*pb.ExternalGame, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/external_games.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type Franchises struct {
|
||||
BaseEndpoint[pb.Franchise]
|
||||
}
|
||||
|
||||
func NewFranchises(request RequestFunc) *Franchises {
|
||||
a := &Franchises{
|
||||
BaseEndpoint[pb.Franchise]{
|
||||
endpointName: EPFranchises,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type Franchises struct{ BaseEndpoint }
|
||||
|
||||
func (a *Franchises) Query(query string) ([]*pb.Franchise, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/franchises.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type GameEngineLogos struct{ BaseEndpoint }
|
||||
|
||||
func (a *GameEngineLogos) Query(query string) ([]*pb.GameEngineLogo, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_engine_logos.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type GameEngines struct {
|
||||
BaseEndpoint[pb.GameEngine]
|
||||
}
|
||||
|
||||
func NewGameEngines(request RequestFunc) *GameEngines {
|
||||
a := &GameEngines{
|
||||
BaseEndpoint[pb.GameEngine]{
|
||||
endpointName: EPGameEngines,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type GameEngines struct{ BaseEndpoint }
|
||||
|
||||
func (a *GameEngines) Query(query string) ([]*pb.GameEngine, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_engines.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type GameLocalizations struct {
|
||||
BaseEndpoint[pb.GameLocalization]
|
||||
}
|
||||
|
||||
func NewGameLocalizations(request RequestFunc) *GameLocalizations {
|
||||
a := &GameLocalizations{
|
||||
BaseEndpoint[pb.GameLocalization]{
|
||||
endpointName: EPGameLocalizations,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type GameLocalizations struct{ BaseEndpoint }
|
||||
|
||||
func (a *GameLocalizations) Query(query string) ([]*pb.GameLocalization, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_localizations.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type GameModes struct {
|
||||
BaseEndpoint[pb.GameMode]
|
||||
}
|
||||
|
||||
func NewGameModes(request RequestFunc) *GameModes {
|
||||
a := &GameModes{
|
||||
BaseEndpoint[pb.GameMode]{
|
||||
endpointName: EPGameModes,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type GameModes struct{ BaseEndpoint }
|
||||
|
||||
func (a *GameModes) Query(query string) ([]*pb.GameMode, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_modes.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type GameReleaseFormats struct {
|
||||
BaseEndpoint[pb.GameReleaseFormat]
|
||||
}
|
||||
|
||||
func NewGameReleaseFormats(request RequestFunc) *GameReleaseFormats {
|
||||
a := &GameReleaseFormats{
|
||||
BaseEndpoint[pb.GameReleaseFormat]{
|
||||
endpointName: EPGameReleaseFormats,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type GameReleaseFormats struct{ BaseEndpoint }
|
||||
|
||||
func (a *GameReleaseFormats) Query(query string) ([]*pb.GameReleaseFormat, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_release_formats.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type GameStatuses struct {
|
||||
BaseEndpoint[pb.GameStatus]
|
||||
}
|
||||
|
||||
func NewGameStatuses(request RequestFunc) *GameStatuses {
|
||||
a := &GameStatuses{
|
||||
BaseEndpoint[pb.GameStatus]{
|
||||
endpointName: EPGameStatuses,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type GameStatuses struct{ BaseEndpoint }
|
||||
|
||||
func (a *GameStatuses) Query(query string) ([]*pb.GameStatus, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_statuses.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type GameTimeToBeats struct {
|
||||
BaseEndpoint[pb.GameTimeToBeat]
|
||||
}
|
||||
|
||||
func NewGameTimeToBeats(request RequestFunc) *GameTimeToBeats {
|
||||
a := &GameTimeToBeats{
|
||||
BaseEndpoint[pb.GameTimeToBeat]{
|
||||
endpointName: EPGameTimeToBeats,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type GameTimeToBeats struct{ BaseEndpoint }
|
||||
|
||||
func (a *GameTimeToBeats) Query(query string) ([]*pb.GameTimeToBeat, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_time_to_beats.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type GameTypes struct {
|
||||
BaseEndpoint[pb.GameType]
|
||||
}
|
||||
|
||||
func NewGameTypes(request RequestFunc) *GameTypes {
|
||||
a := &GameTypes{
|
||||
BaseEndpoint[pb.GameType]{
|
||||
endpointName: EPGameTypes,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type GameTypes struct{ BaseEndpoint }
|
||||
|
||||
func (a *GameTypes) Query(query string) ([]*pb.GameType, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_types.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type GameVersionFeatureValues struct {
|
||||
BaseEndpoint[pb.GameVersionFeatureValue]
|
||||
}
|
||||
|
||||
func NewGameVersionFeatureValues(request RequestFunc) *GameVersionFeatureValues {
|
||||
a := &GameVersionFeatureValues{
|
||||
BaseEndpoint[pb.GameVersionFeatureValue]{
|
||||
endpointName: EPGameVersionFeatureValues,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type GameVersionFeatureValues struct{ BaseEndpoint }
|
||||
|
||||
func (a *GameVersionFeatureValues) Query(query string) ([]*pb.GameVersionFeatureValue, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_version_feature_values.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type GameVersionFeatures struct {
|
||||
BaseEndpoint[pb.GameVersionFeature]
|
||||
}
|
||||
|
||||
func NewGameVersionFeatures(request RequestFunc) *GameVersionFeatures {
|
||||
a := &GameVersionFeatures{
|
||||
BaseEndpoint[pb.GameVersionFeature]{
|
||||
endpointName: EPGameVersionFeatures,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type GameVersionFeatures struct{ BaseEndpoint }
|
||||
|
||||
func (a *GameVersionFeatures) Query(query string) ([]*pb.GameVersionFeature, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_version_features.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type GameVersions struct {
|
||||
BaseEndpoint[pb.GameVersion]
|
||||
}
|
||||
|
||||
func NewGameVersions(request RequestFunc) *GameVersions {
|
||||
a := &GameVersions{
|
||||
BaseEndpoint[pb.GameVersion]{
|
||||
endpointName: EPGameVersions,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type GameVersions struct{ BaseEndpoint }
|
||||
|
||||
func (a *GameVersions) Query(query string) ([]*pb.GameVersion, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_versions.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type GameVideos struct {
|
||||
BaseEndpoint[pb.GameVideo]
|
||||
}
|
||||
|
||||
func NewGameVideos(request RequestFunc) *GameVideos {
|
||||
a := &GameVideos{
|
||||
BaseEndpoint[pb.GameVideo]{
|
||||
endpointName: EPGameVideos,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type GameVideos struct{ BaseEndpoint }
|
||||
|
||||
func (a *GameVideos) Query(query string) ([]*pb.GameVideo, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/game_videos.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type Games struct {
|
||||
BaseEndpoint[pb.Game]
|
||||
}
|
||||
|
||||
func NewGames(request RequestFunc) *Games {
|
||||
a := &Games{
|
||||
BaseEndpoint[pb.Game]{
|
||||
endpointName: EPGames,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type Games struct{ BaseEndpoint }
|
||||
|
||||
func (a *Games) Query(query string) ([]*pb.Game, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/games.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type Genres struct {
|
||||
BaseEndpoint[pb.Genre]
|
||||
}
|
||||
|
||||
func NewGenres(request RequestFunc) *Genres {
|
||||
a := &Genres{
|
||||
BaseEndpoint[pb.Genre]{
|
||||
endpointName: EPGenres,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type Genres struct{ BaseEndpoint }
|
||||
|
||||
func (a *Genres) Query(query string) ([]*pb.Genre, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/genres.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type InvolvedCompanies struct {
|
||||
BaseEndpoint[pb.InvolvedCompany]
|
||||
}
|
||||
|
||||
func NewInvolvedCompanies(request RequestFunc) *InvolvedCompanies {
|
||||
a := &InvolvedCompanies{
|
||||
BaseEndpoint[pb.InvolvedCompany]{
|
||||
endpointName: EPInvolvedCompanies,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type InvolvedCompanies struct{ BaseEndpoint }
|
||||
|
||||
func (a *InvolvedCompanies) Query(query string) ([]*pb.InvolvedCompany, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/involved_companies.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type Keywords struct {
|
||||
BaseEndpoint[pb.Keyword]
|
||||
}
|
||||
|
||||
func NewKeywords(request RequestFunc) *Keywords {
|
||||
a := &Keywords{
|
||||
BaseEndpoint[pb.Keyword]{
|
||||
endpointName: EPKeywords,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type Keywords struct{ BaseEndpoint }
|
||||
|
||||
func (a *Keywords) Query(query string) ([]*pb.Keyword, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/keywords.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type LanguageSupportTypes struct{ BaseEndpoint }
|
||||
|
||||
func (a *LanguageSupportTypes) Query(query string) ([]*pb.LanguageSupportType, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/language_support_types.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type LanguageSupports struct {
|
||||
BaseEndpoint[pb.LanguageSupport]
|
||||
}
|
||||
|
||||
func NewLanguageSupports(request RequestFunc) *LanguageSupports {
|
||||
a := &LanguageSupports{
|
||||
BaseEndpoint[pb.LanguageSupport]{
|
||||
endpointName: EPLanguageSupports,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type LanguageSupports struct{ BaseEndpoint }
|
||||
|
||||
func (a *LanguageSupports) Query(query string) ([]*pb.LanguageSupport, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/language_supports.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type Languages struct {
|
||||
BaseEndpoint[pb.Language]
|
||||
}
|
||||
|
||||
func NewLanguages(request RequestFunc) *Languages {
|
||||
a := &Languages{
|
||||
BaseEndpoint[pb.Language]{
|
||||
endpointName: EPLanguages,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type Languages struct{ BaseEndpoint }
|
||||
|
||||
func (a *Languages) Query(query string) ([]*pb.Language, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/languages.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type MultiplayerModes struct {
|
||||
BaseEndpoint[pb.MultiplayerMode]
|
||||
}
|
||||
|
||||
func NewMultiplayerModes(request RequestFunc) *MultiplayerModes {
|
||||
a := &MultiplayerModes{
|
||||
BaseEndpoint[pb.MultiplayerMode]{
|
||||
endpointName: EPMultiplayerModes,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type MultiplayerModes struct{ BaseEndpoint }
|
||||
|
||||
func (a *MultiplayerModes) Query(query string) ([]*pb.MultiplayerMode, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/multiplayer_modes.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type NetworkTypes struct {
|
||||
BaseEndpoint[pb.NetworkType]
|
||||
}
|
||||
|
||||
func NewNetworkTypes(request RequestFunc) *NetworkTypes {
|
||||
a := &NetworkTypes{
|
||||
BaseEndpoint[pb.NetworkType]{
|
||||
endpointName: EPNetworkTypes,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type NetworkTypes struct{ BaseEndpoint }
|
||||
|
||||
func (a *NetworkTypes) Query(query string) ([]*pb.NetworkType, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/network_types.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type PlatformFamilies struct {
|
||||
BaseEndpoint[pb.PlatformFamily]
|
||||
}
|
||||
|
||||
func NewPlatformFamilies(request RequestFunc) *PlatformFamilies {
|
||||
a := &PlatformFamilies{
|
||||
BaseEndpoint[pb.PlatformFamily]{
|
||||
endpointName: EPPlatformFamilies,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type PlatformFamilies struct{ BaseEndpoint }
|
||||
|
||||
func (a *PlatformFamilies) Query(query string) ([]*pb.PlatformFamily, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_families.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type PlatformLogos struct {
|
||||
BaseEndpoint[pb.PlatformLogo]
|
||||
}
|
||||
|
||||
func NewPlatformLogos(request RequestFunc) *PlatformLogos {
|
||||
a := &PlatformLogos{
|
||||
BaseEndpoint[pb.PlatformLogo]{
|
||||
endpointName: EPPlatformLogos,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type PlatformLogos struct{ BaseEndpoint }
|
||||
|
||||
func (a *PlatformLogos) Query(query string) ([]*pb.PlatformLogo, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_logos.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type PlatformTypes struct {
|
||||
BaseEndpoint[pb.PlatformType]
|
||||
}
|
||||
|
||||
func NewPlatformTypes(request RequestFunc) *PlatformTypes {
|
||||
a := &PlatformTypes{
|
||||
BaseEndpoint[pb.PlatformType]{
|
||||
endpointName: EPPlatformTypes,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type PlatformTypes struct{ BaseEndpoint }
|
||||
|
||||
func (a *PlatformTypes) Query(query string) ([]*pb.PlatformType, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_types.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type PlatformVersionCompanies struct {
|
||||
BaseEndpoint[pb.PlatformVersionCompany]
|
||||
}
|
||||
|
||||
func NewPlatformVersionCompanies(request RequestFunc) *PlatformVersionCompanies {
|
||||
a := &PlatformVersionCompanies{
|
||||
BaseEndpoint[pb.PlatformVersionCompany]{
|
||||
endpointName: EPPlatformVersionCompanies,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type PlatformVersionCompanies struct{ BaseEndpoint }
|
||||
|
||||
func (a *PlatformVersionCompanies) Query(query string) ([]*pb.PlatformVersionCompany, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_version_companies.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type PlatformVersionReleaseDates struct {
|
||||
BaseEndpoint[pb.PlatformVersionReleaseDate]
|
||||
}
|
||||
|
||||
func NewPlatformVersionReleaseDates(request RequestFunc) *PlatformVersionReleaseDates {
|
||||
a := &PlatformVersionReleaseDates{
|
||||
BaseEndpoint[pb.PlatformVersionReleaseDate]{
|
||||
endpointName: EPPlatformVersionReleaseDates,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type PlatformVersionReleaseDates struct{ BaseEndpoint }
|
||||
|
||||
func (a *PlatformVersionReleaseDates) Query(query string) ([]*pb.PlatformVersionReleaseDate, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_version_release_dates.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type PlatformVersions struct {
|
||||
BaseEndpoint[pb.PlatformVersion]
|
||||
}
|
||||
|
||||
func NewPlatformVersions(request RequestFunc) *PlatformVersions {
|
||||
a := &PlatformVersions{
|
||||
BaseEndpoint[pb.PlatformVersion]{
|
||||
endpointName: EPPlatformVersions,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type PlatformVersions struct{ BaseEndpoint }
|
||||
|
||||
func (a *PlatformVersions) Query(query string) ([]*pb.PlatformVersion, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_versions.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type PlatformWebsites struct {
|
||||
BaseEndpoint[pb.PlatformWebsite]
|
||||
}
|
||||
|
||||
func NewPlatformWebsites(request RequestFunc) *PlatformWebsites {
|
||||
a := &PlatformWebsites{
|
||||
BaseEndpoint[pb.PlatformWebsite]{
|
||||
endpointName: EPPlatformWebsites,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type PlatformWebsites struct{ BaseEndpoint }
|
||||
|
||||
func (a *PlatformWebsites) Query(query string) ([]*pb.PlatformWebsite, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/platform_websites.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type Platforms struct{ BaseEndpoint }
|
||||
|
||||
func (a *Platforms) Query(query string) ([]*pb.Platform, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/platforms.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type PlayerPerspectives struct {
|
||||
BaseEndpoint[pb.PlayerPerspective]
|
||||
}
|
||||
|
||||
func NewPlayerPerspectives(request RequestFunc) *PlayerPerspectives {
|
||||
a := &PlayerPerspectives{
|
||||
BaseEndpoint[pb.PlayerPerspective]{
|
||||
endpointName: EPPlayerPerspectives,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type PlayerPerspectives struct{ BaseEndpoint }
|
||||
|
||||
func (a *PlayerPerspectives) Query(query string) ([]*pb.PlayerPerspective, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/player_perspectives.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"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
|
||||
}
|
||||
type PopularityPrimitives struct{ BaseEndpoint }
|
||||
|
||||
func (a *PopularityPrimitives) Query(query string) ([]*pb.PopularityPrimitive, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/popularity_primitives.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type PopularityTypes struct {
|
||||
BaseEndpoint[pb.PopularityType]
|
||||
}
|
||||
|
||||
func NewPopularityTypes(request RequestFunc) *PopularityTypes {
|
||||
a := &PopularityTypes{
|
||||
BaseEndpoint[pb.PopularityType]{
|
||||
endpointName: EPPopularityTypes,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type PopularityTypes struct{ BaseEndpoint }
|
||||
|
||||
func (a *PopularityTypes) Query(query string) ([]*pb.PopularityType, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/popularity_types.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type Regions struct {
|
||||
BaseEndpoint[pb.Region]
|
||||
}
|
||||
|
||||
func NewRegions(request RequestFunc) *Regions {
|
||||
a := &Regions{
|
||||
BaseEndpoint[pb.Region]{
|
||||
endpointName: EPRegions,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type Regions struct{ BaseEndpoint }
|
||||
|
||||
func (a *Regions) Query(query string) ([]*pb.Region, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/regions.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type ReleaseDateRegions struct {
|
||||
BaseEndpoint[pb.ReleaseDateRegion]
|
||||
}
|
||||
|
||||
func NewReleaseDateRegions(request RequestFunc) *ReleaseDateRegions {
|
||||
a := &ReleaseDateRegions{
|
||||
BaseEndpoint[pb.ReleaseDateRegion]{
|
||||
endpointName: EPReleaseDateRegions,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type ReleaseDateRegions struct{ BaseEndpoint }
|
||||
|
||||
func (a *ReleaseDateRegions) Query(query string) ([]*pb.ReleaseDateRegion, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/release_date_regions.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type ReleaseDateStatuses struct {
|
||||
BaseEndpoint[pb.ReleaseDateStatus]
|
||||
}
|
||||
|
||||
func NewReleaseDateStatuses(request RequestFunc) *ReleaseDateStatuses {
|
||||
a := &ReleaseDateStatuses{
|
||||
BaseEndpoint[pb.ReleaseDateStatus]{
|
||||
endpointName: EPReleaseDateStatuses,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type ReleaseDateStatuses struct{ BaseEndpoint }
|
||||
|
||||
func (a *ReleaseDateStatuses) Query(query string) ([]*pb.ReleaseDateStatus, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/release_date_statuses.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type ReleaseDates struct {
|
||||
BaseEndpoint[pb.ReleaseDate]
|
||||
}
|
||||
|
||||
func NewReleaseDates(request RequestFunc) *ReleaseDates {
|
||||
a := &ReleaseDates{
|
||||
BaseEndpoint[pb.ReleaseDate]{
|
||||
endpointName: EPReleaseDates,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type ReleaseDates struct{ BaseEndpoint }
|
||||
|
||||
func (a *ReleaseDates) Query(query string) ([]*pb.ReleaseDate, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/release_dates.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type Screenshots struct {
|
||||
BaseEndpoint[pb.Screenshot]
|
||||
}
|
||||
|
||||
func NewScreenshots(request RequestFunc) *Screenshots {
|
||||
a := &Screenshots{
|
||||
BaseEndpoint[pb.Screenshot]{
|
||||
endpointName: EPScreenshots,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type Screenshots struct{ BaseEndpoint }
|
||||
|
||||
func (a *Screenshots) Query(query string) ([]*pb.Screenshot, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/screenshots.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -22,20 +22,12 @@ var webSearchCFCookies struct {
|
||||
}
|
||||
|
||||
type Search struct {
|
||||
endpointName Name
|
||||
request RequestFunc
|
||||
BaseEndpoint
|
||||
flaresolverr *flaresolverr.Flaresolverr
|
||||
}
|
||||
|
||||
func NewSearch(request RequestFunc) *Search {
|
||||
return &Search{
|
||||
endpointName: EPSearch,
|
||||
request: request,
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Search) Search(query string) ([]*pb.Search, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/search.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type Themes struct {
|
||||
BaseEndpoint[pb.Theme]
|
||||
}
|
||||
|
||||
func NewThemes(request RequestFunc) *Themes {
|
||||
a := &Themes{
|
||||
BaseEndpoint[pb.Theme]{
|
||||
endpointName: EPThemes,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type Themes struct{ BaseEndpoint }
|
||||
|
||||
func (a *Themes) Query(query string) ([]*pb.Theme, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/themes.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -1,103 +1,26 @@
|
||||
package endpoint
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type Webhooks struct {
|
||||
request RequestFunc
|
||||
}
|
||||
type Webhooks struct{ BaseEndpoint }
|
||||
|
||||
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(endpoint Name, secret, callbackUrl string, method WebhookMethod) (*WebhookResponse, error) {
|
||||
func (a *Webhooks) Register(endpoint EndpointName, secret, callbackUrl string) error {
|
||||
dataBody := url.Values{}
|
||||
dataBody.Set("url", callbackUrl)
|
||||
dataBody.Set("secret", secret)
|
||||
dataBody.Set("method", string(method))
|
||||
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s/webhooks/", endpoint), dataBody.Encode())
|
||||
dataBody.Set("method", "update")
|
||||
resp, err := a.request(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(webhookId uint64) error {
|
||||
resp, err := a.request("DELETE", fmt.Sprintf("https://api.igdb.com/v4/webhooks/%v", webhookId), "")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to make request: %w", err)
|
||||
return fmt.Errorf("failed to make request: %s: %w", callbackUrl, err)
|
||||
}
|
||||
|
||||
if resp.StatusCode() == http.StatusOK {
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("failed to unregister webhook: %s", resp.String())
|
||||
}
|
||||
|
||||
func (a *Webhooks) List() ([]*WebhookResponse, error) {
|
||||
resp, err := a.request("GET", "https://api.igdb.com/v4/webhooks/", "")
|
||||
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(webhookId uint64) (*WebhookResponse, error) {
|
||||
resp, err := a.request("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
|
||||
return fmt.Errorf("failed to activate webhook: %s: %s", callbackUrl, resp.String())
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type WebsiteTypes struct {
|
||||
BaseEndpoint[pb.WebsiteType]
|
||||
}
|
||||
|
||||
func NewWebsiteTypes(request RequestFunc) *WebsiteTypes {
|
||||
a := &WebsiteTypes{
|
||||
BaseEndpoint[pb.WebsiteType]{
|
||||
endpointName: EPWebsiteTypes,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type WebsiteTypes struct{ BaseEndpoint }
|
||||
|
||||
func (a *WebsiteTypes) Query(query string) ([]*pb.WebsiteType, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/website_types.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -8,23 +8,10 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
type Websites struct {
|
||||
BaseEndpoint[pb.Website]
|
||||
}
|
||||
|
||||
func NewWebsites(request RequestFunc) *Websites {
|
||||
a := &Websites{
|
||||
BaseEndpoint[pb.Website]{
|
||||
endpointName: EPWebsites,
|
||||
request: request,
|
||||
},
|
||||
}
|
||||
a.queryFunc = a.Query
|
||||
return a
|
||||
}
|
||||
type Websites struct{ BaseEndpoint }
|
||||
|
||||
func (a *Websites) Query(query string) ([]*pb.Website, error) {
|
||||
resp, err := a.request("POST", fmt.Sprintf("https://api.igdb.com/v4/%s.pb", a.endpointName), query)
|
||||
resp, err := a.request("https://api.igdb.com/v4/websites.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
}
|
||||
|
@ -1,149 +1,358 @@
|
||||
package igdb
|
||||
|
||||
import (
|
||||
"github.com/bestnite/go-igdb/endpoint"
|
||||
)
|
||||
import "github.com/bestnite/go-igdb/endpoint"
|
||||
|
||||
func registerAllEndpoints(c *Client) {
|
||||
c.AgeRatingCategories = endpoint.NewAgeRatingCategories(c.Request)
|
||||
|
||||
c.AgeRatingContentDescriptions = endpoint.NewAgeRatingContentDescriptions(c.Request)
|
||||
|
||||
c.AgeRatingContentDescriptionsV2 = endpoint.NewAgeRatingContentDescriptionsV2(c.Request)
|
||||
|
||||
c.AgeRatingOrganizations = endpoint.NewAgeRatingOrganizations(c.Request)
|
||||
|
||||
c.AgeRatings = endpoint.NewAgeRatings(c.Request)
|
||||
|
||||
c.AlternativeNames = endpoint.NewAlternativeNames(c.Request)
|
||||
|
||||
c.Artworks = endpoint.NewArtworks(c.Request)
|
||||
|
||||
c.CharacterGenders = endpoint.NewCharacterGenders(c.Request)
|
||||
|
||||
c.CharacterMugShots = endpoint.NewCharacterMugShots(c.Request)
|
||||
|
||||
c.Characters = endpoint.NewCharacters(c.Request)
|
||||
|
||||
c.CharacterSpecies = endpoint.NewCharacterSpecies(c.Request)
|
||||
|
||||
c.CollectionMemberships = endpoint.NewCollectionMemberships(c.Request)
|
||||
|
||||
c.CollectionMembershipTypes = endpoint.NewCollectionMembershipTypes(c.Request)
|
||||
|
||||
c.CollectionRelations = endpoint.NewCollectionRelations(c.Request)
|
||||
|
||||
c.CollectionRelationTypes = endpoint.NewCollectionRelationTypes(c.Request)
|
||||
|
||||
c.Collections = endpoint.NewCollections(c.Request)
|
||||
|
||||
c.CollectionTypes = endpoint.NewCollectionTypes(c.Request)
|
||||
|
||||
c.Companies = endpoint.NewCompanies(c.Request)
|
||||
|
||||
c.CompanyLogos = endpoint.NewCompanyLogos(c.Request)
|
||||
|
||||
c.CompanyStatuses = endpoint.NewCompanyStatuses(c.Request)
|
||||
|
||||
c.CompanyWebsites = endpoint.NewCompanyWebsites(c.Request)
|
||||
|
||||
c.Covers = endpoint.NewCovers(c.Request)
|
||||
|
||||
c.DateFormats = endpoint.NewDateFormats(c.Request)
|
||||
|
||||
c.EventLogos = endpoint.NewEventLogos(c.Request)
|
||||
|
||||
c.EventNetworks = endpoint.NewEventNetworks(c.Request)
|
||||
|
||||
c.Events = endpoint.NewEvents(c.Request)
|
||||
|
||||
c.ExternalGames = endpoint.NewExternalGames(c.Request)
|
||||
|
||||
c.ExternalGameSources = endpoint.NewExternalGameSources(c.Request)
|
||||
|
||||
c.Franchises = endpoint.NewFranchises(c.Request)
|
||||
|
||||
c.GameEngineLogos = endpoint.NewGameEngineLogos(c.Request)
|
||||
|
||||
c.GameEngines = endpoint.NewGameEngines(c.Request)
|
||||
|
||||
c.GameLocalizations = endpoint.NewGameLocalizations(c.Request)
|
||||
|
||||
c.GameModes = endpoint.NewGameModes(c.Request)
|
||||
|
||||
c.GameReleaseFormats = endpoint.NewGameReleaseFormats(c.Request)
|
||||
|
||||
c.Games = endpoint.NewGames(c.Request)
|
||||
|
||||
c.GameStatuses = endpoint.NewGameStatuses(c.Request)
|
||||
|
||||
c.GameTimeToBeats = endpoint.NewGameTimeToBeats(c.Request)
|
||||
|
||||
c.GameTypes = endpoint.NewGameTypes(c.Request)
|
||||
|
||||
c.GameVersionFeatures = endpoint.NewGameVersionFeatures(c.Request)
|
||||
|
||||
c.GameVersionFeatureValues = endpoint.NewGameVersionFeatureValues(c.Request)
|
||||
|
||||
c.GameVersions = endpoint.NewGameVersions(c.Request)
|
||||
|
||||
c.GameVideos = endpoint.NewGameVideos(c.Request)
|
||||
|
||||
c.Genres = endpoint.NewGenres(c.Request)
|
||||
|
||||
c.InvolvedCompanies = endpoint.NewInvolvedCompanies(c.Request)
|
||||
|
||||
c.Keywords = endpoint.NewKeywords(c.Request)
|
||||
|
||||
c.Languages = endpoint.NewLanguages(c.Request)
|
||||
|
||||
c.LanguageSupports = endpoint.NewLanguageSupports(c.Request)
|
||||
|
||||
c.LanguageSupportTypes = endpoint.NewLanguageSupportTypes(c.Request)
|
||||
|
||||
c.MultiplayerModes = endpoint.NewMultiplayerModes(c.Request)
|
||||
|
||||
c.NetworkTypes = endpoint.NewNetworkTypes(c.Request)
|
||||
|
||||
c.PlatformFamilies = endpoint.NewPlatformFamilies(c.Request)
|
||||
|
||||
c.PlatformLogos = endpoint.NewPlatformLogos(c.Request)
|
||||
|
||||
c.Platforms = endpoint.NewPlatforms(c.Request)
|
||||
|
||||
c.PlatformTypes = endpoint.NewPlatformTypes(c.Request)
|
||||
|
||||
c.PlatformVersionCompanies = endpoint.NewPlatformVersionCompanies(c.Request)
|
||||
|
||||
c.PlatformVersionReleaseDates = endpoint.NewPlatformVersionReleaseDates(c.Request)
|
||||
|
||||
c.PlatformVersions = endpoint.NewPlatformVersions(c.Request)
|
||||
|
||||
c.PlatformWebsites = endpoint.NewPlatformWebsites(c.Request)
|
||||
|
||||
c.PlayerPerspectives = endpoint.NewPlayerPerspectives(c.Request)
|
||||
|
||||
c.PopularityPrimitives = endpoint.NewPopularityPrimitives(c.Request)
|
||||
|
||||
c.PopularityTypes = endpoint.NewPopularityTypes(c.Request)
|
||||
|
||||
c.Regions = endpoint.NewRegions(c.Request)
|
||||
|
||||
c.ReleaseDateRegions = endpoint.NewReleaseDateRegions(c.Request)
|
||||
|
||||
c.ReleaseDates = endpoint.NewReleaseDates(c.Request)
|
||||
|
||||
c.ReleaseDateStatuses = endpoint.NewReleaseDateStatuses(c.Request)
|
||||
|
||||
c.Screenshots = endpoint.NewScreenshots(c.Request)
|
||||
|
||||
c.Themes = endpoint.NewThemes(c.Request)
|
||||
|
||||
c.Websites = endpoint.NewWebsites(c.Request)
|
||||
|
||||
c.WebsiteTypes = endpoint.NewWebsiteTypes(c.Request)
|
||||
|
||||
c.Webhooks = endpoint.NewWebhooks(c.Request)
|
||||
|
||||
c.Search = endpoint.NewSearch(c.Request)
|
||||
c.AgeRatingCategories = &endpoint.AgeRatingCategories{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPAgeRatingCategories),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPAgeRatingCategories] = c.AgeRatingCategories
|
||||
|
||||
c.AgeRatingContentDescriptions = &endpoint.AgeRatingContentDescriptions{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPAgeRatingContentDescriptions),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPAgeRatingContentDescriptions] = c.AgeRatingContentDescriptions
|
||||
|
||||
c.AgeRatingContentDescriptionsV2 = &endpoint.AgeRatingContentDescriptionsV2{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPAgeRatingContentDescriptionsV2),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPAgeRatingContentDescriptionsV2] = c.AgeRatingContentDescriptionsV2
|
||||
|
||||
c.AgeRatingOrganizations = &endpoint.AgeRatingOrganizations{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPAgeRatingOrganizations),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPAgeRatingOrganizations] = c.AgeRatingOrganizations
|
||||
|
||||
c.AgeRatings = &endpoint.AgeRatings{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPAgeRatings),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPAgeRatings] = c.AgeRatings
|
||||
|
||||
c.AlternativeNames = &endpoint.AlternativeNames{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPAlternativeNames),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPAlternativeNames] = c.AlternativeNames
|
||||
|
||||
c.Artworks = &endpoint.Artworks{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPArtworks),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPArtworks] = c.Artworks
|
||||
|
||||
c.CharacterGenders = &endpoint.CharacterGenders{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCharacterGenders),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCharacterGenders] = c.CharacterGenders
|
||||
|
||||
c.CharacterMugShots = &endpoint.CharacterMugShots{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCharacterMugShots),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCharacterMugShots] = c.CharacterMugShots
|
||||
|
||||
c.Characters = &endpoint.Characters{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCharacters),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCharacters] = c.Characters
|
||||
|
||||
c.CharacterSpecies = &endpoint.CharacterSpecies{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCharacterSpecies),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCharacterSpecies] = c.CharacterSpecies
|
||||
|
||||
c.CollectionMemberships = &endpoint.CollectionMemberships{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCollectionMemberships),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCollectionMemberships] = c.CollectionMemberships
|
||||
|
||||
c.CollectionMembershipTypes = &endpoint.CollectionMembershipTypes{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCollectionMembershipTypes),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCollectionMembershipTypes] = c.CollectionMembershipTypes
|
||||
|
||||
c.CollectionRelations = &endpoint.CollectionRelations{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCollectionRelations),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCollectionRelations] = c.CollectionRelations
|
||||
|
||||
c.CollectionRelationTypes = &endpoint.CollectionRelationTypes{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCollectionRelationTypes),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCollectionRelationTypes] = c.CollectionRelationTypes
|
||||
|
||||
c.Collections = &endpoint.Collections{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCollections),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCollections] = c.Collections
|
||||
|
||||
c.CollectionTypes = &endpoint.CollectionTypes{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCollectionTypes),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCollectionTypes] = c.CollectionTypes
|
||||
|
||||
c.Companies = &endpoint.Companies{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCompanies),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCompanies] = c.Companies
|
||||
|
||||
c.CompanyLogos = &endpoint.CompanyLogos{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCompanyLogos),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCompanyLogos] = c.CompanyLogos
|
||||
|
||||
c.CompanyStatuses = &endpoint.CompanyStatuses{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCompanyStatuses),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCompanyStatuses] = c.CompanyStatuses
|
||||
|
||||
c.CompanyWebsites = &endpoint.CompanyWebsites{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCompanyWebsites),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCompanyWebsites] = c.CompanyWebsites
|
||||
|
||||
c.Covers = &endpoint.Covers{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPCovers),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPCovers] = c.Covers
|
||||
|
||||
c.DateFormats = &endpoint.DateFormats{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPDateFormats),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPDateFormats] = c.DateFormats
|
||||
|
||||
c.EventLogos = &endpoint.EventLogos{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPEventLogos),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPEventLogos] = c.EventLogos
|
||||
|
||||
c.EventNetworks = &endpoint.EventNetworks{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPEventNetworks),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPEventNetworks] = c.EventNetworks
|
||||
|
||||
c.Events = &endpoint.Events{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPEvents),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPEvents] = c.Events
|
||||
|
||||
c.ExternalGames = &endpoint.ExternalGames{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPExternalGames),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPExternalGames] = c.ExternalGames
|
||||
|
||||
c.ExternalGameSources = &endpoint.ExternalGameSources{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPExternalGameSources),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPExternalGameSources] = c.ExternalGameSources
|
||||
|
||||
c.Franchises = &endpoint.Franchises{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPFranchises),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPFranchises] = c.Franchises
|
||||
|
||||
c.GameEngineLogos = &endpoint.GameEngineLogos{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGameEngineLogos),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGameEngineLogos] = c.GameEngineLogos
|
||||
|
||||
c.GameEngines = &endpoint.GameEngines{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGameEngines),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGameEngines] = c.GameEngines
|
||||
|
||||
c.GameLocalizations = &endpoint.GameLocalizations{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGameLocalizations),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGameLocalizations] = c.GameLocalizations
|
||||
|
||||
c.GameModes = &endpoint.GameModes{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGameModes),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGameModes] = c.GameModes
|
||||
|
||||
c.GameReleaseFormats = &endpoint.GameReleaseFormats{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGameReleaseFormats),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGameReleaseFormats] = c.GameReleaseFormats
|
||||
|
||||
c.Games = &endpoint.Games{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGames),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGames] = c.Games
|
||||
|
||||
c.GameStatuses = &endpoint.GameStatuses{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGameStatuses),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGameStatuses] = c.GameStatuses
|
||||
|
||||
c.GameTimeToBeats = &endpoint.GameTimeToBeats{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGameTimeToBeats),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGameTimeToBeats] = c.GameTimeToBeats
|
||||
|
||||
c.GameTypes = &endpoint.GameTypes{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGameTypes),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGameTypes] = c.GameTypes
|
||||
|
||||
c.GameVersionFeatures = &endpoint.GameVersionFeatures{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGameVersionFeatures),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGameVersionFeatures] = c.GameVersionFeatures
|
||||
|
||||
c.GameVersionFeatureValues = &endpoint.GameVersionFeatureValues{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGameVersionFeatureValues),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGameVersionFeatureValues] = c.GameVersionFeatureValues
|
||||
|
||||
c.GameVersions = &endpoint.GameVersions{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGameVersions),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGameVersions] = c.GameVersions
|
||||
|
||||
c.GameVideos = &endpoint.GameVideos{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGameVideos),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGameVideos] = c.GameVideos
|
||||
|
||||
c.Genres = &endpoint.Genres{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPGenres),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPGenres] = c.Genres
|
||||
|
||||
c.InvolvedCompanies = &endpoint.InvolvedCompanies{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPInvolvedCompanies),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPInvolvedCompanies] = c.InvolvedCompanies
|
||||
|
||||
c.Keywords = &endpoint.Keywords{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPKeywords),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPKeywords] = c.Keywords
|
||||
|
||||
c.Languages = &endpoint.Languages{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPLanguages),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPLanguages] = c.Languages
|
||||
|
||||
c.LanguageSupports = &endpoint.LanguageSupports{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPLanguageSupports),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPLanguageSupports] = c.LanguageSupports
|
||||
|
||||
c.LanguageSupportTypes = &endpoint.LanguageSupportTypes{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPLanguageSupportTypes),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPLanguageSupportTypes] = c.LanguageSupportTypes
|
||||
|
||||
c.MultiplayerModes = &endpoint.MultiplayerModes{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPMultiplayerModes),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPMultiplayerModes] = c.MultiplayerModes
|
||||
|
||||
c.NetworkTypes = &endpoint.NetworkTypes{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPNetworkTypes),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPNetworkTypes] = c.NetworkTypes
|
||||
|
||||
c.PlatformFamilies = &endpoint.PlatformFamilies{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPPlatformFamilies),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPPlatformFamilies] = c.PlatformFamilies
|
||||
|
||||
c.PlatformLogos = &endpoint.PlatformLogos{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPPlatformLogos),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPPlatformLogos] = c.PlatformLogos
|
||||
|
||||
c.Platforms = &endpoint.Platforms{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPPlatforms),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPPlatforms] = c.Platforms
|
||||
|
||||
c.PlatformTypes = &endpoint.PlatformTypes{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPPlatformTypes),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPPlatformTypes] = c.PlatformTypes
|
||||
|
||||
c.PlatformVersionCompanies = &endpoint.PlatformVersionCompanies{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPPlatformVersionCompanies),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPPlatformVersionCompanies] = c.PlatformVersionCompanies
|
||||
|
||||
c.PlatformVersionReleaseDates = &endpoint.PlatformVersionReleaseDates{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPPlatformVersionReleaseDates),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPPlatformVersionReleaseDates] = c.PlatformVersionReleaseDates
|
||||
|
||||
c.PlatformVersions = &endpoint.PlatformVersions{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPPlatformVersions),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPPlatformVersions] = c.PlatformVersions
|
||||
|
||||
c.PlatformWebsites = &endpoint.PlatformWebsites{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPPlatformWebsites),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPPlatformWebsites] = c.PlatformWebsites
|
||||
|
||||
c.PlayerPerspectives = &endpoint.PlayerPerspectives{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPPlayerPerspectives),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPPlayerPerspectives] = c.PlayerPerspectives
|
||||
|
||||
c.PopularityPrimitives = &endpoint.PopularityPrimitives{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPPopularityPrimitives),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPPopularityPrimitives] = c.PopularityPrimitives
|
||||
|
||||
c.PopularityTypes = &endpoint.PopularityTypes{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPPopularityTypes),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPPopularityTypes] = c.PopularityTypes
|
||||
|
||||
c.Regions = &endpoint.Regions{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPRegions),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPRegions] = c.Regions
|
||||
|
||||
c.ReleaseDateRegions = &endpoint.ReleaseDateRegions{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPReleaseDateRegions),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPReleaseDateRegions] = c.ReleaseDateRegions
|
||||
|
||||
c.ReleaseDates = &endpoint.ReleaseDates{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPReleaseDates),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPReleaseDates] = c.ReleaseDates
|
||||
|
||||
c.ReleaseDateStatuses = &endpoint.ReleaseDateStatuses{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPReleaseDateStatuses),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPReleaseDateStatuses] = c.ReleaseDateStatuses
|
||||
|
||||
c.Screenshots = &endpoint.Screenshots{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPScreenshots),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPScreenshots] = c.Screenshots
|
||||
|
||||
c.Themes = &endpoint.Themes{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPThemes),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPThemes] = c.Themes
|
||||
|
||||
c.Websites = &endpoint.Websites{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPWebsites),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPWebsites] = c.Websites
|
||||
|
||||
c.WebsiteTypes = &endpoint.WebsiteTypes{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPWebsiteTypes),
|
||||
}
|
||||
c.EntityEndpoints[endpoint.EPWebsiteTypes] = c.WebsiteTypes
|
||||
|
||||
c.Webhooks = &endpoint.Webhooks{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPWebhooks),
|
||||
}
|
||||
|
||||
c.Search = &endpoint.Search{
|
||||
BaseEndpoint: *endpoint.NewBaseEndpoint(c.Request, endpoint.EPSearch),
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,6 @@ func request() *resty.Request {
|
||||
|
||||
type disableLogger struct{}
|
||||
|
||||
func (d disableLogger) Errorf(string, ...interface{}) {}
|
||||
func (d disableLogger) Warnf(string, ...interface{}) {}
|
||||
func (d disableLogger) Debugf(string, ...interface{}) {}
|
||||
func (d disableLogger) Errorf(format string, v ...interface{}) {}
|
||||
func (d disableLogger) Warnf(format string, v ...interface{}) {}
|
||||
func (d disableLogger) Debugf(format string, v ...interface{}) {}
|
||||
|
10
token.go
10
token.go
@ -7,21 +7,21 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type TwitchToken struct {
|
||||
type twitchToken struct {
|
||||
clientID string
|
||||
clientSecret string
|
||||
token string
|
||||
expires time.Time
|
||||
}
|
||||
|
||||
func NewTwitchToken(clientID, clientSecret string) *TwitchToken {
|
||||
return &TwitchToken{
|
||||
func NewTwitchToken(clientID, clientSecret string) *twitchToken {
|
||||
return &twitchToken{
|
||||
clientID: clientID,
|
||||
clientSecret: clientSecret,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TwitchToken) getToken() (string, error) {
|
||||
func (t *twitchToken) getToken() (string, error) {
|
||||
if t.token != "" && time.Now().Before(t.expires) {
|
||||
return t.token, nil
|
||||
}
|
||||
@ -34,7 +34,7 @@ func (t *TwitchToken) getToken() (string, error) {
|
||||
return token, nil
|
||||
}
|
||||
|
||||
func (t *TwitchToken) loginTwitch() (string, time.Duration, error) {
|
||||
func (t *twitchToken) loginTwitch() (string, time.Duration, error) {
|
||||
baseURL, _ := url.Parse("https://id.twitch.tv/oauth2/token")
|
||||
params := url.Values{}
|
||||
params.Add("client_id", t.clientID)
|
||||
|
Loading…
x
Reference in New Issue
Block a user