Skip to content

Commit

Permalink
Merge pull request #68 from Henry-Sarabia/dev
Browse files Browse the repository at this point in the history
Patch v1.0.3
  • Loading branch information
Henry Sarabia authored Feb 4, 2020
2 parents 1196f3f + ebe0e72 commit 21fbf59
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 43 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"go.inferGopath": false
}
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
# IGDB

[![GoDoc](https://godoc.org/github.com/Henry-Sarabia/igdb?status.svg)](https://godoc.org/github.com/Henry-Sarabia/igdb) [![Build Status](https://travis-ci.org/Henry-Sarabia/igdb.svg?branch=master)](https://travis-ci.org/Henry-Sarabia/igdb) [![Coverage Status](https://coveralls.io/repos/github/Henry-Sarabia/igdb/badge.svg?branch=master)](https://coveralls.io/github/Henry-Sarabia/igdb?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/Henry-Sarabia/igdb)](https://goreportcard.com/report/github.com/Henry-Sarabia/igdb) [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)
[![GoDoc](https://godoc.org/github.com/Henry-Sarabia/igdb?status.svg)](https://pkg.go.dev/github.com/Henry-Sarabia/igdb?tab=doc) [![Build Status](https://travis-ci.org/Henry-Sarabia/igdb.svg?branch=master)](https://travis-ci.org/Henry-Sarabia/igdb) [![Coverage Status](https://coveralls.io/repos/github/Henry-Sarabia/igdb/badge.svg?branch=master)](https://coveralls.io/github/Henry-Sarabia/igdb?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/Henry-Sarabia/igdb)](https://goreportcard.com/report/github.com/Henry-Sarabia/igdb) [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)

<img align="right" src="https://raw.githubusercontent.com/Henry-Sarabia/igdb/master/img/gopherigdb.png">

**Recently updated to support IGDB V3!**

Communicate with the [Internet Game Database API](https://www.igdb.com/api) quickly and easily
with the `igdb` [Go](https://golang.org/) package. With the `igdb` client, you can retrieve
with the **igdb** package. With the **igdb** client, you can retrieve
extensive information on any number of video games, characters, companies, media, artwork
and [much more](https://api-docs.igdb.com/#endpoints). Every IGDB API endpoint is supported!

If you would like to help the Go `igdb` project, please submit a pull request - it's always
If you would like to help the Go **igdb** project, please submit a pull request - it's always
greatly appreciated.

## Installation

If you do not have Go installed yet, you can find installation instructions
If you do not have [Go](https://golang.org/) installed yet, you can find installation instructions
[here](https://golang.org/doc/install). Please note that the package requires Go version
1.9 or later.
1.13 or later for module support.

To pull the most recent version of `igdb`, use `go get`.
To pull the most recent version of **igdb**, use `go get`.

```
go get github.com/Henry-Sarabia/igdb
Expand All @@ -38,7 +36,7 @@ Now you're ready to Go.

### Creating A Client

Before using the `igdb` package, you need to have an IGDB API key. If you do
Before using the **igdb** package, you need to have an IGDB API key. If you do
not have a key yet, you can sign up [here](https://api.igdb.com/signup).

Create a client with your API key to start communicating with the IGDB API.
Expand All @@ -51,7 +49,7 @@ If you need to use a preconfigured HTTP client, simply pass its address to the
`NewClient` function.

```go
client, err := igdb.NewClient("YOUR_API_KEY", &customClient)
client, err := igdb.NewClient("YOUR_API_KEY", &custom)
```

### Services
Expand Down Expand Up @@ -79,12 +77,12 @@ contains several examples on how to use each service function.

Service functions by themselves allow you to retrieve a considerable amount of
information from the IGDB but sometimes you need more control over the results
being returned. For this reason, the `igdb` package provides a set of
being returned. For this reason, the **igdb** package provides a set of
flexible functional options for customizing a service function's API query.

### Functional Options

The `igdb` package uses what are called functional options to apply different
The **igdb** package uses what are called functional options to apply different
query parameters to service function's API call. Functional options themselves
are merely first order functions that are passed to a service function.

Expand Down Expand Up @@ -140,7 +138,7 @@ filter out any character that does not have a gender code of 1 (which in this
case represents male), retrieve the id, name, and games fields, and return
only up to 5 of these results.

Second, the `igdb` package provides a `ComposeOptions` function which takes any
Second, the **igdb** package provides a `ComposeOptions` function which takes any
number of functional options as its parameters, composes them into a single
functional option, and returns that composed functional option.
```go
Expand Down Expand Up @@ -181,12 +179,12 @@ finely grained control over similar API calls.
## Examples

The repository contains several example mini-applications that demonstrate
how one might use the `igdb` package.
how one might use the **igdb** package.

* [Mini Applications](https://github.com/Henry-Sarabia/igdb/tree/master/examples)
* [Documentation Examples](https://godoc.org/github.com/Henry-Sarabia/igdb#pkg-examples)

If you have used the `igdb` package for a project and would like to have it
If you have used the **igdb** package for a project and would like to have it
featured here as a reference for new users, please submit an issue and I'll be
sure to add it.

Expand Down Expand Up @@ -219,4 +217,4 @@ on functional options
projects for inspiring me to create my own open source package for others to enjoy
* The [Awesome Go](https://github.com/avelino/awesome-go) project for so many
references to admire
* The awesome people in the IGDB community who were always open to my questions
* The awesome people in the IGDB community who are always open to questions
1 change: 0 additions & 1 deletion achievement.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const (

// AchievementService handles all the API calls for the IGDB
// Achievement endpoint.
// This endpoint is only available for the IGDB Pro tier or above.
type AchievementService service

// Get returns a single Achievement identified by the provided IGDB ID. Provide
Expand Down
1 change: 0 additions & 1 deletion achievementicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type AchievementIcon struct {

// AchievementIconService handles all the API calls for the IGDB
// AchievementIcon endpoint.
// This endpoint is only available for the IGDB Pro tier or above.
type AchievementIconService service

// Get returns a single AchievementIcon identified by the provided IGDB ID. Provide
Expand Down
1 change: 0 additions & 1 deletion externalgame.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const (
)

// ExternalGameService handles all the API calls for the IGDB ExternalGame endpoint.
// This endpoint is only available for the IGDB Pro tier or above.
type ExternalGameService service

// Get returns a single ExternalGame identified by the provided IGDB ID. Provide
Expand Down
3 changes: 2 additions & 1 deletion franchise.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package igdb

import (
"strconv"

"github.com/Henry-Sarabia/sliceconv"
"github.com/pkg/errors"
"strconv"
)

//go:generate gomodifytags -file $GOFILE -struct Franchise -add-tags json -w
Expand Down
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/Henry-Sarabia/igdb

go 1.13

require (
github.com/Henry-Sarabia/apicalypse v1.0.2
github.com/Henry-Sarabia/blank v3.0.0+incompatible
github.com/Henry-Sarabia/sliceconv v1.0.2
github.com/pkg/errors v0.9.1
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/Henry-Sarabia/apicalypse v1.0.2 h1:rM2SrWlMgNwyuzP/Ty8dvc5iYb1pWVGa+kF0RvSPMoE=
github.com/Henry-Sarabia/apicalypse v1.0.2/go.mod h1:elNsoPyACTUScwfjuZc1DLN68zFbeyDo2XlJkF1omts=
github.com/Henry-Sarabia/blank v3.0.0+incompatible h1:3JfHWx7YVr1bA+9aK1J2w9TrFpwAHfPibHOq4qwicSc=
github.com/Henry-Sarabia/blank v3.0.0+incompatible/go.mod h1:EKLnM7Lq0E08WmivZuJoo099i07THd4ISgOBs3wOKTw=
github.com/Henry-Sarabia/sliceconv v1.0.2 h1:1zH/sJmocRZz1g1FrmU06GsbskWLWglj6IHhFB9TdBA=
github.com/Henry-Sarabia/sliceconv v1.0.2/go.mod h1:FNvuZcThTpCgAjQQZjPSx7PkS/DYRT6jTV3oPQGP2lU=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
11 changes: 5 additions & 6 deletions igdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package igdb

import (
"encoding/json"
"github.com/Henry-Sarabia/apicalypse"
"github.com/pkg/errors"
"io/ioutil"
"net/http"

"github.com/Henry-Sarabia/apicalypse"
"github.com/pkg/errors"
)

// igdbURL is the base URL for the IGDB API.
Expand Down Expand Up @@ -99,10 +100,8 @@ type Client struct {

// NewClient returns a new Client configured to communicate with the IGDB.
// The provided apiKey will be used to make requests on your behalf. The
// provided Tier will determine the maximum limit and offset your key entitles
// you to in an API call. The provided HTTP Client will be the client making
// requests to the IGDB. If no HTTP Client is provided, a default HTTP client
// is used instead.
// provided HTTP Client will be the client making requests to the IGDB. If no
// HTTP Client is provided, a default HTTP client is used instead.
//
// If you need an IGDB API key, please visit: https://api.igdb.com/signup
func NewClient(apiKey string, custom *http.Client) *Client {
Expand Down
3 changes: 2 additions & 1 deletion keyword.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package igdb

import (
"strconv"

"github.com/Henry-Sarabia/sliceconv"
"github.com/pkg/errors"
"strconv"
)

//go:generate gomodifytags -file $GOFILE -struct Keyword -add-tags json -w
Expand Down
15 changes: 5 additions & 10 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package igdb

import (
"fmt"
"strings"

"github.com/Henry-Sarabia/apicalypse"
"github.com/Henry-Sarabia/blank"
"github.com/pkg/errors"
"strings"
)

// Errors returned by an Option when setting options for an API call.
Expand Down Expand Up @@ -88,10 +89,7 @@ func SetOrder(field string, order order) Option {
}

// SetLimit is a functional option used to limit the number of results from
// an API call. The default limit is 10.
// For free tier users, the maximum limit is 50.
// For pro tier users, the maximum limit is 500.
// For enterprise users, the maximum limit is 5000.
// an API call. The default limit is 10. The maximum limit is 500.
//
// For more information, visit: https://api-docs.igdb.com/#pagination
func SetLimit(lim int) Option {
Expand All @@ -105,15 +103,12 @@ func SetLimit(lim int) Option {
}

// SetOffset is a functional option used to offset the results from an API
// call. The default offset is 0.
// For free tier users, the maximum offset is 150.
// For pro tier users, the maximum offest is 5000.
// For enterprise users, there is no maximum offset.
// call. The default offset is 0. The maximum offest is 5000.
//
// For more information, visit: https://api-docs.igdb.com/#pagination
func SetOffset(off int) Option {
return func() (apicalypse.Option, error) {
if off < 0 {
if off < 0 || off > 5000 {
return nil, ErrOutOfRange
}

Expand Down
11 changes: 5 additions & 6 deletions screenshot.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package igdb

import (
"strconv"

"github.com/Henry-Sarabia/sliceconv"
"github.com/pkg/errors"
"strconv"
)

//go:generate gomodifytags -file $GOFILE -struct Screenshot -add-tags json -w

// Screenshot represents a screenshot of a particular game.
// For more information visit: https://api-docs.igdb.com/#screenshot
type Screenshot struct {
Image `json:"image"`
ID int `json:"id"`
Game int `json:"game"`
Image
ID int `json:"id"`
Game int `json:"game"`
}

// ScreenshotService handles all the API calls for the IGDB Screenshot endpoint.
Expand Down

0 comments on commit 21fbf59

Please sign in to comment.