Add VAGEFAClient
Build image / build-image (push) Successful in 3m12s

This commit is contained in:
2025-04-27 15:31:40 +02:00
parent 1c1aad5846
commit a563cc45b5
3 changed files with 36 additions and 2 deletions
+34 -1
View File
@@ -55,6 +55,7 @@ var allEfaClients []EFAClient = []EFAClient{
BwegtEFAClient{},
VRNEFAClient{},
KVVEFAClient{},
VAGEFAClient{},
}
type VRNEFAClient struct {
@@ -151,6 +152,38 @@ func (c BwegtEFAClient) BuildRequest(stopId string) (*http.Request, error) {
return req, nil
}
type VAGEFAClient struct {
}
func (c VAGEFAClient) GetName() string {
return "VAG"
}
func (c VAGEFAClient) BuildRequest(stopId string) (*http.Request, error) {
// Create request object
req, err := http.NewRequest("GET", "https://efa.vagfr.de/vagfr3/XSLT_DM_REQUEST", nil)
if err != nil {
return nil, err
}
// Configure our request
query := url.Values{}
query.Set("coordOutputFormat", "EPSG:4326")
query.Set("depType", "stopEvents")
query.Set("includeCompleteStopSeq", "0")
query.Set("limit", "10")
query.Set("locationServerActive", "0")
query.Set("mode", "direct")
query.Set("name_dm", stopId)
query.Set("outputFormat", "json")
query.Set("type_dm", "stop")
query.Set("useOnlyStops", "1")
query.Set("useRealtime", "1")
req.URL.RawQuery = query.Encode()
return req, nil
}
func FetchDepartures(c EFAClient, stopId string) (DMResponse, error) {
req, err := c.BuildRequest(stopId)
if err != nil {
@@ -281,7 +314,7 @@ func main() {
platform = &query["platform"][0]
}
c := efaClients[(efaClient.Add(1)-1)%uint64(len(efaClients))]
c := efaClients[(efaClient.Add(1) - 1) % uint64(len(efaClients))]
ds, err := FetchDepartures(c, stopId)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)