add function to access BNN lists

This commit is contained in:
Dom 2019-08-13 16:42:52 +02:00
parent 2a776d5c5f
commit d4fe69d4fb
1 changed files with 35 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
"net/http" "net/http"
"time" "time"
bnn "gitea.statsd.de/dom/goBnn"
"golang.org/x/text/encoding/charmap" "golang.org/x/text/encoding/charmap"
) )
@ -145,3 +146,37 @@ func RetrievePricelist(client *http.Client) ([]SpricelistEntry, error) {
return priceList, nil return priceList, nil
} }
// RetrieveBnnlistPL - Downloads list PL and converts bnn list into an array
func RetrieveBnnlistPL(client *http.Client) (bnn.Bnn, error) {
// Download bnn
resp, err := client.Get("https://static.paxan.de/2016/PL.BNN")
if err != nil {
return bnn.Bnn{}, err
}
b, err := bnn.ReadBnn(resp.Body)
if err != nil {
return bnn.Bnn{}, err
}
return b, nil
}
// RetrieveBnnlistPLF - Downloads list PLF and converts bnn list into an array
func RetrieveBnnlistPLF(client *http.Client) (bnn.Bnn, error) {
// Download bnn
resp, err := client.Get("https://static.paxan.de/2016/PLF.BNN")
if err != nil {
return bnn.Bnn{}, err
}
b, err := bnn.ReadBnn(resp.Body)
if err != nil {
return bnn.Bnn{}, err
}
return b, nil
}