surfliner

package module
v1.0.1-0...-13482ed Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

README

SurflineR

Build Status

NOTE: I would use Surfline's taxonomy API (https://services.surfline.com/taxonomy) instead of my API (https://github.com/mhelmetag/surfline_regions) and this client. My API and this client were meant to bridge the gap when Surfline didn't have an appropriate JSON API for regions they support. Now they do.

Go Client for the Surfline Regions API.

Installation

Simply run go get github.com/mhelmetag/surfliner and start using it in your own apps!

Usage

The full example for fetching Areas, Regions and Sub Regions can be found in examples/main.go and can be run with go run examples/main.go.

To list all Surfline Areas, first instantiate a new Client and then call Areas():

package main

import "github.com/mhelmetag/surfliner"

client, err := surfliner.DefaultClient()
areas, err := client.Areas()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	// contains filtered or unexported fields
}

APIError is an error that can be returned by the Surfline Regions API.

func (APIError) Error

func (e APIError) Error() string

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string
	// contains filtered or unexported fields
}

Client is the SurflineR HTTP Client.

func DefaultClient

func DefaultClient() (*Client, error)

DefaultClient returns a default configured SurflineR Client.

func (*Client) Areas

func (c *Client) Areas() ([]Place, error)

Areas returns all Surfline Areas.

func (*Client) Regions

func (c *Client) Regions(areaID string) ([]Place, error)

Regions returns all Surfline Regions for an Area.

func (*Client) SubRegion

func (c *Client) SubRegion(areaID string, regionID string, subRegionID string) (Place, error)

SubRegion returns a Surfline SubRegion.

func (*Client) SubRegions

func (c *Client) SubRegions(areaID string, regionID string) ([]Place, error)

SubRegions returns all Surfline SubRegions for a Region.

type Place

type Place struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Place can either be an Area, Region or SubRegion (any of the tiers in Surfline's Place hierarchy).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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