Add RDEX
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user