aklapi

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: BSD-2-Clause Imports: 10 Imported by: 0

README

Auckland Council API (unofficial)

Full list of available endpoints, for detailed description see below.

Name Endpoint Parameters Comments
Address /api/v1/addr addr: partial address Address Query
Rubbish and Recycling short /api/v1/rr addr: partial address Rubbish and Recycling, short format
Rubbish and Recycling /api/v1/rrext addr: partial address Rubbish and Recycling
Healthcheck /healthcheck Returns OK if alive
  • /api/v1/addr, parameter: addr -
Rubbish and Recycling

Two endpoints so far, both accepting addr parameter.

  • /api/v1/rr/ - rubbish and recycling, returns the JSON of the following format:

    {
        "rubbish": "2020-02-25",
        "recycle": "2020-02-25",
        "address": "Britomart, CBD"
    }
    
  • /api/v1/rrext/ - extended rubbish and recycling. Returns the JSON in the following format:

    {
        "Collections": [
            {
                "Day": "Monday 24 January",
                "Date": "2020-01-24T00:00:00+13:00",
                "Rubbish": true,
                "Recycle": true
            },
            {
                "Day": "Monday 31 January",
                "Date": "2020-01-31T00:00:00+13:00",
                "Rubbish": true,
                "Recycle": false
            }
        ],
        "Address": {
            "ACRateAccountKey": "12342478585",
            "Address": "500 Queen Street, Auckland Central",
            "Suggestion": "500 Queen Street, Auckland Central"
        }
    }
    

Example:

$ curl --location --request GET 'https://<server>/api/v1/rr/?addr=500%20Queen%20Street'
{"rubbish":"2020-02-24","recycle":"2020-02-24","address":"500 Queen Street, Auckland Central"}
Integrating with Home Assistant

Add the following to your configuration.yaml:

sensor:
  - platform: rest
    resource: https://your_server/api/v1/rr/?addr=500%20Mystreet
    name: Recycle
    value_template: '{{ value_json.recycle }}'

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoCache = false

NoCache is a flag to disable caching of the results.

Functions

This section is empty.

Types

type AddrRequest

type AddrRequest struct {
	ResultCount     int    `json:"ResultCount"`
	SearchText      string `json:"SearchText"`
	RateKeyRequired bool   `json:"RateKeyRequired"`
}

AddrRequest is the address request.

type AddrResponse

type AddrResponse []Address

AddrResponse is the address response.

func AddressLookup

func AddressLookup(addr string) (AddrResponse, error)

AddressLookup is a convenience function to get addresses.

func MatchingPropertyAddresses

func MatchingPropertyAddresses(addrReq *AddrRequest) (AddrResponse, error)

MatchingPropertyAddresses wrapper around the AKL Council API.

type Address

type Address struct {
	ACRateAccountKey string `json:"ACRateAccountKey"`
	Address          string `json:"Address"`
	Suggestion       string `json:"Suggestion"`
}

AddrSuggestion is the address suggestion.

func (Address) String

func (s Address) String() string

type CollectionDayDetailResult

type CollectionDayDetailResult struct {
	Collections []RubbishCollection
	Address     *Address
}

CollectionDayDetailResult contains the information about Rubbish and Recycling collection.

func CollectionDayDetail

func CollectionDayDetail(addr string) (*CollectionDayDetailResult, error)

CollectionDayDetail returns a collection day details for the specified address as reported by the Auckland Council Website.

func (*CollectionDayDetailResult) NextFoodScraps added in v1.1.0

func (res *CollectionDayDetailResult) NextFoodScraps() time.Time

NextFoodScraps returns the next food scraps collection date.

func (*CollectionDayDetailResult) NextRecycle

func (res *CollectionDayDetailResult) NextRecycle() time.Time

NextRecycle returns the next recycle collection date.

func (*CollectionDayDetailResult) NextRubbish

func (res *CollectionDayDetailResult) NextRubbish() time.Time

NextRubbish returns the next rubbish collection date.

type RubbishCollection

type RubbishCollection struct {
	Day        string
	Date       time.Time
	Rubbish    bool
	Recycle    bool
	FoodScraps bool
}

RubbishCollection contains the date and type of collection.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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