forked from nite/go-igdb
u
This commit is contained in:
20
platforms.go
20
platforms.go
@@ -9,7 +9,7 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func (g *igdb) GetPlatforms(query string) ([]*pb.Platform, error) {
|
||||
func (g *Client) GetPlatforms(query string) ([]*pb.Platform, error) {
|
||||
resp, err := g.Request("https://api.igdb.com/v4/platforms.pb", query)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to request: %w", err)
|
||||
@@ -26,7 +26,7 @@ func (g *igdb) GetPlatforms(query string) ([]*pb.Platform, error) {
|
||||
return data.Platforms, nil
|
||||
}
|
||||
|
||||
func (g *igdb) GetPlatformByID(id uint64) (*pb.Platform, error) {
|
||||
func (g *Client) GetPlatformByID(id uint64) (*pb.Platform, error) {
|
||||
query := fmt.Sprintf(`where id=%d; fields *;`, id)
|
||||
platforms, err := g.GetPlatforms(query)
|
||||
if err != nil {
|
||||
@@ -35,7 +35,7 @@ func (g *igdb) GetPlatformByID(id uint64) (*pb.Platform, error) {
|
||||
return platforms[0], nil
|
||||
}
|
||||
|
||||
func (g *igdb) GetPlatformsByIDs(ids []uint64) ([]*pb.Platform, error) {
|
||||
func (g *Client) GetPlatformsByIDs(ids []uint64) ([]*pb.Platform, error) {
|
||||
idStrSlice := make([]string, len(ids))
|
||||
for i, id := range ids {
|
||||
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||
@@ -46,12 +46,12 @@ func (g *igdb) GetPlatformsByIDs(ids []uint64) ([]*pb.Platform, error) {
|
||||
return g.GetPlatforms(idStr)
|
||||
}
|
||||
|
||||
func (g *igdb) GetPlatformsByPlatformFamilyID(id uint64) ([]*pb.Platform, error) {
|
||||
func (g *Client) GetPlatformsByPlatformFamilyID(id uint64) ([]*pb.Platform, error) {
|
||||
query := fmt.Sprintf(`where platform_family = %d; fields *;`, id)
|
||||
return g.GetPlatforms(query)
|
||||
}
|
||||
|
||||
func (g *igdb) GetPlatformsByPlatformFamilyIDs(ids []uint64) ([]*pb.Platform, error) {
|
||||
func (g *Client) GetPlatformsByPlatformFamilyIDs(ids []uint64) ([]*pb.Platform, error) {
|
||||
idStrSlice := make([]string, len(ids))
|
||||
for i, id := range ids {
|
||||
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||
@@ -62,12 +62,12 @@ func (g *igdb) GetPlatformsByPlatformFamilyIDs(ids []uint64) ([]*pb.Platform, er
|
||||
return g.GetPlatforms(idStr)
|
||||
}
|
||||
|
||||
func (g *igdb) GetPlatformsByPlatformLogoID(id uint64) ([]*pb.Platform, error) {
|
||||
func (g *Client) GetPlatformsByPlatformLogoID(id uint64) ([]*pb.Platform, error) {
|
||||
query := fmt.Sprintf(`where platform_logo = %d; fields *;`, id)
|
||||
return g.GetPlatforms(query)
|
||||
}
|
||||
|
||||
func (g *igdb) GetPlatformsByPlatformLogoIDs(ids []uint64) ([]*pb.Platform, error) {
|
||||
func (g *Client) GetPlatformsByPlatformLogoIDs(ids []uint64) ([]*pb.Platform, error) {
|
||||
idStrSlice := make([]string, len(ids))
|
||||
for i, id := range ids {
|
||||
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||
@@ -78,12 +78,12 @@ func (g *igdb) GetPlatformsByPlatformLogoIDs(ids []uint64) ([]*pb.Platform, erro
|
||||
return g.GetPlatforms(idStr)
|
||||
}
|
||||
|
||||
func (g *igdb) GetPlatformsByPlatformTypeID(id uint64) ([]*pb.Platform, error) {
|
||||
func (g *Client) GetPlatformsByPlatformTypeID(id uint64) ([]*pb.Platform, error) {
|
||||
query := fmt.Sprintf(`where platform_type = %d; fields *;`, id)
|
||||
return g.GetPlatforms(query)
|
||||
}
|
||||
|
||||
func (g *igdb) GetPlatformsByPlatformTypeIDs(ids []uint64) ([]*pb.Platform, error) {
|
||||
func (g *Client) GetPlatformsByPlatformTypeIDs(ids []uint64) ([]*pb.Platform, error) {
|
||||
idStrSlice := make([]string, len(ids))
|
||||
for i, id := range ids {
|
||||
idStrSlice[i] = fmt.Sprintf("%d", id)
|
||||
@@ -94,7 +94,7 @@ func (g *igdb) GetPlatformsByPlatformTypeIDs(ids []uint64) ([]*pb.Platform, erro
|
||||
return g.GetPlatforms(idStr)
|
||||
}
|
||||
|
||||
func (g *igdb) GetPlatformsLength() (int, error) {
|
||||
func (g *Client) GetPlatformsLength() (int, error) {
|
||||
query := `fields *; sort id desc; limit 1;`
|
||||
platforms, err := g.GetPlatforms(query)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user