gophish

package module
v0.0.0-...-8828ea1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2019 License: MIT Imports: 7 Imported by: 2

README

GoPhish

MIT licensed GoDoc Build Status Coverage Status Go Report Card

This is a Golang client for the Phish.net API.

Supported API Endpoints

  • /shows/query
  • /setlists/latest
  • /setlists/get
  • /setlists/recent
  • /setlists/tiph
  • /setlist/random

Documentation

Overview

Package gophish provides a convenient wrapper around the Phish.Net API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDate

func FormatDate(date time.Time) string

FormatDate converts a time.Time into the correct format that the Phish.Net API expects.

func ParseDate

func ParseDate(date string) (time.Time, error)

ParseDate parses the date string into a time.Time for use in the Phish.Net API.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a http.Client wrapper that handles rate limiting as well as provides convenience methods for various Phish.Net API endpoints.

func NewClient

func NewClient(apiKey string, opts ...ClientOpt) *Client

NewClient returns a new Client for making requests to the Phish.Net API.

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do sends a throttled request.

func (*Client) SetlistsGet

func (c *Client) SetlistsGet(req *SetlistsGetRequest) (*SetlistsResponse, error)

func (*Client) SetlistsLatest

func (c *Client) SetlistsLatest() (*SetlistsResponse, error)

func (*Client) SetlistsRandom

func (c *Client) SetlistsRandom() (*SetlistsResponse, error)

func (*Client) SetlistsRecent

func (c *Client) SetlistsRecent(req *SetlistsRecentRequest) (*SetlistsResponse, error)

func (*Client) SetlistsTiph

func (c *Client) SetlistsTiph() (*SetlistsResponse, error)

func (*Client) ShowsQuery

func (c *Client) ShowsQuery(req *ShowsQueryRequest) (*ShowsQueryResponse, error)

type ClientOpt

type ClientOpt func(*Client)

ClientOpt is a option configuring the Client.

func WithBaseUrl

func WithBaseUrl(url string) ClientOpt

WithBaseUrl sets the baseurl that should be used for requests. The default is https://api.phish.net/v3.

func WithQueryRate

func WithQueryRate(rate time.Duration) ClientOpt

WithQueryRate sets the rate limiting that should be used when making requests with the client.

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOpt

WithTimeout sets the default timeout for making HTTP requests.

type ErrorResponse

type ErrorResponse struct {
	ErrorCode int                `json:"error"`
	Response  *ErrorResponseBody `json:"response"`
}

ErrorResponse is the standard error format for API errors.

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

type ErrorResponseBody

type ErrorResponseBody struct {
	Message string                 `json:"message"`
	Body    map[string]interface{} `json:"body"`
}

type ResponseHeader

type ResponseHeader struct {
	ErrorCode    int    `json:"error_code"`
	ErrorMessage string `json:"error_message"`
}

type Setlist

type Setlist struct {
	ShowId       int    `json:"showid"`
	ShowDate     string `json:"showdate"`
	ShortDate    string `json:"short_date"`
	LongDate     string `json:"long_date"`
	RelativeDate string `json:"relative_date"`
	Url          string `json:"url"`
	GapChart     string `json:"gapchart"`
	Artist       string `json:"artist"`
	ArtistId     int    `json:"artistid"`
	VenueId      int    `json:"venueid"`
	Venue        string `json:"venue"`
	Location     string `json:"location"`
	SetlistData  string `json:"setlistdata"`
	SetlistNotes string `json:"setlistnotes"`
	Rating       string `json:"rating"`
}

type SetlistsGetRequest

type SetlistsGetRequest struct {
	ShowId   int    `url:"showid,omitempty"`
	ShowDate string `url:"showdate,omitempty"`
}

type SetlistsRecentRequest

type SetlistsRecentRequest struct {
	Limit int `url:"limit,omitempty"`
}

type SetlistsResponse

type SetlistsResponse struct {
	*ResponseHeader
	Response *SetlistsResponseBody `json:"response"`
}

type SetlistsResponseBody

type SetlistsResponseBody struct {
	Count int        `json:"count"`
	Data  []*Setlist `json:"data"`
}

type Show

type Show struct {
	ShowId       int    `json:"showid"`
	ShowDate     string `json:"showdate"`
	ArtistId     int    `json:"artistid"`
	BilledAs     string `json:"billed_as"`
	Link         string `json:"link"`
	Location     string `json:"location"`
	Venue        string `json:"venue"`
	SetlistNotes string `json:"setlistnotes"`
	VenueId      int    `json:"venueid"`
	TourId       int    `json:"tourid"`
	TourName     string `json:"tourname"`
	TourWhen     string `json:"tourwhen"`
	ArtistLink   string `json:"artistlink"`
}

type ShowsQueryRequest

type ShowsQueryRequest struct {
	ShowIds     []string `url:"showids,omitempty"`
	Year        int      `url:"year,omitempty"`
	Month       int      `url:"month,omitempty"`
	Day         int      `url:"day,omitempty"`
	VenueId     int      `url:"venueid,omitempty"`
	TourId      int      `url:"tourid,omitempty"`
	Country     string   `url:"country,omitempty"`
	City        string   `url:"city,omitempty"`
	State       string   `url:"state,omitempty"`
	ShowdateGt  string   `url:"showdate_gt,omitempty"`
	ShowdateGte string   `url:"showdate_gte,omitempty"`
	ShowdateLt  string   `url:"showdate_lt,omitempty"`
	ShowdateLte string   `url:"showdate_lte,omitempty"`
	ShowyearGt  int      `url:"showyear_gt,omitempty"`
	ShowyearGte int      `url:"showyear_gte,omitempty"`
	ShowyearLt  int      `url:"showyear_lt,omitempty"`
	ShowyearLte int      `url:"showyear_lte,omitempty"`
	Limit       int      `url:"limit,omitempty"`
	Order       string   `url:"order,omitempty"`
}

ShowsQueryRequest is the request type for the shows/query endpoint.

type ShowsQueryResponse

type ShowsQueryResponse struct {
	*ResponseHeader
	Response *ShowsQueryResponseBody `json:"response"`
}

type ShowsQueryResponseBody

type ShowsQueryResponseBody struct {
	Count int     `json:"count"`
	Data  []*Show `json:"data"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL