Add VAGEFAClient
All checks were successful
Build image / build-image (push) Successful in 3m12s

This commit is contained in:
Paul Brinkmeier 2025-04-27 15:30:45 +02:00
parent 1c1aad5846
commit a563cc45b5
3 changed files with 36 additions and 2 deletions

View File

@ -11,3 +11,4 @@
- [x] Transfer using JSON - [x] Transfer using JSON
- [x] Correctly implement basic auth - [x] Correctly implement basic auth
- [ ] Use unidecode to replace non-ascii stuff in the backend - [ ] Use unidecode to replace non-ascii stuff in the backend
- [ ] Add query parameter for selecting EFAClient

View File

@ -16,7 +16,7 @@
vrnp-static = pkgs.buildGoModule { vrnp-static = pkgs.buildGoModule {
pname = "vrnp"; pname = "vrnp";
version = "0.0.8"; version = "0.0.9";
vendorHash = null; vendorHash = null;
# For building the package, we use only the files not ignored by Git as inputs. # For building the package, we use only the files not ignored by Git as inputs.

33
main.go
View File

@ -55,6 +55,7 @@ var allEfaClients []EFAClient = []EFAClient{
BwegtEFAClient{}, BwegtEFAClient{},
VRNEFAClient{}, VRNEFAClient{},
KVVEFAClient{}, KVVEFAClient{},
VAGEFAClient{},
} }
type VRNEFAClient struct { type VRNEFAClient struct {
@ -151,6 +152,38 @@ func (c BwegtEFAClient) BuildRequest(stopId string) (*http.Request, error) {
return req, nil 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) { func FetchDepartures(c EFAClient, stopId string) (DMResponse, error) {
req, err := c.BuildRequest(stopId) req, err := c.BuildRequest(stopId)
if err != nil { if err != nil {