Add go documentation
This commit is contained in:
parent
3a90baa8fe
commit
ae5e90ae1f
|
@ -0,0 +1,65 @@
|
||||||
|
# ponyapi
|
||||||
|
|
||||||
|
import "github.com/Xe/PonyAPI/client/go"
|
||||||
|
|
||||||
|
Package ponyapi provides glue for applications written in Go that want to use
|
||||||
|
PonyAPI for getting information.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
#### type Episode
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Episode struct {
|
||||||
|
AirDate int `json:"air_date"`
|
||||||
|
Episode int `json:"episode"`
|
||||||
|
IsMovie bool `json:"is_movie"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Season int `json:"season"`
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Episode is an episode of My Little Pony: Friendship is Magic.
|
||||||
|
|
||||||
|
#### func GetEpisode
|
||||||
|
|
||||||
|
```go
|
||||||
|
func GetEpisode(season, episode int) (*Episode, error)
|
||||||
|
```
|
||||||
|
GetEpisode gets information about season x episode y or an error.
|
||||||
|
|
||||||
|
#### func Newest
|
||||||
|
|
||||||
|
```go
|
||||||
|
func Newest() (*Episode, error)
|
||||||
|
```
|
||||||
|
Newest returns information on the newest episode or an error.
|
||||||
|
|
||||||
|
#### func Random
|
||||||
|
|
||||||
|
```go
|
||||||
|
func Random() (*Episode, error)
|
||||||
|
```
|
||||||
|
Random returns information on a random episode.
|
||||||
|
|
||||||
|
#### func AllEpisodes
|
||||||
|
|
||||||
|
```go
|
||||||
|
func AllEpisodes() ([]*Episode, error)
|
||||||
|
```
|
||||||
|
AllEpisodes gets all information on all episodes or returns an error.
|
||||||
|
|
||||||
|
#### func GetSeason
|
||||||
|
|
||||||
|
```go
|
||||||
|
func GetSeason(season int) ([]*Episode, error)
|
||||||
|
```
|
||||||
|
GetSeason returns all information on season x or returns an error.
|
||||||
|
|
||||||
|
#### func Search
|
||||||
|
|
||||||
|
```go
|
||||||
|
func Search(query string) ([]*Episode, error)
|
||||||
|
```
|
||||||
|
Search takes the give search terms and uses that to search the list of
|
||||||
|
episodes.
|
|
@ -56,26 +56,33 @@ func getEpisodes(fragment string) ([]*Episode, error) {
|
||||||
return eswr.Episodes, nil
|
return eswr.Episodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Newest returns information on the newest episode or an error.
|
||||||
func Newest() (*Episode, error) {
|
func Newest() (*Episode, error) {
|
||||||
return getEpisode("/newest")
|
return getEpisode("/newest")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Random returns information on a random episode.
|
||||||
func Random() (*Episode, error) {
|
func Random() (*Episode, error) {
|
||||||
return getEpisode("/random")
|
return getEpisode("/random")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetEpisode gets information about season x episode y or an error.
|
||||||
func GetEpisode(season, episode int) (*Episode, error) {
|
func GetEpisode(season, episode int) (*Episode, error) {
|
||||||
return getEpisode(fmt.Sprintf("/season/%d/episode/%d", season, episode))
|
return getEpisode(fmt.Sprintf("/season/%d/episode/%d", season, episode))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AllEpisodes gets all information on all episodes or returns an error.
|
||||||
func AllEpisodes() ([]*Episode, error) {
|
func AllEpisodes() ([]*Episode, error) {
|
||||||
return getEpisodes("/all")
|
return getEpisodes("/all")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetSeason returns all information on season x or returns an error.
|
||||||
func GetSeason(season int) ([]*Episode, error) {
|
func GetSeason(season int) ([]*Episode, error) {
|
||||||
return getEpisodes(fmt.Sprintf("/season/%d", season))
|
return getEpisodes(fmt.Sprintf("/season/%d", season))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Search takes the give search terms and uses that to search the
|
||||||
|
// list of episodes.
|
||||||
func Search(query string) ([]*Episode, error) {
|
func Search(query string) ([]*Episode, error) {
|
||||||
path, err := url.Parse("/search")
|
path, err := url.Parse("/search")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue