wsf

package module
v0.0.0-...-2c7338d Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2017 License: LGPL-3.0 Imports: 9 Imported by: 0

README

go-wsf GoDoc Go Report Card

Go library for consuming the Washington State Ferries REST API.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {

	// Base URL for API requests. Defaults to https://www.wsdot.wa.gov/Ferries/API/.
	// BaseURL should always be specified with a trailing backslash.
	BaseURL *url.URL

	UserAgent string

	// Access code for the WSF API, provisioned at https://www.wsdot.wa.gov/Traffic/API/.
	// Requests will fail unless this is defined.
	AccessCode string

	//Different parts of the WSF API, referred to herin as Services.
	Vessels *VesselsService
	// contains filtered or unexported fields
}

A Client manages communication with the WSF API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new WSF API client. If a nil httpClient is privided then then http.DefaultClient will be used.

type Time

type Time time.Time

Time implements a custom JSON unmarsaller for the specific format of non-RFC 3339 time output by the WSF API. Cast the variable to a time.Time to get to the underlying type.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshalls the time output by the WSF API

type VesselLocation

type VesselLocation struct {
	VesselID                int
	VesselName              string
	Mmsi                    int `json:",omitempty"`
	DepartingTerminalID     int
	DepartingTerminalName   string
	DepartingTerminalAbbrev string
	ArrivingTerminalID      int    `json:",omitempty"`
	ArrivingTerminalName    string `json:",omitempty"`
	ArrivingTerminalAbbrev  string `json:",omitempty"`
	Latitude                float64
	Longitude               float64
	Speed                   float64
	Heading                 float64
	InService               bool
	AtDock                  bool
	LeftDock                Time   `json:"LeftDock, string, omitempty"`
	Eta                     Time   `json:"Eta, string, omitempty"`
	EtaBasis                string `json:",omitempty"`
	ScheduledDeparture      Time   `json:"ScheduledDeparture, string, omitempty"`
	OpRouteAbbrev           []string
	VesselPositionNum       int `json:",omitempty"`
	SortSeq                 int
	ManagedBy               int  // Enum, 1 for WSF, and 2 for KCM
	TimeStamp               Time `json:"TimeStamp, string"`
}

VesselLocation is the location and related data for a single vessel.

type VesselLocations

type VesselLocations []VesselLocation

VesselLocations is an array of VesselLocation, which should include every vessel tracked by the endpoint.

type VesselsService

type VesselsService service

VesselsService handles communication with the WSF Vessels API, which includes vessel attributes, locations, and other vessel-specific data. For the corresponding WSF REST API documentation, see http://www.wsdot.wa.gov/ferries/api/vessels/documentation/rest.html

func (*VesselsService) VesselLocations

func (s *VesselsService) VesselLocations() (*VesselLocations, error)

VesselLocations returns an array of every tracked vessel's location data, along with some other related information. This is updated frequently on the endpoint. See http://www.wsdot.wa.gov/Ferries/API/vessels/rest/vessellocations

Jump to

Keyboard shortcuts

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