Documentation ¶
Index ¶
Constants ¶
const ( LineCodeAll = "" LineCodeBlue = "BL" LineCodeGreen = "GR" LineCodeOrange = "OR" LineCodeRed = "RD" LineCodeSilver = "SV" LineCodeYellow = "YL" APIKeyHeader = "api_key" )
Variables ¶
This section is empty.
Functions ¶
func CloseResponseBody ¶
CloseResponseBody is a helper function to close response body and log error
Types ¶
type Client ¶
type Client struct { APIKey string HTTPClient HTTPClient }
Client is a wmata specific http client that includes authentication information
func NewWMATAClient ¶
NewWMATAClient returns a new client to make requests to the WMATA API
func NewWMATADefaultClient ¶
NewWMATADefaultClient returns a new client to make requests to the WMATA API This creates a default http.Client with a 30 second timeout
func (*Client) BuildAndSendGetRequest ¶
func (client *Client) BuildAndSendGetRequest(responseFormat ResponseType, url string, queryParams map[string]string, apiResponse interface{}) error
BuildAndSendGetRequest constructs and sends a generic HTTP GET request against the WMATA API
func (*Client) ValidateAPIKey ¶
ValidateAPIKey sends a validation request to the WMATA API to verify the given API works and that WMATA is available. Returns 200, nil if able to connect and receive a success (200) response from WMATA - otherwise returns status code and error message