This commit is contained in:
Arnaud Delcasse
2025-10-10 15:11:27 +02:00
parent 63fc3e7c83
commit a2c82a1a5c
6 changed files with 617 additions and 76 deletions

View File

@@ -31,6 +31,10 @@ func NewCarpoolRoutingHandler(cfg *viper.Viper) (*CarpoolRoutingHandler, error)
if !ok {
return nil, errors.New("missing operator_id")
}
operatorName, ok := o["name"].(string)
if !ok {
return nil, errors.New("missing name")
}
apiKey, ok := o["api_key"].(string)
if !ok {
return nil, errors.New("missing api_key")
@@ -39,11 +43,33 @@ func NewCarpoolRoutingHandler(cfg *viper.Viper) (*CarpoolRoutingHandler, error)
if !ok {
return nil, errors.New("missing base_url")
}
operatorapi, err := carpool.NewBBCDailyCarpoolAPI(operatorId, apiKey, baseUrl)
operatorapi, err := carpool.NewBBCDailyCarpoolAPI(operatorId, operatorName, apiKey, baseUrl)
if err != nil {
return nil, fmt.Errorf("could not create Blablacar Daily API: %w", err)
}
operatorApis = append(operatorApis, operatorapi)
} else if operatorType == "rdex" {
operatorId, ok := o["operator_id"].(string)
if !ok {
return nil, errors.New("missing operator_id")
}
operatorName, ok := o["name"].(string)
if !ok {
return nil, errors.New("missing name")
}
apiKey, ok := o["api_key"].(string)
if !ok {
return nil, errors.New("missing api_key")
}
baseUrl, ok := o["base_url"].(string)
if !ok {
return nil, errors.New("missing base_url")
}
operatorapi, err := carpool.NewRDEXCarpoolAPI(operatorId, operatorName, apiKey, baseUrl)
if err != nil {
return nil, fmt.Errorf("could not create RDEX API: %w", err)
}
operatorApis = append(operatorApis, operatorapi)
}
}
return &CarpoolRoutingHandler{