Documentation ¶
Index ¶
- Constants
- Variables
- func BuildURI(endpoint string, a ...interface{}) string
- func Int(i int) *int
- func SetConfig(c Config)
- func String(s string) *string
- type Action
- type ActionInput
- type Alert
- type AlertInput
- type Auth
- type Collection
- type Config
- type Embedded
- type Entity
- type Hateoas
- type Link
- type Station
- type StopInput
- type StopTime
Constants ¶
const ( ActionTypeTelegram = "telegram" ActionTypeMessenger = "messenger" )
Type of action available
const ( EmbeddedItems = "items" LinkFirst = "first" LinkLast = "last" LinkPrevious = "previous" LinkNext = "next" )
All keys can be found in hateoas collection
const ( EndpointLogin = "/login" // Station EndpointStations = "/stations" EndpointStation = EndpointStations + "/%d" // Trip EndpointTrips = "/trips" EndpointTrip = EndpointTrips + "/%d" EndpointStationStopsTime = EndpointStation + stopsTime // Alerts EndpointAlerts = "/alerts" EndpointStationAlerts = EndpointStation + stopTime + EndpointAlerts // Action EndpointActions = "/actions" )
List of endpoint used by the client
const URL = "https://api.train.cat"
URL of the API
Variables ¶
var ( ErrFirstPage = errors.New("no previous page") ErrLastPage = errors.New("no next page") )
Error relevant to collection
Functions ¶
Types ¶
type Action ¶
type Action struct { Entity Type string `json:"type"` Data map[string]string `json:"data"` Hateoas }
Action output from the API
func PostAction ¶
func PostAction(i ActionInput) (*Action, error)
PostAction add nex action to the API
type ActionInput ¶
ActionInput for the API
type Alert ¶
Alert output from the API
func CGetAllAlerts ¶
CGetAllAlerts get all pages and return all alerts
type AlertInput ¶
type AlertInput struct {
ActionID uint `json:"action_id"`
}
AlertInput for the API
type Collection ¶
type Collection struct { Page int `json:"page"` Limit int `json:"limit"` Pages int `json:"pages"` Total int `json:"total"` Hateoas }
Collection represent structure return by the API
func (*Collection) IsFirstPage ¶
func (c *Collection) IsFirstPage() bool
IsFirstPage return true if collection is currently on the first page
func (*Collection) IsLastPage ¶
func (c *Collection) IsLastPage() bool
IsLastPage return true if collection is currently on the last page
type Embedded ¶
type Embedded map[string]json.RawMessage
Embedded alias to map[string]json.RawMessage
type Entity ¶
type Entity struct {
ID uint `json:"id"`
}
Entity group all fields available in all entities return by the API
type Station ¶
type Station struct { Entity Name string `json:"name"` UIC string `json:"uic"` IsRealTime bool `json:"is_realtime"` Hateoas }
Station output of the API
func CGetAllStations ¶
CGetAllStations get all pages and return all stations
type StopTime ¶
StopTime output of the API
func CGetStopsTime ¶
CGetStops return all stopsTime available for one station
func (StopTime) GetStation ¶
GetStation return station associate
func (StopTime) GetTerminus ¶
GetTerminus return terminus of the trip